diff options
author | John Camelon | 2003-10-01 17:10:20 +0000 |
---|---|---|
committer | John Camelon | 2003-10-01 17:10:20 +0000 |
commit | c3b63fb508d7b3096dcfea4e7dd5d1b7eda4d485 (patch) | |
tree | 59b48ba794600825e5c5e82d5e749ddce0186ef3 /core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt | |
parent | 10fcbc9c55e0dd3446e0f69afcedf24a87dda861 (diff) | |
download | org.eclipse.cdt-c3b63fb508d7b3096dcfea4e7dd5d1b7eda4d485.tar.gz org.eclipse.cdt-c3b63fb508d7b3096dcfea4e7dd5d1b7eda4d485.tar.xz org.eclipse.cdt-c3b63fb508d7b3096dcfea4e7dd5d1b7eda4d485.zip |
Patch for Andrew Niefer
Bug 43450 - Path strings containing backslashes need quoting by hand
The user needs to input strings in whatever manner necessary for their
build tools to work. If that means quoting them, then quote them.
However, if the user does quote them, then the scanner needs to handle
that when looking for include files:
core:
-modify Scanner.handleInclusion
core.tests:
- added testBug43450 to ManagedBuildTests.java
- added a user include to plugin.xml
Diffstat (limited to 'core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt')
-rw-r--r-- | core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java index 4a933236193..b9c08a26b41 100644 --- a/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java +++ b/core/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java @@ -10,6 +10,8 @@ **********************************************************************/ package org.eclipse.cdt.core.build.managed.tests; +import java.io.ByteArrayInputStream; +import java.io.StringReader; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -20,9 +22,16 @@ import junit.framework.TestSuite; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; +import org.eclipse.cdt.core.parser.IParser; +import org.eclipse.cdt.core.parser.IScanner; 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.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.ParserFactory; +import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; @@ -34,6 +43,9 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.cdt.managedbuilder.internal.core.OptionReference; import org.eclipse.cdt.managedbuilder.internal.core.ToolReference; +import org.eclipse.cdt.testplugin.FileManager; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; @@ -71,6 +83,7 @@ public class ManagedBuildTests extends TestCase { suite.addTest(new ManagedBuildTests("testTargetBuildArtifact")); suite.addTest(new ManagedBuildTests("testMakeCommandManipulation")); suite.addTest(new ManagedBuildTests("testScannerInfoInterface")); + suite.addTest(new ManagedBuildTests("testBug43450")); suite.addTest(new ManagedBuildTests("cleanup")); return suite; @@ -154,14 +167,6 @@ public class ManagedBuildTests extends TestCase { * @throws CoreException */ public void testScannerInfoInterface(){ - // These are the expected path settings - final String[] expectedPaths = new String[4]; - // This first path is a built-in, so it will not be manipulated by build manager - expectedPaths[0] = "/usr/gnu/include"; - expectedPaths[1] = (new Path("/usr/include")).toOSString(); - expectedPaths[2] = (new Path("/opt/gnome/include")).toOSString(); - expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString(); - // Open the test project IProject project = null; try { @@ -170,6 +175,15 @@ public class ManagedBuildTests extends TestCase { fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage()); } + //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] = "/usr/gnu/include"; + expectedPaths[1] = (new Path("/usr/include")).toOSString(); + expectedPaths[2] = (new Path("/opt/gnome/include")).toOSString(); + expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString(); + expectedPaths[4] = project.getLocation().append( "Sub Config\\\"..\\includes\"" ).toOSString(); + // Create a new target in the project based on the sub target ITarget baseTarget = ManagedBuildManager.getTarget(project, "test.sub"); assertNotNull(baseTarget); @@ -845,7 +859,7 @@ public class ManagedBuildTests extends TestCase { assertEquals("More Includes", subOpts[2].getName()); assertEquals(IOption.INCLUDE_PATH, subOpts[2].getValueType()); String[] moreIncPath = subOpts[2].getIncludePaths(); - assertEquals(1, moreIncPath.length); + assertEquals(2, moreIncPath.length); assertEquals("C:\\home\\tester/include", moreIncPath[0]); assertEquals("-I", subOpts[2].getCommand()); // Check the user object option @@ -956,4 +970,30 @@ public class ManagedBuildTests extends TestCase { assertTrue(false); } + public void testBug43450 () throws Exception{ + IProject project = createProject( projectName ); + + FileManager fileManager = new FileManager(); + + IFolder folder = project.getProject().getFolder( "includes" ); + if( !folder.exists() ){ + folder.create( false, true, null ); + } + + IFile file = project.getProject().getFile( "includes/header.h" ); + if( !file.exists() ){ + file.create( new ByteArrayInputStream( "class A { public : static int i; };".getBytes() ), false, null ); + } + + IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); + IScannerInfo info = provider.getScannerInformation( project ); + ISourceElementRequestor callback = new NullSourceElementRequestor(); + + IScanner scanner = ParserFactory.createScanner( new StringReader( "#include <header.h>\n int A::i = 1;" ), + "TEST", info, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback ); + + IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP ); + assertTrue( parser.parse() ); + } + } |