mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Improvement for failing tests, added rename refactoring tests to automated suite.
This commit is contained in:
parent
5dd0ee3043
commit
38aed694f5
5 changed files with 200 additions and 27 deletions
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
|
@ -15,45 +16,55 @@
|
|||
package org.eclipse.cdt.core.tests;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestFailure;
|
||||
import junit.framework.TestResult;
|
||||
|
||||
|
||||
/**
|
||||
* Wraps a test case to check for its failure.
|
||||
* @author aniefer
|
||||
*/
|
||||
public class FailingTest implements Test {
|
||||
private Test test = null;
|
||||
public class FailingTest extends TestCase {
|
||||
private TestCase test = null;
|
||||
private int bugNum = -1;
|
||||
public FailingTest( Test test, int bugNumber ){
|
||||
|
||||
public FailingTest( TestCase test, int bugNumber ){
|
||||
this.test = test;
|
||||
this.bugNum = bugNumber;
|
||||
String name= "Failing " + test.getName();
|
||||
if (bugNum > 0) {
|
||||
name += " [bug " + bugNum + "]";
|
||||
}
|
||||
setName(name);
|
||||
}
|
||||
public FailingTest( Test test ){
|
||||
this.test = test;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see junit.framework.Test#countTestCases()
|
||||
*/
|
||||
public int countTestCases() {
|
||||
return 1;
|
||||
|
||||
public FailingTest( TestCase test ){
|
||||
this(test, -1);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see junit.framework.Test#run(junit.framework.TestResult)
|
||||
*/
|
||||
public void run( TestResult result ) {
|
||||
result.startTest( test );
|
||||
result.startTest( this );
|
||||
|
||||
TestResult r = new TestResult();
|
||||
test.run( r );
|
||||
if( r.errorCount() == 0 && r.failureCount() == 0 )
|
||||
if (r.failureCount() == 1) {
|
||||
TestFailure failure= (TestFailure) r.failures().nextElement();
|
||||
String msg= failure.exceptionMessage();
|
||||
if (msg != null && msg.startsWith("Method \"" + test.getName() + "\"")) {
|
||||
result.addFailure(this, new AssertionFailedError(msg));
|
||||
}
|
||||
}
|
||||
else if( r.errorCount() == 0 && r.failureCount() == 0 )
|
||||
{
|
||||
String err = "Unexpected success"; //$NON-NLS-1$
|
||||
if( bugNum != -1 )
|
||||
err += ", bug #" + bugNum; //$NON-NLS-1$
|
||||
result.addFailure( test, new AssertionFailedError( err ) );
|
||||
result.addFailure( this, new AssertionFailedError( err ) );
|
||||
}
|
||||
|
||||
result.endTest( test );
|
||||
result.endTest( this );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ Require-Bundle: org.eclipse.jface.text,
|
|||
org.eclipse.ui.console,
|
||||
org.eclipse.core.expressions,
|
||||
org.eclipse.cdt.make.core,
|
||||
com.ibm.icu
|
||||
com.ibm.icu,
|
||||
org.eclipse.cdt.refactoring.tests
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-Vendor: Eclipse.org
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.ui.tests;
|
|||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.refactoring.tests.RenameRegressionTests;
|
||||
import org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyTestSuite;
|
||||
import org.eclipse.cdt.ui.tests.text.TextTestSuite;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite;
|
||||
|
@ -50,6 +51,8 @@ public class AutomatedSuite extends TestSuite {
|
|||
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist
|
||||
addTest(ContentAssistTestSuite.suite());
|
||||
|
||||
// tests from the refactoring plugin
|
||||
addTest(RenameRegressionTests.suite());
|
||||
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist2
|
||||
// commented out because they are failing pretty badly
|
||||
// addTest(ContentAssist2TestSuite.suite());
|
||||
|
|
|
@ -13,6 +13,9 @@ package org.eclipse.cdt.ui.tests.callhierarchy;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
@ -20,6 +23,7 @@ import org.eclipse.ui.PartInitException;
|
|||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
import org.eclipse.cdt.core.tests.FailingTest;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
|
||||
|
@ -32,6 +36,21 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
super(name);
|
||||
}
|
||||
|
||||
public static Test getFailingTests() {
|
||||
TestSuite suite= new TestSuite("Failing Tests of BasicCallHierarchyTest");
|
||||
suite.addTest(getFailingTest("_testAnonymousEnumeratorC"));
|
||||
suite.addTest(getFailingTest("_testAnonymousEnumeratorCpp"));
|
||||
suite.addTest(getFailingTest("_testAnonymousStructMembersC"));
|
||||
suite.addTest(getFailingTest("_testAnonymousStructMembersCpp"));
|
||||
suite.addTest(getFailingTest("_testAnonymousUnionMembersC"));
|
||||
suite.addTest(getFailingTest("_testAnonymousUnionMembersCpp"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
private static FailingTest getFailingTest(String name) {
|
||||
return new FailingTest(new BasicCallHierarchyTest(name));
|
||||
}
|
||||
|
||||
public void testFunctionsC() throws Exception {
|
||||
doTestFunctions("functions.c");
|
||||
}
|
||||
|
@ -141,11 +160,11 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
doTestEnumerator("enumerator.cpp", "testEnumerator");
|
||||
}
|
||||
|
||||
public void failing_testAnonymousEnumeratorC() throws Exception {
|
||||
public void _testAnonymousEnumeratorC() throws Exception {
|
||||
doTestEnumerator("enumerator.c", "testAnonymousEnumerator");
|
||||
}
|
||||
|
||||
public void failing_testAnonymousEnumeratorCpp() throws Exception {
|
||||
public void _testAnonymousEnumeratorCpp() throws Exception {
|
||||
doTestEnumerator("enumerator.cpp", "testAnonymousEnumerator");
|
||||
}
|
||||
|
||||
|
@ -287,11 +306,11 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
checkTreeNode(tree, 0, 0, "main()");
|
||||
}
|
||||
|
||||
public void failing_testAnonymousStructMembersC() throws Exception {
|
||||
public void _testAnonymousStructMembersC() throws Exception {
|
||||
doTestAnonymousStructMembers("anon_struct_member.c");
|
||||
}
|
||||
|
||||
public void failing_testAnonymousStructMembersCpp() throws Exception {
|
||||
public void _testAnonymousStructMembersCpp() throws Exception {
|
||||
doTestAnonymousStructMembers("anon_struct_member.cpp");
|
||||
}
|
||||
|
||||
|
@ -329,4 +348,148 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
checkTreeNode(tree, 0, "s4::(anon)::mem5");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
}
|
||||
|
||||
|
||||
public void testUnionMembersC() throws Exception {
|
||||
doTestUnionMembers("union_member.c");
|
||||
}
|
||||
|
||||
public void testUnionMembersCpp() throws Exception {
|
||||
doTestUnionMembers("union_member.cpp");
|
||||
}
|
||||
|
||||
// {testUnionMembers}
|
||||
// union u1 {
|
||||
// int mem1;
|
||||
// char c;
|
||||
// };
|
||||
// typedef union u2 {
|
||||
// int mem2;
|
||||
// char c;
|
||||
// } t2;
|
||||
// typedef union {
|
||||
// int mem3;
|
||||
// char c;
|
||||
// } t3;
|
||||
// union u4 {
|
||||
// union {
|
||||
// int mem5;
|
||||
// char c;
|
||||
// } mem4;
|
||||
// char c;
|
||||
// };
|
||||
//
|
||||
// void main() {
|
||||
// union u1 vs1;
|
||||
// union u2 vs2;
|
||||
// union u4 vs4;
|
||||
// t2 vt2;
|
||||
// t3 vt3;
|
||||
// int i;
|
||||
// i= vs1.mem1; //ref
|
||||
// i= vs2.mem2; //ref
|
||||
// i= vs4.mem4.mem5; //ref
|
||||
// i= vt2.mem2; //ref
|
||||
// i= vt3.mem3; //ref
|
||||
// };
|
||||
private void doTestUnionMembers(String filename) throws Exception {
|
||||
String content = readTaggedComment("testUnionMembers");
|
||||
IFile file= createFile(getProject(), filename, content);
|
||||
waitForIndexer(file, 1000);
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
Tree tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "u1::mem1");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
checkTreeNode(tree, 0, "u2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
checkTreeNode(tree, 0, "u4::mem4");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem1; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "u1::mem1");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "u2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "u4::mem4");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
}
|
||||
|
||||
public void _testAnonymousUnionMembersC() throws Exception {
|
||||
doTestAnonymousUnionMembers("anon_union_member.c");
|
||||
}
|
||||
|
||||
public void _testAnonymousUnionMembersCpp() throws Exception {
|
||||
doTestAnonymousUnionMembers("anon_union_member.cpp");
|
||||
}
|
||||
|
||||
private void doTestAnonymousUnionMembers(String filename) throws Exception {
|
||||
String content = readTaggedComment("testUnionMembers");
|
||||
IFile file= createFile(getProject(), filename, content);
|
||||
waitForIndexer(file, 1000);
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
Tree tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem3; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem5; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
||||
tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ package org.eclipse.cdt.ui.tests.callhierarchy;
|
|||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.tests.FailingTest;
|
||||
|
||||
public class CallHierarchyTestSuite extends TestSuite {
|
||||
|
||||
public static TestSuite suite() {
|
||||
|
@ -24,9 +22,6 @@ public class CallHierarchyTestSuite extends TestSuite {
|
|||
public CallHierarchyTestSuite() {
|
||||
super("Tests in package org.eclipse.cdt.ui.tests.callhierarchy");
|
||||
addTestSuite(BasicCallHierarchyTest.class);
|
||||
addTest(new FailingTest(new BasicCallHierarchyTest("failing_testAnonymousEnumeratorC")));;
|
||||
addTest(new FailingTest(new BasicCallHierarchyTest("failing_testAnonymousEnumeratorCpp")));;
|
||||
addTest(new FailingTest(new BasicCallHierarchyTest("failing_testAnonymousStructMembersC")));;
|
||||
addTest(new FailingTest(new BasicCallHierarchyTest("failing_testAnonymousStructMembersCpp")));;
|
||||
addTest(BasicCallHierarchyTest.getFailingTests());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue