1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*******************************************************************************
* Copyright (c) 2007, 2008 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
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.make.scannerdiscovery;
import java.io.File;
import java.util.List;
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.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileBOPConsoleParser;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Path;
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 testParsingIfStatement_bug197930() throws Exception {
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);
assertEquals(1, cmds.size());
CCommandDSC command= (CCommandDSC) cmds.get(0);
assertEquals("gcc", command.getCompilerName());
}
public void testResolvingLinkedResourceArgument_Bug216945() throws Exception {
File tempRoot= new File(System.getProperty("java.io.tmpdir"));
File tempDir= new File(tempRoot, "cdttest_216945");
tempDir.mkdir();
File tempFile= null;
try {
tempFile= new File(tempDir, "test.c");
tempFile.createNewFile();
IFolder linkedFolder= fCProject.getProject().getFolder("cdttest");
linkedFolder.createLink(new Path(tempDir.toString()), IResource.ALLOW_MISSING_LOCAL, null);
fOutputParser.processLine("gcc -g -O0 -c \""+ tempFile.toString() + "\""); //$NON-NLS-1$
IFile file= linkedFolder.getFile("test.c");
List cmds = fCollector.getCollectedScannerInfo(file, ScannerInfoTypes.COMPILER_COMMAND);
assertEquals(1, cmds.size());
} finally {
if (tempFile != null) {
tempFile.delete();
}
tempDir.delete();
}
}
}
|