-
Notifications
You must be signed in to change notification settings - Fork 98
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
Feature/separate plugin config and execution #1542
Feature/separate plugin config and execution #1542
Conversation
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.
reconsider what the formatter did here :(
.a_build().with() | ||
.the_task("jgivenTestReport").is_successful(); | ||
.a_build().with() | ||
.the_task("-x").the_task("test").and() |
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.
@jjohannes I'd like to, for one final time, have your opinon on this one.
To me it seems, now that we properly use Providers, Gradle is able to track the necessary inputs of the JGiven task.
Therefore, previously a JGiven report task would not run, if a test task was not explicitely requested. Now, I assume that because we explicitely request the report task to run, Gradle knows that it needs to run the test task and does so accordingly.
While this is changed behavior, I am of the opinon, that we are now more in line with how Gradle is expected to behave and therefore this would generally be an appreciated change.
How do you see this?
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.
Yes, your observation is correct. The providers that point at task outputs carry the task dependency information and that is why the test
task is automatically executed before.
If you can accept the breaking change, I would agree that this is the better behavior. It follows Gradle best practices. (If not, there would be ways to "trick" the setup into loosing the dependency but still using providers in general.)
Note: Traditionally the jacoco
report task built into Gradle core also does not follow this best practice. However I believe this is due to not wanting to break the behavior that was introduced early (pre Gradle 1.0). If the JaCoCo tasks/plugin would be created today, I think it would also behave different.
d4b8874
to
8fbb431
Compare
protected ObjectFactory getObjects() { | ||
throw new UnsupportedOperationException(); | ||
} |
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.
protected ObjectFactory getObjects() { | |
throw new UnsupportedOperationException(); | |
} | |
protected abstract ObjectFactory getObjects(); |
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.
Just a suggestion to make it "more compact".
reportTask.getResults().set(getResultsDirectory); | ||
|
||
String relativeFilePath = "jgiven" + "/" + test.getName() + "/"; | ||
Provider<Directory> reportOutputLocation= reportingExtension.getBaseDirectory().dir(relativeFilePath); |
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.
Provider<Directory> reportOutputLocation= reportingExtension.getBaseDirectory().dir(relativeFilePath); | |
Provider<Directory> reportOutputLocation = reportingExtension.getBaseDirectory().dir(relativeFilePath); |
Provider<Directory> getResultsDirectory = test.getExtensions() | ||
.getByType(JGivenTaskExtension.class) | ||
.getResultsDir(); | ||
|
||
reportTask.getResults().set(getResultsDirectory); |
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.
Provider<Directory> getResultsDirectory = test.getExtensions() | |
.getByType(JGivenTaskExtension.class) | |
.getResultsDir(); | |
reportTask.getResults().set(getResultsDirectory); | |
Provider<Directory> resultsDirectory = test.getExtensions() | |
.getByType(JGivenTaskExtension.class) | |
.getResultsDir(); | |
reportTask.getResults().convention(resultsDirectory); |
Using convention
makes this the "fall-back" value. Then you can be sure that if a user re-configures this, the user value will override the default. Changing the value here also allows users to "break" the task dependency to the test task if they are not happy with that change.
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.
Funnily enought, I had this as convention for a while, but convinced myself that "set" was correct ^^
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
these have been detailed https://github.com/jjohannes/JGiven/commit/cc3f67a7b4b39f9f78599c2cea18c42c95870c73 and authority to use these has been explicitly granted #1527 (comment) Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
turns out that this check is not what prevented the task from running and it is neither the "SkipWhenEmpty" instruction on the input. Rather, for some reason unknown to me, the test task did not run, but now it does. Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
…o using conventions Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
This commit is a reimplementation from dangling commit 37c736e of this repository, which I couldn't get to cherry pick. The original commit was done by jjohannes and the message reads "Move report location computation out of 'confiugureEach'" Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
I guess we don't need that anymore, now that we properly mapped in / and outputs via providers Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
…Given result Reason: Apparently, now that we use providers gradle can map the in and outputs of the jgiven task and hence requires a test task to run when a JGiven task is requested. Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
…d test tasks. A lot of those are technically testing the gradle API, but since handling that API is fiddly, and it is easy to do it wrong, I opt to rather have an additional assertion on how the Jgiven task operates. Especially for the case that we lay out in our example projects Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
to highlight that these are github usernames. Also these changes have been made through the entire document to be consistent. Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
802894f
to
ee64ff2
Compare
and minor code beatification from review comments Signed-off-by: l-1squared <30831153+l-1squared@users.noreply.github.com>
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.
Two small comments added.
when: | ||
def result = GradleRunner.create() | ||
.withProjectDir(testProjectDir) | ||
.withArguments("--configuration-cache", "test", "jgivenTestReport", "-S", "--info"/*, "-Dorg.gradle.debug=true"*/ ) |
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.
Will this comment still have some purpose?
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.
You could remove that comment but add this line:
.withDebug(ManagementFactory.getRuntimeMXBean().getInputArguments().toString().contains("-agentlib:jdwp"))
Then, when you start a test in debug in IntelliJ, it will run the "Gradle under test" in the same process that you are debugging. And you can debug inside plugin.
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.
Damn, I totally missed that. but @jjohannes thanks for the suggestion
import org.gradle.api.Task; | ||
import org.gradle.api.internal.ConventionMapping; | ||
import org.gradle.api.internal.IConventionAware; | ||
import org.gradle.api.*; |
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 this import be avoidable?
TODO:
test that the jgiven report doesn't produce results if neither test, nor report is requestedcheck how the report looks with that double task instructionbetter message for WIP commitchangelogcredit in changelog