mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 396411: JUnit failure: cdt.managedbuilder.core.tests.ManagedBuildCoreTests20.testScannerInfoInterface
This commit is contained in:
parent
ca6f6aa2aa
commit
cce302595e
8 changed files with 66 additions and 34 deletions
|
@ -122,22 +122,22 @@ public class BuildSystemTestHelper {
|
|||
return project;
|
||||
}
|
||||
|
||||
static public void checkDiff(Object[] arr1, Object[] arr2){
|
||||
LinkedHashSet<? extends Object> set1 = new LinkedHashSet<Object>(Arrays.asList(arr1));
|
||||
LinkedHashSet<? extends Object> set2 = new LinkedHashSet<Object>(Arrays.asList(arr2));
|
||||
static public void checkDiff(Object[] expected, Object[] actual){
|
||||
LinkedHashSet<? extends Object> set1 = new LinkedHashSet<Object>(Arrays.asList(expected));
|
||||
LinkedHashSet<? extends Object> set2 = new LinkedHashSet<Object>(Arrays.asList(actual));
|
||||
LinkedHashSet<? extends Object> set1Copy = new LinkedHashSet<Object>(set1);
|
||||
set1.removeAll(set2);
|
||||
set2.removeAll(set1Copy);
|
||||
|
||||
String set1String = collectionToString(set1);
|
||||
String set2String = collectionToString(set2);
|
||||
String diffMsg = "array1 entries: " + set1String + ",\n array2 entries: " + set2String + "\n";
|
||||
Assert.assertEquals("arrays have different size\n" + diffMsg, arr1.length, arr2.length);
|
||||
Assert.assertEquals("arrays have different contents\n" + diffMsg, 0, set1.size());
|
||||
Assert.assertEquals("arrays have different contents\n" + diffMsg, 0, set2.size());
|
||||
String diffMsg = "expected entries: " + set1String + ",\n actual entries: " + set2String + "\n";
|
||||
Assert.assertEquals("arrays have different size\n" + diffMsg, expected.length, actual.length);
|
||||
Assert.assertTrue("arrays have different contents\n" + diffMsg, set1.size() == 0);
|
||||
Assert.assertTrue("arrays have different contents\n" + diffMsg, set2.size() == 0);
|
||||
|
||||
if(!Arrays.equals(arr1, arr2)){
|
||||
Assert.fail("different element order, dumping..\n array1 entries: " + arrayToString(arr1) + "\n array2 entries: " + arrayToString(arr2) + "\n");
|
||||
if(!Arrays.equals(expected, actual)){
|
||||
Assert.fail("different element order, dumping..\n expected entries: " + arrayToString(expected) + "\n actual entries: " + arrayToString(actual) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -22,6 +24,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
|
@ -48,11 +51,9 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/*
|
||||
|
@ -198,6 +199,19 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert path to OS specific representation
|
||||
*/
|
||||
private String toOSString(String path) {
|
||||
File file = new File(path);
|
||||
try {
|
||||
path = file.getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -218,18 +232,15 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
}
|
||||
|
||||
//These are the expected path settings
|
||||
final String[] expectedPaths = new String[5];
|
||||
|
||||
// This first path is a built-in, so it will not be manipulated by build manager
|
||||
expectedPaths[0] = (new Path("/usr/include")).toOSString();
|
||||
expectedPaths[1] = (new Path("/opt/gnome/include")).toOSString();
|
||||
IPath path = new Path("C:\\home\\tester/include");
|
||||
if(path.isAbsolute()) // for win32 path is treated as absolute
|
||||
expectedPaths[2] = path.toOSString();
|
||||
else // for Linux path is relative
|
||||
expectedPaths[2] = project.getLocation().append("Sub Config").append(path).toOSString();
|
||||
expectedPaths[3] = project.getLocation().append( "includes" ).toOSString();
|
||||
expectedPaths[4] = (new Path("/usr/gnu/include")).toOSString();
|
||||
final String[] expectedPaths = {
|
||||
toOSString("/usr/include"),
|
||||
toOSString("/opt/gnome/include"),
|
||||
toOSString("C:\\home\\tester/include"),
|
||||
// relative path makes 2 entries
|
||||
project.getLocation().append("includes").toOSString(),
|
||||
"includes",
|
||||
"/usr/gnu/include", // This one set to ICSettingEntry.RESOLVED
|
||||
};
|
||||
|
||||
// Create a new managed project based on the sub project type
|
||||
IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub");
|
||||
|
@ -281,6 +292,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
|
|||
// Find the first IScannerInfoProvider that supplies build info for the project
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||
assertNotNull(provider);
|
||||
assertTrue(provider instanceof LanguageSettingsScannerInfoProvider);
|
||||
|
||||
// Now subscribe (note that the method will be called after a change
|
||||
provider.subscribe(project, new IScannerInfoChangeListener () {
|
||||
|
|
|
@ -56,11 +56,16 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
|||
for (ICLanguageSetting langSetting : languageSettings) {
|
||||
if (langSetting != null) {
|
||||
String id = langSetting.getLanguageId();
|
||||
if (id != null && id.equals(languageId)) {
|
||||
if (id == languageId || (id != null && id.equals(languageId))) {
|
||||
int kindsBits = langSetting.getSupportedEntryKinds();
|
||||
for (int kind=1; kind <= kindsBits; kind <<= 1) {
|
||||
if ((kindsBits & kind) != 0) {
|
||||
list.addAll(langSetting.getSettingEntriesList(kind));
|
||||
List<ICLanguageSettingEntry> additions = langSetting.getSettingEntriesList(kind);
|
||||
for (ICLanguageSettingEntry entry : additions) {
|
||||
if (! list.contains(entry)) {
|
||||
list.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ public class LanguageSettingsManager {
|
|||
* commonly come from the input type(s).
|
||||
*
|
||||
* @param rcDescription - resource description
|
||||
* @return list of language IDs for the resource.
|
||||
* @return list of language IDs for the resource. The list can contain {@code null} ID.
|
||||
* Never returns {@code null} but empty list if no languages can be found.
|
||||
*
|
||||
*/
|
||||
|
@ -226,9 +226,9 @@ public class LanguageSettingsManager {
|
|||
List<String> languageIds = new ArrayList<String>();
|
||||
if (languageSettings != null) {
|
||||
for (ICLanguageSetting languageSetting : languageSettings) {
|
||||
if (languageSetting!=null) {
|
||||
if (languageSetting != null) {
|
||||
String languageId = languageSetting.getLanguageId();
|
||||
if (languageId != null && !languageId.isEmpty()) {
|
||||
if (! languageIds.contains(languageId)) {
|
||||
languageIds.add(languageId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ public interface ICLanguageSetting extends ICSettingObject {
|
|||
|
||||
// String[] getHeaderExtensions();
|
||||
|
||||
/**
|
||||
* @return language id. Note that that id can be {@code null}.
|
||||
*/
|
||||
String getLanguageId();
|
||||
|
||||
// ICLanguageSettingEntry[] getSettingEntries();
|
||||
|
|
|
@ -2051,8 +2051,10 @@ public class PathEntryTranslator {
|
|||
IProject project = cfgDescription.getProjectDescription().getProject();
|
||||
if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project)) {
|
||||
IResource rc = findResourceInWorkspace(project, rcData.getPath());
|
||||
for (CLanguageData lData : lDatas) {
|
||||
list.addAll(LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, lData.getLanguageId(), kind));
|
||||
if (rc != null) {
|
||||
for (CLanguageData lData : lDatas) {
|
||||
list.addAll(LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, lData.getLanguageId(), kind));
|
||||
}
|
||||
}
|
||||
return list.size()>0;
|
||||
|
||||
|
|
|
@ -159,7 +159,12 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
|
|||
// still, MBS does that and we need to handle that
|
||||
String buildPathString = buildCWD.toString();
|
||||
buildPathString = mngr.resolveValue(buildPathString, "", null, cfgDescription); //$NON-NLS-1$
|
||||
buildCWD = new Path(buildPathString);
|
||||
if (!buildPathString.isEmpty()) {
|
||||
buildCWD = new Path(buildPathString);
|
||||
} else {
|
||||
IProject project = cfgDescription.getProjectDescription().getProject();
|
||||
buildCWD = project.getLocation();
|
||||
}
|
||||
} catch (CdtVariableException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
|
|
@ -968,6 +968,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
|||
currentLanguageId = null;
|
||||
|
||||
List<String> languageIds = LanguageSettingsManager.getLanguages(rcDes);
|
||||
// Not sure what to do with null language ID, ignoring for now
|
||||
languageIds.remove(null);
|
||||
Collections.sort(languageIds);
|
||||
for (String langId : languageIds) {
|
||||
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
||||
|
@ -1124,9 +1126,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
|||
if (page.isForFile()) {
|
||||
List<String> languageIds = LanguageSettingsManager.getLanguages(getResDesc());
|
||||
for (String langId : languageIds) {
|
||||
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
||||
if (language != null)
|
||||
return true;
|
||||
if (langId != null) {
|
||||
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
||||
if (language != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue