summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiviu Ionescu2013-10-07 14:01:10 (EDT)
committerAndrew Gvozdev2013-10-08 11:01:13 (EDT)
commit775dc3fc68169d8558cfc76c41da8708aaa0a550 (patch)
treec3d71bf4a336f65c96a72be99603219f843b4f6a
parente2661d99930f9dbbfde5c8b5a096176c720d0044 (diff)
downloadorg.eclipse.cdt-775dc3fc68169d8558cfc76c41da8708aaa0a550.zip
org.eclipse.cdt-775dc3fc68169d8558cfc76c41da8708aaa0a550.tar.gz
org.eclipse.cdt-775dc3fc68169d8558cfc76c41da8708aaa0a550.tar.bz2
Bug 413678: trigger discovery after command line change
Change-Id: I543b95ba08c0f2a482799a6c37fe13759bc21550 Also-by: Andrew Gvozdev <angvoz.dev@gmail.com> Signed-off-by: Andrew Gvozdev <angvoz.dev@gmail.com> Signed-off-by: Liviu Ionescu <ilg@livius.net>
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java35
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java5
2 files changed, 40 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java
index 68c897f..5c3e4e7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java
@@ -889,6 +889,41 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
}
/**
+ * Test running a provider after changing the compiler command.
+ */
+ public void testAbstractBuiltinSpecsDetector_RerunOnCommandArgsChange() throws Exception {
+ // Create test "compiler"
+ java.io.File compiler = new java.io.File("compiler");
+ compiler.createNewFile();
+ assertTrue(compiler.exists());
+ String compilerPath = compiler.getAbsolutePath();
+
+ // Create provider
+ MockBuiltinSpecsDetectorWithRunCount provider = new MockBuiltinSpecsDetectorWithRunCount();
+ provider.setCommand(compilerPath + " arg1");
+ // register environment listener on workspace
+ provider.registerListener(null);
+ waitForProviderToFinish();
+ assertEquals(1, provider.getExecutedCount());
+
+ // Check that an event doesn't trigger unnecessary rerun
+ provider.handleEvent(null);
+ waitForProviderToFinish();
+ assertEquals(1, provider.getExecutedCount());
+
+ // Change the compiler command
+ provider.setCommand(compilerPath + " arg2");
+
+ // Check that an event triggers rerun after changing the compiler command
+ provider.handleEvent(null);
+ waitForProviderToFinish();
+ assertEquals(2, provider.getExecutedCount());
+
+ // unregister listeners
+ provider.unregisterListener();
+ }
+
+ /**
* Check that entries get grouped by kinds by stock built-in specs detector.
*/
public void testAbstractBuiltinSpecsDetector_GroupSettings() throws Exception {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
index 30d6e4f..696b575 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Gvozdev - initial API and implementation
+ * Liviu Ionescu - Bug 413678: trigger discovery after command line change
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.language.settings.providers;
@@ -419,6 +420,10 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
for (String languageId : languageIds) {
try {
String command = resolveCommand(languageId);
+ if (command != null) {
+ envHashNew = 31*envHashNew + command.hashCode();
+ }
+
String[] cmdArray = CommandLineUtil.argumentsToArray(command);
if (cmdArray != null && cmdArray.length > 0) {
IPath location = new Path(cmdArray[0]);