From 93f33210c74039f56bcf248edc97af0ed4166ff9 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 17 Jul 2007 15:00:53 +0000 Subject: [PATCH] Enabled scanner discovery tests for the per file scanner discovery. --- .../.settings/org.eclipse.jdt.core.prefs | 56 +++++ .../.settings/org.eclipse.pde.prefs | 15 ++ .../META-INF/MANIFEST.MF | 6 +- .../builder/tests/CDataProviderTests.java | 3 - .../ScannerConfigConsoleParserTests.java | 211 ------------------ .../builder/tests/StandardBuildTests.java | 13 +- .../core/tests/AutomatedIntegrationSuite.java | 5 +- .../BaseBOPConsoleParserTests.java | 117 ++++++++++ .../GCCPerFileBOPConsoleParserTests.java | 73 ++++++ .../GCCScannerInfoConsoleParserTests.java | 95 ++++++++ .../ScannerConfigDiscoveryTests.java | 7 +- .../ScannerDiscoveryTests.java | 28 +++ .../TestScannerInfoCollector.java | 59 +++++ 13 files changed, 459 insertions(+), 229 deletions(-) create mode 100644 build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs create mode 100644 build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.pde.prefs delete mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigConsoleParserTests.java create mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java create mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java create mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java rename build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/{builder/tests => scannerdiscovery}/ScannerConfigDiscoveryTests.java (94%) create mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java create mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/TestScannerInfoCollector.java diff --git a/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..cb4f1dff2d6 --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,56 @@ +#Tue Jul 17 13:02:09 CEST 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=ignore +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning diff --git a/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.pde.prefs b/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.pde.prefs new file mode 100644 index 00000000000..b74a406b6c0 --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/.settings/org.eclipse.pde.prefs @@ -0,0 +1,15 @@ +#Tue Jul 17 12:53:48 CEST 2007 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.deprecated=1 +compilers.p.missing-packages=2 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.use-project=true +eclipse.preferences.version=1 diff --git a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF index 00becff334b..a992ef374ea 100644 --- a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF @@ -5,13 +5,13 @@ Bundle-SymbolicName: org.eclipse.cdt.make.core.tests Bundle-Version: 4.0.0.qualifier Bundle-ClassPath: makecoretests.jar Bundle-Activator: org.eclipse.cdt.make.core.tests.MakeTestsPlugin -Bundle-Localization: plugin Export-Package: org.eclipse.cdt.make.builder.tests, org.eclipse.cdt.make.core.tests Require-Bundle: org.eclipse.core.runtime, org.junit, org.eclipse.cdt.make.core, org.eclipse.cdt.core, - org.eclipse.core.resources -Eclipse-AutoStart: true + org.eclipse.core.resources, + org.eclipse.cdt.core.tests +Eclipse-LazyStart: true Bundle-Vendor: Eclipse.org diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java index 3621ac64192..5fe246c8886 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java @@ -16,11 +16,8 @@ import junit.framework.TestSuite; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.make.core.MakeCorePlugin; -import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder; -import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigConsoleParserTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigConsoleParserTests.java deleted file mode 100644 index 9113217f15c..00000000000 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigConsoleParserTests.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - * Anton Leherbauer (Wind River Systems) - *******************************************************************************/ -package org.eclipse.cdt.make.builder.tests; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; - -import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; -import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; -import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; -import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser; - -/** - * Scanner configuration console parser tests - * - * @author vhirsl - */ -public class ScannerConfigConsoleParserTests extends TestCase { - - private IScannerInfoConsoleParser clParser; - - public ScannerConfigConsoleParserTests(String name) { - super(name); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - - clParser = new GCCScannerInfoConsoleParser(); - } - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - - protected void tearDown() throws Exception { - super.tearDown(); - - clParser.shutdown(); - clParser = null; - } - - /* - * Tests GCCScannerInfoConsoleParser. Utility object not provided. - * Only tests parsing of the imput (make build output) - */ - public void testParsingIncludePaths() { - IScannerInfoCollector collector = new IScannerInfoCollector() { - private List sumIncludes = new ArrayList(); - public void contributeToScannerConfig(Object resource, Map scannerInfo) { - sumIncludes.addAll((List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS)); - } - public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { - if (type.equals(ScannerInfoTypes.INCLUDE_PATHS)) { - return sumIncludes; - } - return new ArrayList(); - } - }; - // initialize it with the utility - clParser.startup(null, null, collector, null); - - clParser.processLine("gcc -I /dir/include -I C:\\dir\\include -ID:/dir/include -c test.c"); // absolute paths //$NON-NLS-1$ - clParser.processLine("gcc -I -I /dir2/include -c test.c"); // empty -I //$NON-NLS-1$ - clParser.processLine("gcc -I../back_dir/include -I./cur_dir/include -c test.c"); // relative paths //$NON-NLS-1$ - clParser.processLine("gcc '-I /squoted/dir1' -I '/squoted/dir2' -I'/squoted/dir3' -c test.c"); // single quote dirs //$NON-NLS-1$ - clParser.processLine("gcc \"-I /dquoted/dir1\" -I \"/dquoted/dir2\" -I\"/dquoted/dir3\" -c test.c"); // double quote dirs //$NON-NLS-1$ - clParser.processLine("gcc '-I /with spaces 1' -I'/with spaces 2' -c test.c"); // dirs with spaces 1,2 //$NON-NLS-1$ - clParser.processLine("gcc \"-I /with spaces 3\" -I \"/with spaces 4\" -c test.c"); // dirs with spaces 3,4 //$NON-NLS-1$ - clParser.processLine("gcc -I /with\\ spaces\\ 5 -c test.c"); // dirs with spaces 5 //$NON-NLS-1$ - clParser.processLine("gcc -I '\\\\server1\\include' '-I\\\\server2\\include' -I \"\\\\server3\\include\" -c test.c"); // UNC paths //$NON-NLS-1$ - clParser.processLine("gcc -I //server4/include -I '//server5/include' '-I//server6/include' -c test.c"); // UNC paths //$NON-NLS-1$ - clParser.processLine("gcc -I \\"); //$NON-NLS-1$ - clParser.processLine("/multiline\\"); //$NON-NLS-1$ - clParser.processLine("/dir -c test.c"); // multiline //$NON-NLS-1$ - - List sumIncludes = collector.getCollectedScannerInfo(null, ScannerInfoTypes.INCLUDE_PATHS); - assertTrue(sumIncludes.contains("/dir/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("C:\\dir\\include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("D:/dir/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/dir2/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("../back_dir/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("./cur_dir/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/squoted/dir1")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/squoted/dir2")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/squoted/dir3")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/dquoted/dir1")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/dquoted/dir2")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/dquoted/dir3")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/with spaces 1")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/with spaces 2")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/with spaces 3")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/with spaces 4")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/with spaces 5")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("\\\\server1\\include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("\\\\server2\\include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("\\\\server3\\include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("//server4/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("//server5/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("//server6/include")); //$NON-NLS-1$ - assertTrue(sumIncludes.contains("/multiline/dir")); //$NON-NLS-1$ - assertTrue(sumIncludes.size() == 24); - } - - public void testParsingSymbolDefinitions() { - IScannerInfoCollector collector = new IScannerInfoCollector() { - private List sumSymbols = new ArrayList(); - public void contributeToScannerConfig(Object resource, Map scannerInfo) { - sumSymbols.addAll((List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS)); - } - public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { - if (type.equals(ScannerInfoTypes.SYMBOL_DEFINITIONS)) { - return sumSymbols; - } - return new ArrayList(); - } - }; - // initialize it with the utility - clParser.startup(null, null, collector, null); - - clParser.processLine("gcc -DMACRO1 -D MACRO2=value2 -c test.c"); // simple definitions //$NON-NLS-1$ - clParser.processLine("gcc -D -DMACRO3 -c test.c"); // empty -D //$NON-NLS-1$ - clParser.processLine("gcc -D MACRO4='value4' -D 'MACRO5=value5' '-D MACRO6 = value6' -c test.c"); // single quotes //$NON-NLS-1$ - clParser.processLine("gcc -D'MACRO7=\"value 7\"' -D MACRO8='\"value 8\"' -c test.c"); // single quotes //$NON-NLS-1$ - clParser.processLine("gcc -DMACRO9=\"value9\" -D \"MACRO10=value10\" \"-D MACRO11 = value11\" -c test.c"); // double quotes //$NON-NLS-1$ - clParser.processLine("gcc -D\"MACRO12=\\\"value 12\\\"\" -D MACRO13=\"\\\"value 13\\\"\" -c test.c"); // single quotes //$NON-NLS-1$ - clParser.processLine("gcc -D \\"); //$NON-NLS-1$ - clParser.processLine("MULTILINE=TRUE \\"); //$NON-NLS-1$ - clParser.processLine("-c test.c"); // multiline //$NON-NLS-1$ - clParser.processLine("gcc -D 'SUM(x, y) = (x) + (y)' -c test.c"); // more complex macro definition //$NON-NLS-1$ - - List sumSymbols = collector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); - assertTrue(sumSymbols.contains("MACRO1")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO2=value2")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO3")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO4=value4")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO5=value5")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO6 = value6")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO7=\"value 7\"")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO8=\"value 8\"")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO9=value9")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO10=value10")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO11 = value11")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO12=\"value 12\"")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MACRO13=\"value 13\"")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("MULTILINE=TRUE")); //$NON-NLS-1$ - assertTrue(sumSymbols.contains("SUM(x, y) = (x) + (y)")); //$NON-NLS-1$ - assertTrue(sumSymbols.size() == 15); - } - - public void testParsingSymbolDefinitions_bug80271() { - IScannerInfoCollector collector = new IScannerInfoCollector() { - private List sumSymbols = new ArrayList(); - public void contributeToScannerConfig(Object resource, Map scannerInfo) { - sumSymbols.addAll((List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS)); - } - public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { - if (type.equals(ScannerInfoTypes.SYMBOL_DEFINITIONS)) { - return sumSymbols; - } - return new ArrayList(); - } - }; - // initialize it with the utility - clParser.startup(null, null, collector, null); - - clParser.processLine("gcc -DMACRO1 -I ..\\inc -c ..\\source\\source.c"); // PR 80271 //$NON-NLS-1$ - - List sumSymbols = collector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); - assertTrue(sumSymbols.contains("MACRO1")); //$NON-NLS-1$ - assertTrue(sumSymbols.size() == 1); - } - - public void testParsingUnbalancedDoubleQuote_Bug186065() throws Exception { - IScannerInfoCollector collector = new IScannerInfoCollector() { - private List sumSymbols = new ArrayList(); - public void contributeToScannerConfig(Object resource, Map scannerInfo) { - sumSymbols.addAll((List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS)); - } - public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { - if (type.equals(ScannerInfoTypes.SYMBOL_DEFINITIONS)) { - return sumSymbols; - } - return new ArrayList(); - } - }; - // initialize it with the utility - clParser.startup(null, null, collector, null); - - clParser.processLine("../src/bug186065.cc:8: error: missing terminating \" character"); // PR 80271 //$NON-NLS-1$ - clParser.processLine("gcc -DBUG186065_IS_FIXED"); //$NON-NLS-1$ - - List sumSymbols = collector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); - assertTrue(sumSymbols.contains("BUG186065_IS_FIXED")); //$NON-NLS-1$ - assertTrue(sumSymbols.size() == 1); - } -} diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java index 6b54f66fa59..915aeb253ca 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java @@ -8,6 +8,7 @@ package org.eclipse.cdt.make.builder.tests; * * Contributors: * QNX Software Systems - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ import junit.framework.Test; @@ -18,6 +19,7 @@ import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.make.core.IMakeBuilderInfo; +import org.eclipse.cdt.make.core.IMakeCommonBuildInfo; import org.eclipse.cdt.make.core.MakeBuilder; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeProjectNature; @@ -54,10 +56,7 @@ public class StandardBuildTests extends TestCase { suite.addTest(new StandardBuildTests("testProjectSettings")); suite.addTest(new StandardBuildTests("testProjectConversion")); suite.addTest(new StandardBuildTests("testProjectCleanup")); - - suite.addTestSuite(ScannerConfigConsoleParserTests.class); - suite.addTestSuite(ScannerConfigDiscoveryTests.class); - + return suite; } @@ -241,9 +240,9 @@ public class StandardBuildTests extends TestCase { IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID); builderInfo.setStopOnError(ON); builderInfo.setUseDefaultBuildCmd(OFF); - builderInfo.setBuildCommand(new Path(OVR_BUILD_COMMAND)); - builderInfo.setBuildArguments(OVR_BUILD_ARGS); - builderInfo.setBuildLocation(new Path(OVR_BUILD_LOCATION)); + builderInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, OVR_BUILD_COMMAND); + builderInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, OVR_BUILD_ARGS); + builderInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, OVR_BUILD_LOCATION); try { project.close(new NullProgressMonitor()); } catch (CoreException e) { diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java index 7a2d37a2e68..56eab3a818a 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 QNX Software Systems and others. + * Copyright (c) 2004, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.make.core.tests; @@ -14,6 +15,7 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.cdt.make.builder.tests.StandardBuildTests; +import org.eclipse.cdt.make.scannerdiscovery.ScannerDiscoveryTests; public class AutomatedIntegrationSuite extends TestSuite { @@ -36,6 +38,7 @@ public class AutomatedIntegrationSuite extends TestSuite { final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite(); suite.addTest(StandardBuildTests.suite()); + suite.addTest(ScannerDiscoveryTests.suite()); return suite; } diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java new file mode 100644 index 00000000000..2927382796d --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) + * Markus Schorn (Wind River Systems) + *******************************************************************************/ +package org.eclipse.cdt.make.scannerdiscovery; + +import java.util.List; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; +import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; + +/** + * Scanner configuration console parser tests + * + * @author vhirsl + */ +public abstract class BaseBOPConsoleParserTests extends BaseTestCase { + + public static TestSuite suite() { + return suite(BaseBOPConsoleParserTests.class); + } + + protected IScannerInfoConsoleParser fOutputParser; + protected IScannerInfoCollector fCollector; + + public BaseBOPConsoleParserTests(String name) { + super(name); + } + + protected void setUp() throws Exception { + super.setUp(); + fCollector= new TestScannerInfoCollector(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + + public void testParsingSymbolDefinitions() { + fOutputParser.processLine("gcc -DMACRO1 -D MACRO2=value2 -c test.c"); // simple definitions //$NON-NLS-1$ + fOutputParser.processLine("gcc -D -DMACRO3 -c test.c"); // empty -D //$NON-NLS-1$ + fOutputParser.processLine("gcc -D MACRO4='value4' -D 'MACRO5=value5' '-D MACRO6 = value6' -c test.c"); // single quotes //$NON-NLS-1$ + fOutputParser.processLine("gcc -D'MACRO7=\"value 7\"' -D MACRO8='\"value 8\"' -c test.c"); // single quotes //$NON-NLS-1$ + fOutputParser.processLine("gcc -DMACRO9=\"value9\" -D \"MACRO10=value10\" \"-D MACRO11 = value11\" -c test.c"); // double quotes //$NON-NLS-1$ + fOutputParser.processLine("gcc -D\"MACRO12=\\\"value 12\\\"\" -D MACRO13=\"\\\"value 13\\\"\" -c test.c"); // single quotes //$NON-NLS-1$ + fOutputParser.processLine("gcc -D \\"); //$NON-NLS-1$ + fOutputParser.processLine("MULTILINE=TRUE \\"); //$NON-NLS-1$ + fOutputParser.processLine("-c test.c"); // multiline //$NON-NLS-1$ + fOutputParser.processLine("gcc -D 'SUM(x, y) = (x) + (y)' -c test.c"); // more complex macro definition //$NON-NLS-1$ + + List sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); + assertTrue(sumSymbols.contains("MACRO1")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO2=value2")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO3")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO4=value4")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO5=value5")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO6 = value6")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO7=\"value 7\"")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO8=\"value 8\"")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO9=value9")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO10=value10")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO11 = value11")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO12=\"value 12\"")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MACRO13=\"value 13\"")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("MULTILINE=TRUE")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("SUM(x, y) = (x) + (y)")); //$NON-NLS-1$ + assertTrue(sumSymbols.size() == 15); + } + + public void testParsingSymbolDefinitions_bug80271() { + fOutputParser.processLine("gcc -DMACRO1 -I ..\\inc -c ..\\source\\source.c"); // PR 80271 //$NON-NLS-1$ + + List sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); + assertTrue(sumSymbols.contains("MACRO1")); //$NON-NLS-1$ + assertTrue(sumSymbols.size() == 1); + } + + public void testParsingUnbalancedDoubleQuote_Bug186065() throws Exception { + fOutputParser.processLine("../src/bug186065.cc:8: error: missing terminating \" character"); // PR 80271 //$NON-NLS-1$ + fOutputParser.processLine("gcc -DBUG186065_IS_FIXED"); //$NON-NLS-1$ + + List sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); + assertTrue(sumSymbols.contains("BUG186065_IS_FIXED")); //$NON-NLS-1$ + assertTrue(sumSymbols.size() == 1); + } + + public void _testCompilerCommand_bug194394() throws Exception { + fOutputParser.processLine("/usr/bin/gcc -DA"); //$NON-NLS-1$ + fOutputParser.processLine("/usr/gcc-installs/gcc -DB"); //$NON-NLS-1$ + fOutputParser.processLine("/usr/gcc/gcc -DC"); //$NON-NLS-1$ + fOutputParser.processLine("/usr/gcc.exe -DD"); //$NON-NLS-1$ + fOutputParser.processLine("/usr/gcc-tool-x -DE"); //$NON-NLS-1$ + fOutputParser.processLine("/usr/gcc/something_else -DF"); //$NON-NLS-1$ + + List sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); + assertTrue(sumSymbols.contains("A")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("B")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("C")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("D")); //$NON-NLS-1$ + assertTrue(sumSymbols.contains("E")); //$NON-NLS-1$ + assertFalse(sumSymbols.contains("F")); //$NON-NLS-1$ + assertTrue(sumSymbols.size() == 5); + } +} diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java new file mode 100644 index 00000000000..a884fb037db --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.scannerdiscovery; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.IMarkerGenerator; +import org.eclipse.cdt.core.ProblemMarkerInfo; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileBOPConsoleParser; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; + +public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests { + private final static IMarkerGenerator MARKER_GENERATOR= new IMarkerGenerator() { + public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) { + } + public void addMarker(ProblemMarkerInfo problemMarkerInfo) { + } + }; + + public static TestSuite suite() { + return suite(GCCPerFileBOPConsoleParserTests.class); + } + + private ICProject fCProject; + + public GCCPerFileBOPConsoleParserTests(String name) { + super(name); + } + + protected void setUp() throws Exception { + super.setUp(); + fCProject= CProjectHelper.createCCProject("perfilescdtest", null); + fOutputParser= new GCCPerFileBOPConsoleParser(); + final IProject project = fCProject.getProject(); + fOutputParser.startup(project, project.getLocation(), fCollector, MARKER_GENERATOR); + } + + protected void tearDown() throws Exception { + super.tearDown(); + if (fOutputParser != null) { + fOutputParser.shutdown(); + } + if (fCProject != null) { + CProjectHelper.delete(fCProject); + } + } + + public void testParsingSymbolDefinitions() {} + public void _testParsingSymbolDefinitions() { + super.testParsingSymbolDefinitions(); + } + + public void testParsingSymbolDefinitions_bug80271() {} + public void _testParsingSymbolDefinitions_bug80271() { + super.testParsingSymbolDefinitions_bug80271(); + } + + public void testParsingUnbalancedDoubleQuote_Bug186065() {} + public void _testParsingUnbalancedDoubleQuote_Bug186065() throws Exception { + super.testParsingUnbalancedDoubleQuote_Bug186065(); + } +} diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java new file mode 100644 index 00000000000..3c029772b01 --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) + * Markus Schorn (Wind River Systems) + *******************************************************************************/ +package org.eclipse.cdt.make.scannerdiscovery; + +import java.util.List; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; +import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser; + +/** + * Scanner configuration console parser tests + * + * @author vhirsl + */ +public class GCCScannerInfoConsoleParserTests extends BaseBOPConsoleParserTests { + + public static TestSuite suite() { + return suite(GCCScannerInfoConsoleParserTests.class); + } + + public GCCScannerInfoConsoleParserTests(String name) { + super(name); + } + + protected void setUp() throws Exception { + super.setUp(); + fOutputParser= new GCCScannerInfoConsoleParser(); + fOutputParser.startup(null, null, fCollector, null); + } + + protected void tearDown() throws Exception { + super.tearDown(); + fOutputParser.shutdown(); + } + + /* + * Tests GCCScannerInfoConsoleParser. Utility object not provided. + * Only tests parsing of the input (make build output) + */ + public void testParsingIncludePaths() { + fOutputParser.processLine("gcc -I /dir/include -I c:\\dir\\include -ID:/dir/include -c test.c"); // absolute paths //$NON-NLS-1$ + fOutputParser.processLine("gcc -I -I /dir2/include -c test.c"); // empty -I //$NON-NLS-1$ + fOutputParser.processLine("gcc -I../back_dir/include -I./cur_dir/include -c test.c"); // relative paths //$NON-NLS-1$ + fOutputParser.processLine("gcc '-I /squoted/dir1' -I '/squoted/dir2' -I'/squoted/dir3' -c test.c"); // single quote dirs //$NON-NLS-1$ + fOutputParser.processLine("gcc \"-I /dquoted/dir1\" -I \"/dquoted/dir2\" -I\"/dquoted/dir3\" -c test.c"); // double quote dirs //$NON-NLS-1$ + fOutputParser.processLine("gcc '-I /with spaces 1' -I'/with spaces 2' -c test.c"); // dirs with spaces 1,2 //$NON-NLS-1$ + fOutputParser.processLine("gcc \"-I /with spaces 3\" -I \"/with spaces 4\" -c test.c"); // dirs with spaces 3,4 //$NON-NLS-1$ + fOutputParser.processLine("gcc -I /with\\ spaces\\ 5 -c test.c"); // dirs with spaces 5 //$NON-NLS-1$ + fOutputParser.processLine("gcc -I '\\\\server1\\include' '-I\\\\server2\\include' -I \"\\\\server3\\include\" -c test.c"); // UNC paths //$NON-NLS-1$ + fOutputParser.processLine("gcc -I //server4/include -I '//server5/include' '-I//server6/include' -c test.c"); // UNC paths //$NON-NLS-1$ + fOutputParser.processLine("gcc -I \\"); //$NON-NLS-1$ + fOutputParser.processLine("/multiline\\"); //$NON-NLS-1$ + fOutputParser.processLine("/dir -c test.c"); // multiline //$NON-NLS-1$ + + List sumIncludes = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.INCLUDE_PATHS); + assertTrue(sumIncludes.contains("/dir/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("c:\\dir\\include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("D:/dir/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/dir2/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("../back_dir/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("./cur_dir/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/squoted/dir1")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/squoted/dir2")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/squoted/dir3")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/dquoted/dir1")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/dquoted/dir2")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/dquoted/dir3")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/with spaces 1")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/with spaces 2")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/with spaces 3")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/with spaces 4")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/with spaces 5")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("\\\\server1\\include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("\\\\server2\\include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("\\\\server3\\include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("//server4/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("//server5/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("//server6/include")); //$NON-NLS-1$ + assertTrue(sumIncludes.contains("/multiline/dir")); //$NON-NLS-1$ + assertTrue(sumIncludes.size() == 24); + } + +} diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigDiscoveryTests.java similarity index 94% rename from build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java rename to build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigDiscoveryTests.java index 3bcdee1232f..e25d1e67858 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigDiscoveryTests.java @@ -8,16 +8,15 @@ * Contributors: * IBM - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.make.builder.tests; +package org.eclipse.cdt.make.scannerdiscovery; import java.io.ByteArrayInputStream; import java.util.Map; -import junit.framework.TestCase; - import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeProjectNature; import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature; @@ -35,7 +34,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; * * @author vhirsl */ -public class ScannerConfigDiscoveryTests extends TestCase { +public class ScannerConfigDiscoveryTests extends BaseTestCase { private IProject fCProject = null; private IFile fCFile = null; IProgressMonitor fMonitor = null; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java new file mode 100644 index 00000000000..aec8eaa16df --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.make.scannerdiscovery; + +import junit.framework.TestSuite; + +public class ScannerDiscoveryTests extends TestSuite { + + public static TestSuite suite() { + return new ScannerDiscoveryTests(); + } + + public ScannerDiscoveryTests() { + super(ScannerDiscoveryTests.class.getName()); + addTestSuite(ScannerConfigDiscoveryTests.class); + addTest(GCCScannerInfoConsoleParserTests.suite()); + addTest(GCCPerFileBOPConsoleParserTests.suite()); + } +} diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/TestScannerInfoCollector.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/TestScannerInfoCollector.java new file mode 100644 index 00000000000..8721db531b3 --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/TestScannerInfoCollector.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.scannerdiscovery; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; +import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; +import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC; + +final class TestScannerInfoCollector implements IScannerInfoCollector { + private HashMap fInfoMap = new HashMap(); + + public void contributeToScannerConfig(Object resource, Map scannerInfo) { + for (Iterator iterator = scannerInfo.entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + ScannerInfoTypes key = (ScannerInfoTypes) entry.getKey(); + List value = (List) entry.getValue(); + addTo(key, value); + if (ScannerInfoTypes.COMPILER_COMMAND.equals(key)) { + for (Iterator iterator2 = value.iterator(); iterator2.hasNext();) { + CCommandDSC cdsc= (CCommandDSC) iterator2.next(); + cdsc.resolveOptions(null); + addTo(ScannerInfoTypes.INCLUDE_PATHS, cdsc.getIncludes()); + addTo(ScannerInfoTypes.QUOTE_INCLUDE_PATHS, cdsc.getQuoteIncludes()); + addTo(ScannerInfoTypes.SYMBOL_DEFINITIONS, cdsc.getSymbols()); + } + } + } + } + + private void addTo(ScannerInfoTypes type, List col) { + Collection target= (Collection) fInfoMap.get(type); + if (target == null) { + target= new ArrayList(); + fInfoMap.put(type, target); + } + target.addAll(col); + } + + public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { + List result= (List) fInfoMap.get(type); + return result == null ? Collections.EMPTY_LIST : result; + } +} \ No newline at end of file