mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 392416: make BuiltinSpecsDetectorTest.java run on non-windows
platforms (accept spaces in paths; increase timestamp by 1000ms) Change-Id: I0bf2cef0e31d655310446a6f5321dd938e4c69ad 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> Reviewed-on: https://git.eclipse.org/r/17179
This commit is contained in:
parent
775dc3fc68
commit
e72330fe5a
3 changed files with 37 additions and 24 deletions
|
@ -49,6 +49,7 @@ import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuilti
|
||||||
import org.eclipse.cdt.utils.envvar.StorableEnvironment;
|
import org.eclipse.cdt.utils.envvar.StorableEnvironment;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
@ -813,15 +814,18 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
* Test running a provider on compiler upgrades.
|
* Test running a provider on compiler upgrades.
|
||||||
*/
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_CompilerUpgrade() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_CompilerUpgrade() throws Exception {
|
||||||
|
// Create a folder for this test
|
||||||
|
IPath folder = ResourceHelper.createWorkspaceFolder(getName());
|
||||||
|
|
||||||
// Create test "compiler"
|
// Create test "compiler"
|
||||||
java.io.File compiler = new java.io.File("compiler");
|
java.io.File compiler = new java.io.File(folder.append("compiler").toOSString());
|
||||||
compiler.createNewFile();
|
compiler.createNewFile();
|
||||||
assertTrue(compiler.exists());
|
assertTrue(compiler.exists());
|
||||||
String compilerPath = compiler.getAbsolutePath();
|
String compilerPath = compiler.getAbsolutePath();
|
||||||
|
|
||||||
// Create provider
|
// Create provider
|
||||||
MockBuiltinSpecsDetectorWithRunCount provider = new MockBuiltinSpecsDetectorWithRunCount();
|
MockBuiltinSpecsDetectorWithRunCount provider = new MockBuiltinSpecsDetectorWithRunCount();
|
||||||
provider.setCommand(compilerPath + " arg1");
|
provider.setCommand('"' + compilerPath + '"' + " arg1");
|
||||||
// register environment listener on workspace
|
// register environment listener on workspace
|
||||||
provider.registerListener(null);
|
provider.registerListener(null);
|
||||||
waitForProviderToFinish();
|
waitForProviderToFinish();
|
||||||
|
@ -833,7 +837,12 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, provider.getExecutedCount());
|
assertEquals(1, provider.getExecutedCount());
|
||||||
|
|
||||||
// "Upgrade" the "compiler"
|
// "Upgrade" the "compiler"
|
||||||
compiler.setLastModified(compiler.lastModified() + 1);
|
long lastModified = compiler.lastModified();
|
||||||
|
// less than 1 sec might be truncated
|
||||||
|
compiler.setLastModified(lastModified + 1000);
|
||||||
|
long lastModifiedUpdated = compiler.lastModified();
|
||||||
|
assertTrue(lastModifiedUpdated != lastModified);
|
||||||
|
|
||||||
|
|
||||||
// Check that an event triggers rerun after upgrade
|
// Check that an event triggers rerun after upgrade
|
||||||
provider.handleEvent(null);
|
provider.handleEvent(null);
|
||||||
|
@ -853,19 +862,24 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a folder for this test
|
||||||
|
IPath folder = ResourceHelper.createWorkspaceFolder(getName());
|
||||||
|
|
||||||
// Create test "compiler"
|
// Create test "compiler"
|
||||||
java.io.File compiler = new java.io.File("compiler");
|
IPath compilerLocation = folder.append("compiler");
|
||||||
|
java.io.File compiler = new java.io.File(compilerLocation.toOSString());
|
||||||
compiler.createNewFile();
|
compiler.createNewFile();
|
||||||
assertTrue(compiler.exists());
|
assertTrue(compiler.exists());
|
||||||
// Create symbolic link to the test compiler
|
// Create symbolic link to the test compiler
|
||||||
ResourceHelper.createSymbolicLink(new Path("compilerLink"), new Path(compiler.getAbsolutePath()));
|
IPath compilerLinkLocation = folder.append("compilerLink");
|
||||||
java.io.File compilerLink = new java.io.File("compilerLink");
|
ResourceHelper.createSymbolicLink(compilerLinkLocation, compilerLocation);
|
||||||
|
java.io.File compilerLink = new java.io.File(compilerLinkLocation.toOSString());
|
||||||
assertTrue(compilerLink.exists());
|
assertTrue(compilerLink.exists());
|
||||||
String compilerLinkPath = compilerLink.getAbsolutePath();
|
String compilerLinkPath = compilerLink.getAbsolutePath();
|
||||||
|
|
||||||
// Create provider
|
// Create provider
|
||||||
MockBuiltinSpecsDetectorWithRunCount provider = new MockBuiltinSpecsDetectorWithRunCount();
|
MockBuiltinSpecsDetectorWithRunCount provider = new MockBuiltinSpecsDetectorWithRunCount();
|
||||||
provider.setCommand(compilerLinkPath + " arg1");
|
provider.setCommand('"' + compilerLinkPath + '"' + " arg1");
|
||||||
// register environment listener on workspace
|
// register environment listener on workspace
|
||||||
provider.registerListener(null);
|
provider.registerListener(null);
|
||||||
waitForProviderToFinish();
|
waitForProviderToFinish();
|
||||||
|
@ -876,8 +890,12 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
waitForProviderToFinish();
|
waitForProviderToFinish();
|
||||||
assertEquals(1, provider.getExecutedCount());
|
assertEquals(1, provider.getExecutedCount());
|
||||||
|
|
||||||
// "Upgrade" the "compiler"
|
// "Upgrade" the "compiler". Note that less than 1 sec might be truncated.
|
||||||
compiler.setLastModified(compiler.lastModified() + 1);
|
long lastModified = compiler.lastModified();
|
||||||
|
// less than 1 sec might be truncated
|
||||||
|
compiler.setLastModified(lastModified + 1000);
|
||||||
|
long lastModifiedUpdated = compiler.lastModified();
|
||||||
|
assertTrue(lastModifiedUpdated != lastModified);
|
||||||
|
|
||||||
// Check that an event triggers rerun after upgrade
|
// Check that an event triggers rerun after upgrade
|
||||||
provider.handleEvent(null);
|
provider.handleEvent(null);
|
||||||
|
@ -892,15 +910,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
* Test running a provider after changing the compiler command.
|
* Test running a provider after changing the compiler command.
|
||||||
*/
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_RerunOnCommandArgsChange() throws Exception {
|
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
|
// Create provider
|
||||||
MockBuiltinSpecsDetectorWithRunCount provider = new MockBuiltinSpecsDetectorWithRunCount();
|
MockBuiltinSpecsDetectorWithRunCount provider = new MockBuiltinSpecsDetectorWithRunCount();
|
||||||
provider.setCommand(compilerPath + " arg1");
|
provider.setCommand("compiler arg1");
|
||||||
// register environment listener on workspace
|
// register environment listener on workspace
|
||||||
provider.registerListener(null);
|
provider.registerListener(null);
|
||||||
waitForProviderToFinish();
|
waitForProviderToFinish();
|
||||||
|
@ -911,8 +923,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
waitForProviderToFinish();
|
waitForProviderToFinish();
|
||||||
assertEquals(1, provider.getExecutedCount());
|
assertEquals(1, provider.getExecutedCount());
|
||||||
|
|
||||||
// Change the compiler command
|
// Change the compiler command argument
|
||||||
provider.setCommand(compilerPath + " arg2");
|
provider.setCommand("compiler arg2");
|
||||||
|
|
||||||
// Check that an event triggers rerun after changing the compiler command
|
// Check that an event triggers rerun after changing the compiler command
|
||||||
provider.handleEvent(null);
|
provider.handleEvent(null);
|
||||||
|
|
|
@ -973,7 +973,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
parser.processLine("gcc "
|
parser.processLine("gcc "
|
||||||
+ "-I/path0 "
|
+ "-I/path0 "
|
||||||
+ "-I. "
|
+ "-I. "
|
||||||
+ file.getLocation().toOSString());
|
+ '"' + file.getLocation().toOSString() + '"');
|
||||||
parser.shutdown();
|
parser.shutdown();
|
||||||
|
|
||||||
// check entries
|
// check entries
|
||||||
|
@ -1004,7 +1004,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
parser.processLine("gcc "
|
parser.processLine("gcc "
|
||||||
+ "-I/path0 "
|
+ "-I/path0 "
|
||||||
+ "-I. "
|
+ "-I. "
|
||||||
+ file.getLocation().toOSString());
|
+ '"' + file.getLocation().toOSString() + '"');
|
||||||
parser.shutdown();
|
parser.shutdown();
|
||||||
|
|
||||||
// check entries
|
// check entries
|
||||||
|
@ -1772,9 +1772,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
// parse line
|
// parse line
|
||||||
parser.startup(cfgDescription, null);
|
parser.startup(cfgDescription, null);
|
||||||
parser.processLine("gcc "
|
parser.processLine("gcc "
|
||||||
+ " -I."
|
+ "-I. "
|
||||||
+ " -Iinclude"
|
+ "-Iinclude "
|
||||||
+ " " + file.getLocation().toOSString()
|
+ '"' + file.getLocation().toOSString() + '"'
|
||||||
);
|
);
|
||||||
parser.shutdown();
|
parser.shutdown();
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev - Initial API and implementation
|
* Andrew Gvozdev - Initial API and implementation
|
||||||
* James Blackburn (Broadcom Corp.)
|
* James Blackburn (Broadcom Corp.)
|
||||||
|
* Liviu Ionescu - bug 392416
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.testplugin;
|
package org.eclipse.cdt.core.testplugin;
|
||||||
|
|
||||||
|
@ -579,7 +580,7 @@ public class ResourceHelper {
|
||||||
throw new UnsupportedOperationException("Windows links .lnk are not supported.");
|
throw new UnsupportedOperationException("Windows links .lnk are not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String command = "ln -s " + realPath.toOSString() + ' ' + linkPath.toOSString();
|
String command[] = { "ln", "-s", realPath.toOSString(), linkPath.toOSString()};
|
||||||
Process process = Runtime.getRuntime().exec(command);
|
Process process = Runtime.getRuntime().exec(command);
|
||||||
|
|
||||||
// Wait for up to 2.5s...
|
// Wait for up to 2.5s...
|
||||||
|
|
Loading…
Add table
Reference in a new issue