1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 09:15:38 +02:00

Enabled scanner discovery tests for the per file scanner discovery.

This commit is contained in:
Markus Schorn 2007-07-17 15:00:53 +00:00
parent dd6ebbcaf5
commit 93f33210c7
13 changed files with 459 additions and 229 deletions

View file

@ -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

View file

@ -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

View file

@ -5,13 +5,13 @@ Bundle-SymbolicName: org.eclipse.cdt.make.core.tests
Bundle-Version: 4.0.0.qualifier Bundle-Version: 4.0.0.qualifier
Bundle-ClassPath: makecoretests.jar Bundle-ClassPath: makecoretests.jar
Bundle-Activator: org.eclipse.cdt.make.core.tests.MakeTestsPlugin Bundle-Activator: org.eclipse.cdt.make.core.tests.MakeTestsPlugin
Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.make.builder.tests, Export-Package: org.eclipse.cdt.make.builder.tests,
org.eclipse.cdt.make.core.tests org.eclipse.cdt.make.core.tests
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,
org.junit, org.junit,
org.eclipse.cdt.make.core, org.eclipse.cdt.make.core,
org.eclipse.cdt.core, org.eclipse.cdt.core,
org.eclipse.core.resources org.eclipse.core.resources,
Eclipse-AutoStart: true org.eclipse.cdt.core.tests
Eclipse-LazyStart: true
Bundle-Vendor: Eclipse.org Bundle-Vendor: Eclipse.org

View file

@ -16,11 +16,8 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; 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.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.make.core.MakeCorePlugin; 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.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;

View file

@ -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);
}
}

View file

@ -8,6 +8,7 @@ package org.eclipse.cdt.make.builder.tests;
* *
* Contributors: * Contributors:
* QNX Software Systems - initial API and implementation * QNX Software Systems - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
import junit.framework.Test; 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.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.make.core.IMakeBuilderInfo; 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.MakeBuilder;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature; 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("testProjectSettings"));
suite.addTest(new StandardBuildTests("testProjectConversion")); suite.addTest(new StandardBuildTests("testProjectConversion"));
suite.addTest(new StandardBuildTests("testProjectCleanup")); suite.addTest(new StandardBuildTests("testProjectCleanup"));
suite.addTestSuite(ScannerConfigConsoleParserTests.class);
suite.addTestSuite(ScannerConfigDiscoveryTests.class);
return suite; return suite;
} }
@ -241,9 +240,9 @@ public class StandardBuildTests extends TestCase {
IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID); IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
builderInfo.setStopOnError(ON); builderInfo.setStopOnError(ON);
builderInfo.setUseDefaultBuildCmd(OFF); builderInfo.setUseDefaultBuildCmd(OFF);
builderInfo.setBuildCommand(new Path(OVR_BUILD_COMMAND)); builderInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, OVR_BUILD_COMMAND);
builderInfo.setBuildArguments(OVR_BUILD_ARGS); builderInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, OVR_BUILD_ARGS);
builderInfo.setBuildLocation(new Path(OVR_BUILD_LOCATION)); builderInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, OVR_BUILD_LOCATION);
try { try {
project.close(new NullProgressMonitor()); project.close(new NullProgressMonitor());
} catch (CoreException e) { } catch (CoreException e) {

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - initial API and implementation * QNX Software Systems - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.make.core.tests; package org.eclipse.cdt.make.core.tests;
@ -14,6 +15,7 @@ import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.make.builder.tests.StandardBuildTests; import org.eclipse.cdt.make.builder.tests.StandardBuildTests;
import org.eclipse.cdt.make.scannerdiscovery.ScannerDiscoveryTests;
public class AutomatedIntegrationSuite extends TestSuite { public class AutomatedIntegrationSuite extends TestSuite {
@ -36,6 +38,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite(); final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite();
suite.addTest(StandardBuildTests.suite()); suite.addTest(StandardBuildTests.suite());
suite.addTest(ScannerDiscoveryTests.suite());
return suite; return suite;
} }

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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);
}
}

View file

@ -8,16 +8,15 @@
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.make.builder.tests; package org.eclipse.cdt.make.scannerdiscovery;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.Map; import java.util.Map;
import junit.framework.TestCase;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo; 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.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature; import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature; import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
@ -35,7 +34,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* *
* @author vhirsl * @author vhirsl
*/ */
public class ScannerConfigDiscoveryTests extends TestCase { public class ScannerConfigDiscoveryTests extends BaseTestCase {
private IProject fCProject = null; private IProject fCProject = null;
private IFile fCFile = null; private IFile fCFile = null;
IProgressMonitor fMonitor = null; IProgressMonitor fMonitor = null;

View file

@ -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());
}
}

View file

@ -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;
}
}