diff --git a/common/com/twitter/intellij/pants/util/PantsUtil.java b/common/com/twitter/intellij/pants/util/PantsUtil.java index 7e3ab8569..d9bc1243e 100644 --- a/common/com/twitter/intellij/pants/util/PantsUtil.java +++ b/common/com/twitter/intellij/pants/util/PantsUtil.java @@ -261,6 +261,11 @@ public static VirtualFile findProjectManifestJar(@NotNull Project myProject) { return null; } + public static GeneralCommandLine defaultCommandLine(@NotNull Project project) throws PantsException { + VirtualFile pantsExecutable = PantsUtil.findPantsExecutable(project); + return defaultCommandLine(pantsExecutable.getPath()); + } + public static GeneralCommandLine defaultCommandLine(@NotNull String projectPath) throws PantsException { final File pantsExecutable = PantsUtil.findPantsExecutable(new File(projectPath)); if (pantsExecutable == null) { diff --git a/testFramework/com/twitter/intellij/pants/testFramework/PantsIntegrationTestCase.java b/testFramework/com/twitter/intellij/pants/testFramework/PantsIntegrationTestCase.java index 8a5da664d..e4e8efca5 100644 --- a/testFramework/com/twitter/intellij/pants/testFramework/PantsIntegrationTestCase.java +++ b/testFramework/com/twitter/intellij/pants/testFramework/PantsIntegrationTestCase.java @@ -3,6 +3,7 @@ package com.twitter.intellij.pants.testFramework; +import com.google.common.base.Joiner; import com.intellij.compiler.impl.ModuleCompileScope; import com.intellij.execution.ExecutionException; import com.intellij.execution.ProgramRunnerUtil; @@ -161,6 +162,15 @@ private void cmd(String... args) throws ExecutionException { assertTrue("Failed to execute: " + StringUtil.join(args, " "), cmdOutput.getExitCode() == 0); } + protected void killNailgun() throws ExecutionException { + // NB: the ideal interface here is defaultCommandLine(myProject). However, + // not all tests call doImport therefore myProject may not always contain modules. + final GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(getProjectPath()); + commandLine.addParameter("ng-killall"); + // Wait for command to finish. + PantsUtil.getCmdOutput(commandLine, null); + } + @NotNull abstract protected File getProjectFolder(); @@ -339,7 +349,9 @@ private List assertCompilerMessages(List messages) { ); switch (message.getCategory()) { case ERROR: - fail("Compilation failed with error: " + prettyMessage); + // Always show full error messages. + + fail("Compilation failed with error: " + Joiner.on('\n').join(messages)); break; case WARNING: System.out.println("Compilation warning: " + prettyMessage); @@ -488,6 +500,9 @@ public void tearDown() throws Exception { if (myCompilerTester != null) { myCompilerTester.tearDown(); } + + // Kill nailgun after usage as memory on travis is limited, at a cost of slower later builds. + killNailgun(); cleanProjectRoot(); Messages.setTestDialog(TestDialog.DEFAULT); } diff --git a/tests/com/twitter/intellij/pants/integration/OSSPantsExamplesMultiTargetsIntegrationTest.java b/tests/com/twitter/intellij/pants/integration/OSSPantsExamplesMultiTargetsIntegrationTest.java index b0bd0bc29..9d59d8a51 100644 --- a/tests/com/twitter/intellij/pants/integration/OSSPantsExamplesMultiTargetsIntegrationTest.java +++ b/tests/com/twitter/intellij/pants/integration/OSSPantsExamplesMultiTargetsIntegrationTest.java @@ -6,13 +6,7 @@ import com.twitter.intellij.pants.testFramework.OSSPantsIntegrationTest; public class OSSPantsExamplesMultiTargetsIntegrationTest extends OSSPantsIntegrationTest { - public void testEmpty() { - // Unfortunately this is in junit 3 we need at least one method starts with 'test'. - // Remove once https://github.com/pantsbuild/intellij-pants-plugin/issues/133 is addressed. - } - - // TODO (peiyu) https://github.com/pantsbuild/intellij-pants-plugin/issues/133 - public void IGNORE_testHello() throws Throwable { + public void testHello() throws Throwable { doImport("examples/src/java/org/pantsbuild/example/hello"); assertModules(