mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
pwd in scanner discovery, bug 237958.
This commit is contained in:
parent
0954c9559b
commit
87b69a7f19
2 changed files with 33 additions and 13 deletions
|
@ -47,6 +47,7 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
fCProject= CProjectHelper.createCCProject("perfilescdtest", null);
|
fCProject= CProjectHelper.createCCProject("perfilescdtest", null);
|
||||||
|
@ -55,6 +56,7 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
|
||||||
fOutputParser.startup(project, project.getLocation(), fCollector, MARKER_GENERATOR);
|
fOutputParser.startup(project, project.getLocation(), fCollector, MARKER_GENERATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
if (fOutputParser != null) {
|
if (fOutputParser != null) {
|
||||||
|
@ -68,7 +70,7 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
|
||||||
public void testParsingIfStatement_bug197930() throws Exception {
|
public void testParsingIfStatement_bug197930() throws Exception {
|
||||||
fOutputParser.processLine("if gcc -g -O0 -I\"include abc\" -c impl/testmath.c; then ; fi"); //$NON-NLS-1$
|
fOutputParser.processLine("if gcc -g -O0 -I\"include abc\" -c impl/testmath.c; then ; fi"); //$NON-NLS-1$
|
||||||
|
|
||||||
List cmds = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.COMPILER_COMMAND);
|
List<?> cmds = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.COMPILER_COMMAND);
|
||||||
assertEquals(1, cmds.size());
|
assertEquals(1, cmds.size());
|
||||||
CCommandDSC command= (CCommandDSC) cmds.get(0);
|
CCommandDSC command= (CCommandDSC) cmds.get(0);
|
||||||
assertEquals("gcc", command.getCompilerName());
|
assertEquals("gcc", command.getCompilerName());
|
||||||
|
@ -76,16 +78,16 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
|
||||||
|
|
||||||
public void testResolvingLinkedFolder_Bug213690() throws Exception {
|
public void testResolvingLinkedFolder_Bug213690() throws Exception {
|
||||||
File tempRoot= new File(System.getProperty("java.io.tmpdir"));
|
File tempRoot= new File(System.getProperty("java.io.tmpdir"));
|
||||||
File tempDir= new File(tempRoot, "cdttest_213690");
|
File tempDir= new File(tempRoot, "cdttest_213690").getCanonicalFile();
|
||||||
tempDir.mkdir();
|
tempDir.mkdir();
|
||||||
try {
|
try {
|
||||||
IFolder linkedFolder= fCProject.getProject().getFolder("cdttest");
|
IFolder linkedFolder= fCProject.getProject().getFolder("cdttest");
|
||||||
linkedFolder.createLink(new Path(tempDir.toString()), IResource.ALLOW_MISSING_LOCAL, null);
|
linkedFolder.createLink(new Path(tempDir.toString()), IResource.ALLOW_MISSING_LOCAL, null);
|
||||||
fOutputParser.processLine("gcc -g -O0 -I\""+ tempDir.toString() + "\"" + "-c test.c"); //$NON-NLS-1$
|
fOutputParser.processLine("gcc -g -O0 -I\""+ tempDir.toString() + "\" -c test.c"); //$NON-NLS-1$
|
||||||
List cmds = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.COMPILER_COMMAND);
|
List<?> cmds = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.COMPILER_COMMAND);
|
||||||
assertEquals(1, cmds.size());
|
assertEquals(1, cmds.size());
|
||||||
CCommandDSC command= (CCommandDSC) cmds.get(0);
|
CCommandDSC command= (CCommandDSC) cmds.get(0);
|
||||||
List includes= command.getIncludes();
|
List<?> includes= command.getIncludes();
|
||||||
assertEquals(1, includes.size());
|
assertEquals(1, includes.size());
|
||||||
assertEquals(tempDir.toString(), includes.get(0).toString());
|
assertEquals(tempDir.toString(), includes.get(0).toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -105,7 +107,7 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
|
||||||
linkedFolder.createLink(new Path(tempDir.toString()), IResource.ALLOW_MISSING_LOCAL, null);
|
linkedFolder.createLink(new Path(tempDir.toString()), IResource.ALLOW_MISSING_LOCAL, null);
|
||||||
fOutputParser.processLine("gcc -g -O0 -c \""+ tempFile.toString() + "\""); //$NON-NLS-1$
|
fOutputParser.processLine("gcc -g -O0 -c \""+ tempFile.toString() + "\""); //$NON-NLS-1$
|
||||||
IFile file= linkedFolder.getFile("test.c");
|
IFile file= linkedFolder.getFile("test.c");
|
||||||
List cmds = fCollector.getCollectedScannerInfo(file, ScannerInfoTypes.COMPILER_COMMAND);
|
List<?> cmds = fCollector.getCollectedScannerInfo(file, ScannerInfoTypes.COMPILER_COMMAND);
|
||||||
assertEquals(1, cmds.size());
|
assertEquals(1, cmds.size());
|
||||||
} finally {
|
} finally {
|
||||||
if (tempFile != null) {
|
if (tempFile != null) {
|
||||||
|
@ -114,4 +116,23 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
|
||||||
tempDir.delete();
|
tempDir.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPwdInFilePath_Bug237958() throws Exception {
|
||||||
|
IFile file1= fCProject.getProject().getFile("Bug237958_1.c");
|
||||||
|
IFile file2= fCProject.getProject().getFile("Bug237958_2.c");
|
||||||
|
fOutputParser.processLine("gcc -g -DTEST1 -c `pwd`/Bug237958_1.c");
|
||||||
|
fOutputParser.processLine("gcc -DTEST2=12 -g -ggdb -Wall -c \"`pwd`/./Bug237958_2.c\"");
|
||||||
|
|
||||||
|
List<?> cmds = fCollector.getCollectedScannerInfo(file1, ScannerInfoTypes.COMPILER_COMMAND);
|
||||||
|
CCommandDSC cdsc= (CCommandDSC) cmds.get(0);
|
||||||
|
List<?> symbols= cdsc.getSymbols();
|
||||||
|
assertEquals(1, symbols.size());
|
||||||
|
assertEquals("TEST1=1", symbols.get(0).toString());
|
||||||
|
|
||||||
|
cmds = fCollector.getCollectedScannerInfo(file2, ScannerInfoTypes.COMPILER_COMMAND);
|
||||||
|
cdsc= (CCommandDSC) cmds.get(0);
|
||||||
|
symbols= cdsc.getSymbols();
|
||||||
|
assertEquals(1, symbols.size());
|
||||||
|
assertEquals("TEST2=12", symbols.get(0).toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -177,8 +177,8 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
|
||||||
* @return array of commands
|
* @return array of commands
|
||||||
*/
|
*/
|
||||||
protected String[][] tokenize(String line, boolean escapeInsideDoubleQuotes) {
|
protected String[][] tokenize(String line, boolean escapeInsideDoubleQuotes) {
|
||||||
ArrayList commands= new ArrayList();
|
ArrayList<String[]> commands= new ArrayList<String[]>();
|
||||||
ArrayList tokens= new ArrayList();
|
ArrayList<String> tokens= new ArrayList<String>();
|
||||||
StringBuffer token= new StringBuffer();
|
StringBuffer token= new StringBuffer();
|
||||||
|
|
||||||
final char[] input= line.toCharArray();
|
final char[] input= line.toCharArray();
|
||||||
|
@ -197,7 +197,6 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
|
||||||
if (c=='`') {
|
if (c=='`') {
|
||||||
token.append(c); // preserve back-quotes
|
token.append(c); // preserve back-quotes
|
||||||
}
|
}
|
||||||
endToken(token, tokens);
|
|
||||||
currentQuote= 0;
|
currentQuote= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,17 +273,17 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endCommand(token, tokens, commands);
|
endCommand(token, tokens, commands);
|
||||||
return (String[][]) commands.toArray(new String[commands.size()][]);
|
return commands.toArray(new String[commands.size()][]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endCommand(StringBuffer token, ArrayList tokens, ArrayList commands) {
|
private void endCommand(StringBuffer token, ArrayList<String> tokens, ArrayList<String[]> commands) {
|
||||||
endToken(token, tokens);
|
endToken(token, tokens);
|
||||||
if (!tokens.isEmpty()) {
|
if (!tokens.isEmpty()) {
|
||||||
commands.add(tokens.toArray(new String[tokens.size()]));
|
commands.add(tokens.toArray(new String[tokens.size()]));
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void endToken(StringBuffer token, ArrayList tokens) {
|
private void endToken(StringBuffer token, ArrayList<String> tokens) {
|
||||||
if (token.length() > 0) {
|
if (token.length() > 0) {
|
||||||
tokens.add(token.toString());
|
tokens.add(token.toString());
|
||||||
token.setLength(0);
|
token.setLength(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue