-
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
improve exception messages used within import dialog #314
improve exception messages used within import dialog #314
Conversation
when .listAllTargets() fails: - log the command line - provide better exception messages for failure cases
CI failed because of the md5sum, just uploaded another commit to fix that. Since |
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! Look mostly good with some aspects to address.
processOutput.getExitCode()) + | ||
String.format("argv: '%s'\n", cmd.getCommandLineString()) + | ||
String.format("stdout:\n%s\n", listOutput) + | ||
String.format("warnings:\n%s\n", processOutput.getStdout()) + |
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.
if the command fails, nothing will be in listOutput
.
so stdout will be processOutput.getStdout()
and stderr will be processOutput.getStderr()
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.
That makes sense -- I've made the exception message contain just stdout and stderr as you described.
String.format("argv: '%s'\n", cmd.getCommandLineString()) + | ||
String.format("stdout:\n%s\n", listOutput) + | ||
String.format("warnings:\n%s\n", processOutput.getStdout()) + | ||
String.format("stderr:\n%s\n", processOutput.getStderr()); |
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: instead of \n
on every line, put them in an array then join with \n
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.
Fixed.
} | ||
else { | ||
throw new PantsException("Failed:" + cmd.getCommandLineString()); | ||
final String errorDescription = | ||
String.format("could not list targets: pants exited with status %d\n", |
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: capitalization Could not...... Pants ...
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.
Fixed, also fixed in the other exception message to "Could not execute command..."
.
String.format("could not execute command: '%s' due to error: '%s'", | ||
cmd.getCommandLineString(), | ||
e.getMessage()); | ||
LOG.warn(noProcessErrMsg, e); |
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:
1.noProcessErrMsg
may suggests boolean, maybe otherProcessErrMsg
2. capitalization in error message
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.
Changed to processCreationFailureMessage
and fixed capitalization.
master currently fails the test suite, because jetbrains has removed the previous version of IDEA for download from their site. This pull request makes the changes listed below so master can run again. This issue was blocking #312 and #314. - bump ij version to the [most recent available release](https://www.jetbrains.com/idea/download) - update list of jars read from the scala plugin directory for the new version of ij - update checksums for IDEA and plugins - update scala sdk version to 2.11.11 - explicitly specify python and jdk version in `.travis.yml` - refactor some calls that were marked deprecated in between previous and current versions of ij
I removed I still don't know how to make a test checking whether the project import dialog does actually get closed after |
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 good. Thanks @cosmicexplorer ! just a few points
File projectDir = getProjectFolder(); | ||
VirtualFile virtualProjectDir = LocalFileSystem.getInstance().findFileByIoFile(projectDir); | ||
Optional<VirtualFile> pantsIniFileResult = PantsUtil.findPantsIniFile(Optional.ofNullable(virtualProjectDir)); | ||
assertTrue(pantsIniFileResult.isPresent()); |
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 you add appropriate error messages for all assertions?
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, here and elsewhere.
File nonexistentFile = new File(nonexistentFilePath); | ||
assertTrue(!nonexistentFile.exists()); | ||
assertTrue(!PantsUtil.isBUILDFilePath(nonexistentFilePath)); | ||
assertEquals(PantsUtil.listAllTargets(nonexistentFilePath), |
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.
Generally speaking, each test function should focus on one method instead of covering all the methods. Otherwise if you change the behavior of some function in the future, it requires modifying multiple test functions. E.g.
void testBuildFilePath() {
assertTrue("msg", PantsUtil.isBUILDFilePath(...))
assertFalse("msg", PantsUtil.isBUILDFilePath(...))
}
void testListTargets() {
...
}
Let me know if you would prefer to do so with a separate patch.
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.
That makes sense. I'll fix that in this file and in PantsProjectSettingsTest.java
.
String pantsIniFilePath = pantsIniFileResult.get().getPath(); | ||
File pantsIniFile = new File(pantsIniFilePath); | ||
assertTrue(pantsIniFile.exists() && !pantsIniFile.isDirectory()); | ||
assertTrue(!PantsUtil.isBUILDFilePath(pantsIniFilePath)); |
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.
use assertFalse
instead, ditto for other cases.
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, here and elsewhere.
|
||
public void testListTargetInvalidBuildFile() { | ||
String projectDir = getProjectFolder().getPath(); | ||
Path invalidBuildFilePath = Paths.get( |
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 probably use something like https://github.com/wisechengyi/intellij-pants-plugin/blob/540e81a0b001aac8bbdef23dd966804d60cc3f4f/testFramework/com/twitter/intellij/pants/testFramework/PantsTestUtils.java#L16 to get testData
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.
Gotcha, I'll try to make this cleaner.
} catch (PantsException e) { | ||
caught = true; | ||
} | ||
assertTrue("PantsException not thrown for invalid BUILD file", caught); |
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 can put the assertion/fail message in the try block, e.g. https://github.com/wisechengyi/intellij-pants-plugin/blob/e01fd6db7c00636108cb95f12bb8bef7fc853e59/tests/com/twitter/intellij/pants/model/PantsOptionsTest.java#L53-L61
so no need for the caught
variable.
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 the example, I hadn't thought of that. I'll make the 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.
Thanks @cosmicexplorer . just one nit
|
||
try { | ||
PantsUtil.listAllTargets(invalidBuildFilePath); | ||
fail(String.format("%s should have been thrown")); |
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.
is there a particular exception to be caught? what is %s for?
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.
Whoops. I used String.format()
following the example you gave in your previous comment, but forgot that means I need to check it. Just pushed a change fixing this.
# Notable Changes - Compatibility with IntelliJ 2017.3. #319 - Add .idea, .pants.d to git ignore. #307 - Improve exception messages used within import dialog. #314, #321 - Update release doc. #306 - Add a lint action to the plugin context menus and dropdown menu. #312 - Fix a bug which would occur when displaying two projects at once. #320 - Attach annotations for plugin selected JDK. #308
PantsUtil.listAllTargets()
fails.Currently, the function throws a
PantsException
on failure which describes the command line that failed. This command line already contains the output file, incidentally, but this change makes the output file explicit.