mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 15:35:24 +02:00
Disabled a failing test.
This commit is contained in:
parent
c24990c2ad
commit
71592307c1
1 changed files with 61 additions and 92 deletions
|
@ -11,11 +11,11 @@
|
||||||
package org.eclipse.cdt.core.model.tests;
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Stack;
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Deque;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IInclude;
|
import org.eclipse.cdt.core.model.IInclude;
|
||||||
|
@ -26,72 +26,36 @@ import org.eclipse.cdt.core.testplugin.util.ExpectedStrings;
|
||||||
/**
|
/**
|
||||||
* @author Peter Graves
|
* @author Peter Graves
|
||||||
*
|
*
|
||||||
* This file contains a set of generic tests for the core C model's
|
* This file contains a set of generic tests for the core C model's TranslationUnit class.
|
||||||
* TranslationUnit class. There is nothing exotic here, mostly just sanity type
|
* There is nothing exotic here, mostly just sanity type tests.
|
||||||
* tests.
|
|
||||||
*/
|
*/
|
||||||
public class TranslationUnitTests extends TranslationUnitBaseTest {
|
public class TranslationUnitTests extends TranslationUnitBaseTest {
|
||||||
/*
|
/*
|
||||||
* This is a list of elements in the test .c file. It will be used in a
|
* This is a list of elements in the test .c file. It will be used in a
|
||||||
* number of places in the tests
|
* number of places in the tests
|
||||||
*/
|
*/
|
||||||
String[] expectedStringList = { "stdio.h", "unistd.h", "func2p",
|
private static final String[] expectedStringList = {
|
||||||
"globalvar", "myenum", "mystruct_t", "mystruct", "myunion",
|
"stdio.h", "unistd.h", "func2p", "globalvar", "myenum", "mystruct_t",
|
||||||
"mytype", "func1", "func2", "main", "func3" };
|
"mystruct", "myunion", "mytype", "func1", "func2", "main", "func3" };
|
||||||
|
|
||||||
int[] expectedLines = { 12, 14, 17, 20, 23, 28, 32, 35, 42, 47, 53, 58, 65, 70 };
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a list of that the types of the above list of elements is
|
|
||||||
* expected to be.
|
|
||||||
*/
|
|
||||||
int[] expectedTypes = { ICElement.C_INCLUDE, ICElement.C_INCLUDE,
|
|
||||||
ICElement.C_FUNCTION_DECLARATION, ICElement.C_VARIABLE,
|
|
||||||
ICElement.C_ENUMERATION, ICElement.C_STRUCT, ICElement.C_TYPEDEF,
|
|
||||||
ICElement.C_UNION, ICElement.C_TYPEDEF, ICElement.C_FUNCTION,
|
|
||||||
ICElement.C_FUNCTION, ICElement.C_FUNCTION, ICElement.C_FUNCTION,
|
|
||||||
ICElement.C_FUNCTION };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for TranslationUnitTests
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public TranslationUnitTests(String name) {
|
public TranslationUnitTests(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
TestSuite suite = new TestSuite(TranslationUnitTests.class.getName());
|
return new TestSuite(TranslationUnitTests.class);
|
||||||
suite.addTest(new TranslationUnitTests("testIsTranslationUnit"));
|
|
||||||
suite.addTest(new TranslationUnitTests("testGetChildren"));
|
|
||||||
suite.addTest(new TranslationUnitTests("testGetElement"));
|
|
||||||
suite.addTest(new TranslationUnitTests("testBug23478A"));
|
|
||||||
suite.addTest(new TranslationUnitTests("testBug23478B"));
|
|
||||||
suite.addTest(new TranslationUnitTests("testIsValidSourceUnitName"));
|
|
||||||
suite.addTest(new TranslationUnitTests("testAssemblyContentType_Bug186774"));
|
|
||||||
// TODO: suite.addTest(new
|
|
||||||
// TranslationUnitTests("testGetElementAtLine"));
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
junit.textui.TestRunner.run(suite());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Simple sanity test to make sure TranslationUnit.isTranslationUnit returns
|
* Simple sanity test to make sure TranslationUnit.isTranslationUnit returns true
|
||||||
* true
|
|
||||||
*/
|
*/
|
||||||
public void testIsTranslationUnit() throws Exception,
|
public void testIsTranslationUnit() throws Exception, FileNotFoundException {
|
||||||
FileNotFoundException {
|
|
||||||
ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c");
|
ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c");
|
||||||
assertNotNull(tu);
|
assertNotNull(tu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Simple sanity tests to make sure TranslationUnit.getChildren seems to
|
* Simple sanity tests to make sure TranslationUnit.getChildren seems to basically work.
|
||||||
* basicly work
|
|
||||||
*/
|
*/
|
||||||
public void testGetChildren() throws Exception {
|
public void testGetChildren() throws Exception {
|
||||||
ExpectedStrings expectedString = new ExpectedStrings(expectedStringList);
|
ExpectedStrings expectedString = new ExpectedStrings(expectedStringList);
|
||||||
|
@ -104,8 +68,7 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
||||||
expectedString.foundString(elements[x].getElementName());
|
expectedString.foundString(elements[x].getElementName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue("PR:23603 " + expectedString.getMissingString(),
|
assertTrue("PR:23603 " + expectedString.getMissingString(), expectedString.gotAll());
|
||||||
expectedString.gotAll());
|
|
||||||
assertTrue(expectedString.getExtraString(), !expectedString.gotExtra());
|
assertTrue(expectedString.getExtraString(), !expectedString.gotExtra());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,25 +76,25 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
||||||
* Simple sanity tests for the getElement() call
|
* Simple sanity tests for the getElement() call
|
||||||
*/
|
*/
|
||||||
public void testGetElement() throws Exception {
|
public void testGetElement() throws Exception {
|
||||||
Stack missing = new Stack();
|
Deque<String> missing = new ArrayDeque<String>();
|
||||||
ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject,
|
ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c");
|
||||||
"exetest.c");
|
|
||||||
|
|
||||||
for (int x = 0; x < expectedStringList.length; x++) {
|
for (int x = 0; x < expectedStringList.length; x++) {
|
||||||
ICElement myElement = tu.getElement(expectedStringList[x]);
|
ICElement myElement = tu.getElement(expectedStringList[x]);
|
||||||
if (myElement == null) {
|
if (myElement == null) {
|
||||||
missing.push(expectedStringList[x]);
|
missing.push(expectedStringList[x]);
|
||||||
} else {
|
} else {
|
||||||
assertTrue("Expected: \"" + expectedStringList[x] + "\". Got:"
|
assertTrue("Expected: \"" + expectedStringList[x]
|
||||||
+ myElement.getElementName(),
|
+ "\". Got:" + myElement.getElementName(),
|
||||||
expectedStringList[x].equals(myElement.getElementName()));
|
expectedStringList[x].equals(myElement.getElementName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!missing.empty()) {
|
if (!missing.isEmpty()) {
|
||||||
String output = new String("PR:23603 Could not get elements: ");
|
StringBuilder output = new StringBuilder("PR:23603 Could not get elements:");
|
||||||
while (!missing.empty())
|
while (!missing.isEmpty()) {
|
||||||
output += missing.pop() + " ";
|
output.append(" ").append(missing.pop());
|
||||||
assertTrue(output, false);
|
}
|
||||||
|
assertTrue(output.toString(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,35 +138,37 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Simple sanity tests for the getElementAtLine() call
|
* Simple sanity tests for the getElementAtLine() call.
|
||||||
*/
|
*/
|
||||||
public void testGetElementAtLine() throws Exception {
|
// This test is disabled due to consistent failure.
|
||||||
Stack missing = new Stack();
|
// public void testGetElementAtLine() throws Exception {
|
||||||
ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c");
|
// Deque<String> missing = new ArrayDeque<String>();
|
||||||
|
// ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c");
|
||||||
for (int x = 0; x < expectedStringList.length; x++) {
|
//
|
||||||
ICElement element = tu.getElementAtLine(expectedLines[x]);
|
// for (int x = 0; x < expectedStringList.length; x++) {
|
||||||
if (element == null) {
|
// ICElement element = tu.getElementAtLine(expectedLines[x]);
|
||||||
missing.push(expectedStringList[x]);
|
// if (element == null) {
|
||||||
} else {
|
// missing.push(expectedStringList[x]);
|
||||||
if (expectedStringList[x].equals("mystruct_t")) {
|
// } else {
|
||||||
assertTrue("PR:23603 expected: " + expectedStringList[x]
|
// if (expectedStringList[x].equals("mystruct_t")) {
|
||||||
+ ". Got: " + element.getElementName(),
|
// assertTrue("PR:23603 expected: " + expectedStringList[x]
|
||||||
expectedStringList[x].equals(element.getElementName()));
|
// + ". Got: " + element.getElementName(),
|
||||||
} else {
|
// expectedStringList[x].equals(element.getElementName()));
|
||||||
assertTrue("Expected:" + expectedStringList[x] + " Got: "
|
// } else {
|
||||||
+ element.getElementName(), expectedStringList[x]
|
// assertTrue("Expected: " + expectedStringList[x]
|
||||||
.equals(element.getElementName()));
|
// + ". Got: " + element.getElementName(),
|
||||||
}
|
// expectedStringList[x].equals(element.getElementName()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (!missing.empty()) {
|
// }
|
||||||
String output = new String("PR: 23603 Could not get elements: ");
|
// if (!missing.isEmpty()) {
|
||||||
while (!missing.empty())
|
// StringBuilder output = new StringBuilder("PR:23603 Could not get elements:");
|
||||||
output += missing.pop() + " ";
|
// while (!missing.isEmpty()) {
|
||||||
assertTrue(output, false);
|
// output.append(" ").append(missing.pop());
|
||||||
}
|
// }
|
||||||
}
|
// assertTrue(output.toString(), false);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public void testIsValidSourceUnitName() {
|
public void testIsValidSourceUnitName() {
|
||||||
assertTrue(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.c"));
|
assertTrue(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.c"));
|
||||||
|
@ -212,8 +177,12 @@ public class TranslationUnitTests extends TranslationUnitBaseTest {
|
||||||
assertFalse(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.hh"));
|
assertFalse(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.hh"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAssemblyContentType_Bug186774() {
|
// This test is disabled because it fails consistently due to a collision between content types
|
||||||
assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.s"));
|
// "asmSource" defined in org.eclipse.cdt.core and
|
||||||
assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.S"));
|
// "org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssemblyCode" defined in
|
||||||
}
|
// org.eclipse.cdt.managedbuilder.llvm.ui.
|
||||||
|
// public void testAssemblyContentType_Bug186774() {
|
||||||
|
// assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.s"));
|
||||||
|
// assertEquals(CCorePlugin.CONTENT_TYPE_ASMSOURCE, CoreModel.getRegistedContentTypeId(testProject.getProject(), "test.S"));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue