1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

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>
This commit is contained in:
Liviu Ionescu 2013-10-07 21:01:10 +03:00 committed by Andrew Gvozdev
parent e2661d9993
commit 775dc3fc68
2 changed files with 40 additions and 0 deletions

View file

@ -888,6 +888,41 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
provider.unregisterListener(); provider.unregisterListener();
} }
/**
* 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. * Check that entries get grouped by kinds by stock built-in specs detector.
*/ */

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Gvozdev - initial API and implementation * Andrew Gvozdev - initial API and implementation
* Liviu Ionescu - Bug 413678: trigger discovery after command line change
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.language.settings.providers; package org.eclipse.cdt.managedbuilder.language.settings.providers;
@ -419,6 +420,10 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
for (String languageId : languageIds) { for (String languageId : languageIds) {
try { try {
String command = resolveCommand(languageId); String command = resolveCommand(languageId);
if (command != null) {
envHashNew = 31*envHashNew + command.hashCode();
}
String[] cmdArray = CommandLineUtil.argumentsToArray(command); String[] cmdArray = CommandLineUtil.argumentsToArray(command);
if (cmdArray != null && cmdArray.length > 0) { if (cmdArray != null && cmdArray.length > 0) {
IPath location = new Path(cmdArray[0]); IPath location = new Path(cmdArray[0]);