mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 409651: MinGW language settings provider provides duplicate include paths
This commit is contained in:
parent
e8cb904f9c
commit
4ead47e948
2 changed files with 35 additions and 1 deletions
|
@ -401,6 +401,36 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
|||
assertEquals(1, entries.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test parsing of include directives included multiple times.
|
||||
*/
|
||||
public void testGCCBuiltinSpecsDetector_Includes_Duplicates() throws Exception {
|
||||
// Create model project and folders to test
|
||||
String projectName = getName();
|
||||
IProject project = ResourceHelper.createCDTProject(projectName);
|
||||
IPath tmpPath = ResourceHelper.createTemporaryFolder();
|
||||
ResourceHelper.createFolder(project, "/usr/include");
|
||||
String loc = tmpPath.toString();
|
||||
|
||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||
detector.startup(null, null);
|
||||
detector.startupForLanguage(null);
|
||||
|
||||
detector.processLine("#include <...> search starts here:");
|
||||
detector.processLine(" "+loc+"/usr/include");
|
||||
detector.processLine(" "+loc+"/usr/include");
|
||||
detector.processLine(" "+loc+"/usr/include/");
|
||||
detector.processLine(" "+loc+"/usr/include/../include");
|
||||
detector.processLine("End of search list.");
|
||||
detector.shutdownForLanguage();
|
||||
detector.shutdown();
|
||||
|
||||
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
|
||||
int index = 0;
|
||||
assertEquals(new CIncludePathEntry(loc+"/usr/include", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
|
||||
assertEquals(index, entries.size());
|
||||
}
|
||||
/**
|
||||
* Test parsing of include directives for Cygwin for global provider.
|
||||
*/
|
||||
|
|
|
@ -700,7 +700,11 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
|||
// Built-in specs detectors collect entries not per line but for the whole output
|
||||
// so collect them to save later when output finishes
|
||||
if (entries != null) {
|
||||
detectedSettingEntries.addAll(entries);
|
||||
for (ICLanguageSettingEntry entry : entries) {
|
||||
if (!detectedSettingEntries.contains(entry)) {
|
||||
detectedSettingEntries.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue