-
Notifications
You must be signed in to change notification settings - Fork 55
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
Include jvm.test.junit.options
in IntelliJ test config
#439
Include jvm.test.junit.options
in IntelliJ test config
#439
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.
Thanks, Tomasz!
@@ -104,6 +105,11 @@ else if (testPackage != null) { | |||
} | |||
|
|||
taskSettings.setScriptParameters(StringUtil.join(scriptParameters, " ")); | |||
Optional<String[]> vmOptions = | |||
PantsOptions.getPantsOptions(module.getProject()).flatMap(options -> options.getList("jvm.test.junit.options")); | |||
|
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.
Would be good to extract the string to a constant next to https://github.com/pantsbuild/intellij-pants-plugin/blob/master/common/com/twitter/intellij/pants/util/PantsConstants.java#L40?
@@ -43,6 +44,12 @@ public boolean has(String optionName) { | |||
return Optional.ofNullable(options.get(optionName)); | |||
} | |||
|
|||
public Optional<String[]> getList(String optionName) { |
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.
Can you kindly add some unit tests for this function?
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.
Oh sorry. The pants runner does not need this change actually because Pants is already picking up those options via the ini files.
This is should be used for IntelliJ junit/scalatest and such, which is happens at
intellij-pants-plugin/src/com/twitter/intellij/pants/execution/PantsMakeBeforeRun.java
Lines 126 to 128 in 97a31e5
BeforeRunTask pantsMakeTask = new ExternalSystemBeforeRunTask(ID, PantsConstants.SYSTEM_ID); | |
pantsMakeTask.setEnabled(true); | |
runManagerImpl.setBeforeRunTasks(runConfiguration, Collections.singletonList(pantsMakeTask), false); |
Basically for any config that we have to replace
Build
with PantsCompile
.
Edit: url changed.
The VM options should appear in intellij's runners (e.g. junit/scala), but
should not appear in Pants' runner. Please let me know if it's still
confusing.
…On Mon, Nov 25, 2019 at 2:14 AM Tomasz Pasternak ***@***.***> wrote:
Oh, I didn't notice your last. Comment. I thought you want to override it
in IntelliJ runner :). If not, then it's OK, this PR shouldn't be merged.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#439?email_source=notifications&email_token=AAERTBT3LPK5TMCFEGHE5MLQVOQQRA5CNFSM4JQR2GI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFB3M4Q#issuecomment-558085746>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAERTBX5MZQKZYSGMLHXXPTQVOQQRANCNFSM4JQR2GIQ>
.
|
Yes, it's clear, I just noticed your note right after I submitted the commits. I have some problems w with classpath now, because the Pants plugin needs access to JUnit plugin's classes. Hopefully will be done tomorrow. |
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, Tomasz! Looks mostly good with some minor points.
|
||
if(runConfiguration instanceof JUnitConfiguration) { | ||
Optional<String[]> os = PantsOptions.getPantsOptions(project) | ||
.flatMap(options -> options.getList(PantsConstants.PANTS_OPTION_TEST_JUNIT_OPTIONS)); | ||
String optionsString = String.join(" ", os.orElse(new String[]{})); | ||
((JUnitConfiguration)runConfiguration).setVMParameters(optionsString); | ||
} | ||
|
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.
This logic is needed for if (PantsUtil.isScalaRelatedTestRunConfiguration(runConfiguration))
as well. So possibly we can extract this to a helper function.
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.
Done
|
||
|
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.
xx
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.
Done
private ConfigurationFromContext getPantsJunitConfigurationFromContext(ConfigurationContext context) { | ||
return getConfigurationFromContext(context, PantsJUnitTestRunConfigurationProducer.class); | ||
} |
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.
no longer used?
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.
Both getJunitConfigurationFromContext
and getPantsJunitConfigurationFromContext
are used. I Introduced getJunitConfigurationFromContext
in order to test new behavior.
Optional<String[]> os = PantsOptions.getPantsOptions(project) | ||
.flatMap(options -> options.getList(PantsConstants.PANTS_OPTION_TEST_JUNIT_OPTIONS)); |
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.
This introduces a minor lag in the UI if PantsOptions wasn't cached. We could either the following options:
- Show the UI
Getting Pants options ...
- Preemptively populate pants options up on project start.
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.
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.
Looks great. Thanks!
resources/META-INF/plugin.xml
Outdated
@@ -20,6 +20,7 @@ | |||
<!--Add gradle as a dep because of Pants runner requires it.--> | |||
<depends>com.intellij.gradle</depends> | |||
|
|||
<depends optional="true" config-file="pants-junit.xml">JUnit</depends> |
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.
This should be required. so optional=false
or not specifying it at all.
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 chose conditional dependency, because otherwise it was failing when you were using 2019.2 for development.
Now it's unconditional.
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! The plugin upgrade is normally backwards incompatible, so not-optional should be fine.
I broke the tests by accident while I was refactoring the code. Now it should be fine |
That means tests are working as intended :) |
Now it's only "Too many projects leaked:" test that fails |
Thanks! This looks good. Unfortunately I found a blocking issue that internally we use certain security manager settings in I will give it a bit more thought how we can proceed there. |
Dependency to JUnit in plugin.xml was required, because we now edit JUnitConfiguration class in PantsMakeBeforeRun, so we need this class in the PantsPlugin classpath. closes #435
It was broken while refactoring
@wisechengyi can we close it? |
ping @wisechengyi |
closes #435