1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cleaned up warnings in the tests.

This commit is contained in:
Doug Schaefer 2005-05-28 02:15:24 +00:00
parent cf6eeec9c8
commit bc8ea403ac
6 changed files with 8 additions and 222 deletions

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
@ -103,7 +104,7 @@ public class CPathEntryTest extends TestCase {
fail("Workspace was not setup");
if (root == null)
fail("Workspace root was not setup");
pluginRoot = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
pluginRoot = CTestPlugin.getDefault().find(new Path("/")).getFile();
desc = workspace.getDescription();
desc.setAutoBuilding(false);
workspace.setDescription(desc);

View file

@ -25,6 +25,7 @@ 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.core.parser.ScannerInfo;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.core.runtime.Path;
@ -95,7 +96,7 @@ public class AutomatedTest extends AutomatedFramework {
}
protected void loadProperties() throws Exception{
String resourcePath = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); //$NON-NLS-1$ //$NON-NLS-2$
String resourcePath = CTestPlugin.getDefault().find(new Path("/")).getFile(); //$NON-NLS-1$ //$NON-NLS-2$
resourcePath += "resources/parser/AutomatedTest"; //$NON-NLS-1$
try{

View file

@ -28,6 +28,7 @@ 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.core.parser.ScannerInfo;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.core.runtime.Path;
/**
@ -50,7 +51,7 @@ public class FractionalAutomatedTest extends AutomatedFramework {
return new FractionalAutomatedTest( name );
}
protected void loadProperties() throws Exception{
String resourcePath = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); //$NON-NLS-1$ //$NON-NLS-2$
String resourcePath = CTestPlugin.getDefault().find(new Path("/")).getFile(); //$NON-NLS-1$ //$NON-NLS-2$
resourcePath += "resources/parser/AutomatedTest"; //$NON-NLS-1$
try{

View file

@ -28,6 +28,7 @@ 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.core.parser.ScannerInfo;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.core.runtime.Path;
@ -54,7 +55,7 @@ public class TortureTest extends FractionalAutomatedTest {
}
protected void loadProperties() throws Exception{
String resourcePath = org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile(); //$NON-NLS-1$ //$NON-NLS-2$
String resourcePath = CTestPlugin.getDefault().find(new Path("/")).getFile(); //$NON-NLS-1$ //$NON-NLS-2$
resourcePath += "resources/parser/TortureTest"; //$NON-NLS-1$
try {

View file

@ -16,7 +16,6 @@ package org.eclipse.cdt.core.search.tests;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.cdt.core.parser.IOffsetDuple;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.IMatch;

View file

@ -1,217 +0,0 @@
package org.eclipse.cdt.core.suite;
import java.io.FileOutputStream;
import java.io.PrintStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestListener;
import junit.framework.TestResult;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.testing.ITestHarness;
import org.eclipse.ui.testing.TestableObject;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ProcessingInstruction;
/**
* @see IPlatformRunnable
*/
public class RunTests implements ITestHarness, TestListener {
private TestableObject testableObject;
private PrintStream stream;
private String testReport;
private String pluginName = "org.eclipse.cdt.core.tests";
Document doc;
Element testRun;
Element testSuite;
Element testClass;
Element test;
/**
*
*/
public RunTests() {
}
/**
* @see IPlatformRunnable#run
*/
public Object run(Object args) throws Exception {
stream = System.out;
String [] sargs = (String[])args;
for (int i = 0; i <sargs.length; ++i) {
if (sargs[i].equals("-testout") && ++i < sargs.length) {
stream = new PrintStream(new FileOutputStream(sargs[i]));
} else if (sargs[i].equals("-testreport") && ++i < sargs.length) {
testReport = sargs[i];
}
}
IPlatformRunnable application = getApplication();
testableObject = PlatformUI.getTestableObject();
testableObject.setTestHarness(this);
return application.run(args);
}
/*
* return the application to run, or null if not even the default application
* is found.
*/
private IPlatformRunnable getApplication() throws CoreException {
// Assume we are in 3.0 mode.
// Find the name of the application as specified by the PDE JUnit launcher.
// If no application is specified, the 3.0 default workbench application
// is returned.
IExtension extension =
Platform.getPluginRegistry().getExtension(
Platform.PI_RUNTIME,
Platform.PT_APPLICATIONS,
"org.eclipse.ui.ide.workbench");
// If the extension does not have the correct grammar, return null.
// Otherwise, return the application object.
IConfigurationElement[] elements = extension.getConfigurationElements();
if (elements.length > 0) {
IConfigurationElement[] runs = elements[0].getChildren("run");
if (runs.length > 0) {
Object runnable = runs[0].createExecutableExtension("class");
if (runnable instanceof IPlatformRunnable)
return (IPlatformRunnable) runnable;
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.ui.testing.ITestHarness#runTests()
*/
public void runTests() {
testableObject.testingStarting();
testableObject.runTest(new Runnable() {
public void run() {
TestResult results = new TestResult();
results.addListener(RunTests.this);
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
ProcessingInstruction pi = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + testReport +"\"");
doc.appendChild(pi);
testRun = doc.createElement("testRun");
doc.appendChild(testRun);
testRun.setAttribute("name", pluginName);
startSuite(AutomatedIntegrationSuite.class.getName());
AutomatedIntegrationSuite.suite().run(results);
currentTest = null;
results.removeListener(RunTests.this);
results.stop();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(doc), new StreamResult(stream));
} catch (Throwable t) {
System.out.println("runTests failed");
t.printStackTrace();
}
}
});
testableObject.testingFinished();
}
// Test Listener methods
Throwable failure;
/* (non-Javadoc)
* @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
*/
public void addError(Test test, Throwable t) {
failure = t;
}
/* (non-Javadoc)
* @see junit.framework.TestListener#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
*/
public void addFailure(Test test, AssertionFailedError t) {
failure = t;
}
/* (non-Javadoc)
* @see junit.framework.TestListener#endTest(junit.framework.Test)
*/
public void endTest(Test t) {
double time = (System.currentTimeMillis() - startTime) / 1000.0;
test.setAttribute("time", String.valueOf(time));
String result;
if (failure == null)
result = "pass";
else {
CDATASection data = doc.createCDATASection(failure.toString());
test.appendChild(data);
if (failure instanceof AssertionFailedError)
result = "failed";
else
result = "error";
}
test.setAttribute("result", result);
failure = null;
}
private Class currentTest;
private long startTime;
/* (non-Javadoc)
* @see junit.framework.TestListener#startTest(junit.framework.Test)
*/
public void startTest(Test t) {
if (t.getClass() != currentTest) {
currentTest = t.getClass();
testClass = doc.createElement("testClass");
testSuite.appendChild(testClass);
testClass.setAttribute("name", currentTest.getName());
}
test = doc.createElement("test");
testClass.appendChild(test);
String name = t.toString();
name = name.substring(0, name.indexOf('('));
test.setAttribute("name", name);
startTime = System.currentTimeMillis();
}
// Report Generator
private void startSuite(String name) {
testSuite = doc.createElement("testSuite");
testRun.appendChild(testSuite);
testSuite.setAttribute("name", name);
}
}