-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gradle: fix test target for cli, examples, pts #351
Conversation
The following gradle targets were not running any of the unit tests contained in their directories due to incorrect test dependencies. It appears these projects all use JUnit 5 "vintage" tests, so need that engine as a test dependency. :cli:test :examples:test :pts:test CliTest: Add test for the PARTIQL_PRETTY output format added in commit 9175002. This was how I discovered this issue. examples: Remove tests from the implementation dependencies.
if (originalAst != deserializedAst) { | ||
throw Exception("expected AST to be equal") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we instead use the assertEquals
with a message parameter for the exception? I am not sure what we are gaining by using if
and throwing our own exception here, perhaps I am missing something though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason was to avoid requiring the kotlin-test
JAR from code that is technically not an automated unit test. I will revert that part of the change since you would prefer to use this dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining. In that case, ignore my comments for this file on using assert
. Let's keep the examples clean of testing libs.
if (statement != roundTrippedStatement) { | ||
throw Exception("Expected statements to be the same") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same argument here concerning assertEquals
// PTS | ||
testImplementation project(':testscript') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this dependency breaking anything? This (I believe) is what hooks into the PTS (included in this repo) system which runs more tests focusing on spec compliance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not breaking anything, but it seems to be unnecessary as the code builds without it? I haven't read the code in detail, but it appears to me that the dependency tree is that the pts
targets/directory imports the code in testscript
. I was assuming that means those are the targets that actually use this code. Nothing in the lang
directory references testscript AFAIK?
I barely understand this though; I just was curious if all these dependencies were actually needed. I will revert my changes to this file: the important updates are to cli
, examples
, and pts
so ./gradlew test
actually executes the tests in those directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I think my previous PR (#338) to fix Gradle to run on ParameterizedTest
s introduced this testing target bug.
Only have a few nits/questions.
import com.amazon.ion.system.* | ||
import org.partiql.examples.util.Example | ||
import org.partiql.lang.ast.* | ||
import org.partiql.lang.domains.PartiqlAst | ||
import org.partiql.lang.syntax.* | ||
import java.io.PrintStream | ||
import java.util.Objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: unused import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops thanks sorry; This was a stray import from a previous edit.
cli/test/org/partiql/cli/CliTest.kt
Outdated
val subject = makeCli("SELECT * FROM input_data", "{a: 1, b: 2}", | ||
outputFormat = OutputFormat.PARTIQL_PRETTY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could move onto the same line as the previous test
val subject = makeCli("SELECT * FROM input_data", "{a: 1, b: 2}", | |
outputFormat = OutputFormat.PARTIQL_PRETTY) | |
val subject = makeCli("SELECT * FROM input_data", "{a: 1, b: 2}", outputFormat = OutputFormat.PARTIQL_PRETTY) |
@@ -1,6 +1,5 @@ | |||
plugins { | |||
id 'org.jetbrains.kotlin.jvm' | |||
id 'io.gitlab.arturbosch.detekt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this plugin removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand gradle. I assumed since this file has no references to it, this is unnecessary?
The top level build.gradle
references detekt
, and I assumed the apply plugin
thing attempts to apply the plugin to all subprojects? If so, doesn't that mean this is unnecessary, since the top level project includes it?
FWIW, with this change, the ./gradlew cli:detekt
task still seems to work?
~/partiql-lang-kotlin $ ./gradlew cli:detekt --info
...
> Task :cli:detekt UP-TO-DATE
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't understand gradle too well. You seem to be right regarding the top level references to detekt
, which is applied to all the subprojects. Since the detekt
plugin isn't referenced in the other subprojects, could you also remove the detekt
plugin from
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, done, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make the suggested changes ... but maybe not for a few days; thanks for the prompt review!
if (originalAst != deserializedAst) { | ||
throw Exception("expected AST to be equal") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason was to avoid requiring the kotlin-test
JAR from code that is technically not an automated unit test. I will revert that part of the change since you would prefer to use this dependency.
// PTS | ||
testImplementation project(':testscript') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not breaking anything, but it seems to be unnecessary as the code builds without it? I haven't read the code in detail, but it appears to me that the dependency tree is that the pts
targets/directory imports the code in testscript
. I was assuming that means those are the targets that actually use this code. Nothing in the lang
directory references testscript AFAIK?
I barely understand this though; I just was curious if all these dependencies were actually needed. I will revert my changes to this file: the important updates are to cli
, examples
, and pts
so ./gradlew test
actually executes the tests in those directories.
import com.amazon.ion.system.* | ||
import org.partiql.examples.util.Example | ||
import org.partiql.lang.ast.* | ||
import org.partiql.lang.domains.PartiqlAst | ||
import org.partiql.lang.syntax.* | ||
import java.io.PrintStream | ||
import java.util.Objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops thanks sorry; This was a stray import from a previous edit.
@@ -1,6 +1,5 @@ | |||
plugins { | |||
id 'org.jetbrains.kotlin.jvm' | |||
id 'io.gitlab.arturbosch.detekt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand gradle. I assumed since this file has no references to it, this is unnecessary?
The top level build.gradle
references detekt
, and I assumed the apply plugin
thing attempts to apply the plugin to all subprojects? If so, doesn't that mean this is unnecessary, since the top level project includes it?
FWIW, with this change, the ./gradlew cli:detekt
task still seems to work?
~/partiql-lang-kotlin $ ./gradlew cli:detekt --info
...
> Task :cli:detekt UP-TO-DATE
...
CliTest.kt: format code on one line ParserExample.kt: remove unnecessary import lang,pts,testscript/build.gradle: remove detekt plugin (not needed)
sorry for the delay. I believe I addressed all the comments. Thanks again for the prompt review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed a deleted line in the first review. Once that's added back, should be approved and merged. Thanks again for the contribution!
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5' | ||
testImplementation 'pl.pragmatists:JUnitParams:[1.0.0,1.1.0)' | ||
testImplementation 'org.assertj:assertj-core:[3.11.0,3.12.0)' | ||
|
||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this dependency to run junit ParameterizedTest
s with ArgumentsSource
that we are starting to use (e.g. EvaluatingCompilerFromLetTests.kt). Without this dependency, these ParameterizedTest
s aren't being run by gradle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops nice catch thanks! This is probably why I should not make wholesale changes without understanding what I am actually doing :)
Description of changes:
The following gradle targets were not running any of the unit tests
contained in their directories due to incorrect test dependencies. It
appears these projects all use JUnit 5 "vintage" tests, so need that
engine as a test dependency.
CliTest: Add test for the PARTIQL_PRETTY output format added in commit
9175002. This was how I discovered this issue.
examples: Remove tests from the implementation dependencies.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.