mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
bug 396411: JUnit failure: cdt.managedbuilder.core.tests.ManagedBuildCoreTests20.testScannerInfoInterface
This commit is contained in:
parent
963f1bf26e
commit
0a4170fed0
3 changed files with 49 additions and 32 deletions
|
@ -204,7 +204,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
/**
|
||||
* Convert path to OS specific representation
|
||||
*/
|
||||
private String toOSString(String path) {
|
||||
private String toOSLocation(String path) {
|
||||
File file = new File(path);
|
||||
try {
|
||||
path = file.getCanonicalPath();
|
||||
|
@ -213,7 +213,14 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert path to OS specific representation
|
||||
*/
|
||||
private String toOSString(String path) {
|
||||
return new Path(path).toOSString();
|
||||
}
|
||||
|
||||
/**
|
||||
* The purpose of this test is to exercise the build path info interface.
|
||||
* To get to that point, a new project/config has to be created in the test
|
||||
|
@ -240,24 +247,24 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
if (new Path("C:\\home\\tester/include").isAbsolute()) {
|
||||
// Windows
|
||||
expectedPaths = new String[] {
|
||||
toOSString("/usr/include"),
|
||||
toOSString("/opt/gnome/include"),
|
||||
toOSString("C:\\home\\tester/include"),
|
||||
toOSLocation("/usr/include"),
|
||||
toOSLocation("/opt/gnome/include"),
|
||||
toOSLocation("C:\\home\\tester/include"),
|
||||
// relative paths make 2 entries
|
||||
project.getLocation().append("includes").toOSString(),
|
||||
"includes", // FIXME this is incorrect, the original entry set via extension point is "../includes"
|
||||
buildCWD.append("../includes").toOSString(),
|
||||
toOSString("includes"),
|
||||
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
|
||||
};
|
||||
} else {
|
||||
// Unix
|
||||
expectedPaths = new String[] {
|
||||
toOSString("/usr/include"),
|
||||
toOSString("/opt/gnome/include"),
|
||||
toOSLocation("/usr/include"),
|
||||
toOSLocation("/opt/gnome/include"),
|
||||
buildCWD.append("C:\\home\\tester/include").toOSString(), // added on Unix being relative path
|
||||
toOSLocation("C:\\home\\tester/include"),
|
||||
// relative paths make 2 entries
|
||||
buildCWD.append("C:\\home\\tester/include").toOSString(),
|
||||
"C:\\home\\tester/include",
|
||||
project.getLocation().append("includes").toOSString(),
|
||||
"includes", // FIXME this is incorrect, the original entry set via extension point is "../includes"
|
||||
buildCWD.append("../includes").toOSString(),
|
||||
toOSString("includes"),
|
||||
"/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1841,11 +1841,10 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider
|
|||
// }
|
||||
|
||||
if(!buildPath.isAbsolute()){
|
||||
buildPath = project.getFullPath().append(buildPath);
|
||||
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
|
||||
result = buildPath.toString();
|
||||
result = mngr.generateVariableExpression("workspace_loc", result); //$NON-NLS-1$
|
||||
// build dir may not exist yet and non-existent paths will resolve to empty string by VariablesPlugin
|
||||
// so append relative part outside of expression, i.e. ${workspace_loc:/Project}/BuildDir
|
||||
result = mngr.generateVariableExpression("workspace_loc", project.getFullPath().toString()) + Path.SEPARATOR + buildPath.toString(); //$NON-NLS-1$
|
||||
} else {
|
||||
result = buildPath.toString();
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
|
|||
*/
|
||||
private static IPath getBuildCWD(ICConfigurationDescription cfgDescription) {
|
||||
IPath buildCWD = cfgDescription.getBuildSetting().getBuilderCWD();
|
||||
if (buildCWD==null) {
|
||||
if (buildCWD == null) {
|
||||
IProject project = cfgDescription.getProjectDescription().getProject();
|
||||
buildCWD = project.getLocation();
|
||||
} else {
|
||||
|
@ -178,7 +178,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
|
|||
* Resolve location to file system location in a configuration context.
|
||||
* Resolving includes replacing build/environment variables with values, making relative path absolute etc.
|
||||
*
|
||||
* @param location - location to resolve. If relative, it is taken to be rooted in build working directory.
|
||||
* @param location - location to resolve. If relative, it is taken to be rooted in project directory.
|
||||
* @param cfgDescription - the configuration context.
|
||||
* @return resolved file system location.
|
||||
*/
|
||||
|
@ -192,24 +192,35 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
|
|||
CCorePlugin.log(e);
|
||||
}
|
||||
// use OS file separators (i.e. '\' on Windows)
|
||||
if (java.io.File.separatorChar != '/') {
|
||||
location = location.replace('/', java.io.File.separatorChar);
|
||||
if (java.io.File.separatorChar != IPath.SEPARATOR) {
|
||||
location = location.replace(IPath.SEPARATOR, java.io.File.separatorChar);
|
||||
}
|
||||
|
||||
// note that we avoid using org.eclipse.core.runtime.Path for manipulations being careful
|
||||
// to preserve "../" segments and not let collapsing them which is not correct for symbolic links.
|
||||
Path locPath = new Path(location);
|
||||
if (locPath.isAbsolute() && locPath.getDevice()==null) {
|
||||
IPath locPath = new Path(location);
|
||||
if (locPath.isAbsolute() && locPath.getDevice() == null) {
|
||||
IPath buildCWD = getBuildCWD(cfgDescription);
|
||||
// prepend device (C:) for Windows
|
||||
IPath buildCWD = getBuildCWD(cfgDescription);
|
||||
String device = buildCWD.getDevice();
|
||||
if (device!=null)
|
||||
if (device != null) {
|
||||
// note that we avoid using org.eclipse.core.runtime.Path for manipulations being careful
|
||||
// to preserve "../" segments and not let collapsing them which is not correct for symbolic links.
|
||||
location = device + location;
|
||||
}
|
||||
}
|
||||
|
||||
if (!locPath.isAbsolute()) {
|
||||
// consider relative path to be from build working directory
|
||||
IPath buildCWD = getBuildCWD(cfgDescription);
|
||||
location = buildCWD.toOSString() + locPath;
|
||||
ICProjectDescription projectDescription = cfgDescription.getProjectDescription();
|
||||
if (projectDescription != null) {
|
||||
IProject project = projectDescription.getProject();
|
||||
if (project != null) {
|
||||
IPath projectLocation = project.getLocation();
|
||||
if (projectLocation != null) {
|
||||
// again, we avoid using org.eclipse.core.runtime.Path for manipulations being careful
|
||||
// to preserve "../" segments and not let collapsing them which is not correct for symbolic links.
|
||||
location = projectLocation.addTrailingSeparator().toOSString() + locPath.toOSString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
@ -222,7 +233,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
|
|||
* @param cfgDescription - configuration description for resolving entries.
|
||||
* @return array of the locations.
|
||||
*/
|
||||
private String[] convertToLocations(LinkedHashSet<ICLanguageSettingEntry> entriesPath, ICConfigurationDescription cfgDescription){
|
||||
private String[] convertToLocations(LinkedHashSet<ICLanguageSettingEntry> entriesPath, ICConfigurationDescription cfgDescription) {
|
||||
List<String> locations = new ArrayList<String>(entriesPath.size());
|
||||
for (ICLanguageSettingEntry entry : entriesPath) {
|
||||
ACPathEntry entryPath = (ACPathEntry)entry;
|
||||
|
@ -261,7 +272,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
|
|||
IPath unresolvedPath = entryPath.getLocation();
|
||||
if (!unresolvedPath.isAbsolute()) {
|
||||
IPath expandedPath = expandVariables(unresolvedPath, cfgDescription);
|
||||
if (!expandedPath.isAbsolute()) {
|
||||
if (!expandedPath.isEmpty() && !expandedPath.isAbsolute()) {
|
||||
locations.add(expandedPath.toOSString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue