mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Remove test interdependencies in CPathEntryTest
testCPathEntries verifies the presence of the default path entries. testPathEntryContainer modifies the path entries. Because the same project is being used, if testPathEntryContainer executes first, testCPathEntries fails. By creating and deleting the project every time, the problem is fixed. Also, removed some unnecessary code than seemed copy pasted but not actually used. Change-Id: Ifcd06d3a133f29b5ce9e2e0fdee34e9493377625 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/23756 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
6d82f0f7a4
commit
274b07f70f
1 changed files with 10 additions and 61 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2007 QNX Software Systems and others.
|
* Copyright (c) 2002, 2014 QNX Software Systems 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
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
|
* Marc-Andre Laperle (Ericsson)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.model.tests;
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
|
@ -31,13 +32,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
|
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceDescription;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
@ -47,11 +42,8 @@ import org.eclipse.core.runtime.Path;
|
||||||
* CPathEntryTest
|
* CPathEntryTest
|
||||||
*/
|
*/
|
||||||
public class CPathEntryTest extends BaseTestCase {
|
public class CPathEntryTest extends BaseTestCase {
|
||||||
IWorkspace workspace;
|
|
||||||
IWorkspaceRoot root;
|
private ICProject testProject;
|
||||||
IProject project_c, project_cc;
|
|
||||||
NullProgressMonitor monitor;
|
|
||||||
String pluginRoot;
|
|
||||||
|
|
||||||
class CElementListener implements IElementChangedListener {
|
class CElementListener implements IElementChangedListener {
|
||||||
|
|
||||||
|
@ -104,23 +96,10 @@ public class CPathEntryTest extends BaseTestCase {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws CoreException {
|
protected void setUp() throws CoreException {
|
||||||
/***************************************************************************************************************************
|
testProject = CProjectHelper.createCProject("cpathtest", "none", IPDOMManager.ID_NO_INDEXER);
|
||||||
* The test of the tests assume that they have a working workspace and workspace root object to use to create
|
if (testProject == null) {
|
||||||
* projects/files in, so we need to get them setup first.
|
fail("Unable to create project");
|
||||||
*/
|
}
|
||||||
IWorkspaceDescription desc;
|
|
||||||
workspace = ResourcesPlugin.getWorkspace();
|
|
||||||
root = workspace.getRoot();
|
|
||||||
monitor = new NullProgressMonitor();
|
|
||||||
if (workspace == null)
|
|
||||||
fail("Workspace was not setup");
|
|
||||||
if (root == null)
|
|
||||||
fail("Workspace root was not setup");
|
|
||||||
pluginRoot = CTestPlugin.getDefault().find(new Path("/")).getFile();
|
|
||||||
desc = workspace.getDescription();
|
|
||||||
desc.setAutoBuilding(false);
|
|
||||||
workspace.setDescription(desc);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,29 +108,20 @@ public class CPathEntryTest extends BaseTestCase {
|
||||||
* Called after every test case method.
|
* Called after every test case method.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() {
|
protected void tearDown() throws CoreException {
|
||||||
// release resources here and clean-up
|
testProject.getProject().delete(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
return suite(CPathEntryTest.class);
|
return suite(CPathEntryTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
junit.textui.TestRunner.run(suite());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************************************************************
|
/*******************************************************************************************************************************
|
||||||
* Check if the PathEntry's are generated.
|
* Check if the PathEntry's are generated.
|
||||||
*
|
*
|
||||||
* @see CProjectHelper#createCProject
|
* @see CProjectHelper#createCProject
|
||||||
*/
|
*/
|
||||||
public void testCPathEntries() throws CoreException {
|
public void testCPathEntries() throws CoreException {
|
||||||
ICProject testProject;
|
|
||||||
testProject = CProjectHelper.createCProject("cpathtest", "none", IPDOMManager.ID_NO_INDEXER);
|
|
||||||
if (testProject == null) {
|
|
||||||
fail("Unable to create project");
|
|
||||||
}
|
|
||||||
IPathEntry[] entries = testProject.getResolvedPathEntries();
|
IPathEntry[] entries = testProject.getResolvedPathEntries();
|
||||||
// We always have at least two entries:
|
// We always have at least two entries:
|
||||||
// 1) the default sourceEntry becomes the project
|
// 1) the default sourceEntry becomes the project
|
||||||
|
@ -176,11 +146,6 @@ public class CPathEntryTest extends BaseTestCase {
|
||||||
* @see CProjectHelper#createCProject
|
* @see CProjectHelper#createCProject
|
||||||
*/
|
*/
|
||||||
public void testCPathEntriesDelta() throws CoreException {
|
public void testCPathEntriesDelta() throws CoreException {
|
||||||
ICProject testProject;
|
|
||||||
testProject = CProjectHelper.createCProject("cpathtest", "none", IPDOMManager.ID_NO_INDEXER);
|
|
||||||
if (testProject == null) {
|
|
||||||
fail("Unable to create project");
|
|
||||||
}
|
|
||||||
CProjectHelper.addCContainer(testProject, "foo");
|
CProjectHelper.addCContainer(testProject, "foo");
|
||||||
IPathEntry[] entries = new IPathEntry[3];
|
IPathEntry[] entries = new IPathEntry[3];
|
||||||
entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
|
entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
|
||||||
|
@ -199,11 +164,6 @@ public class CPathEntryTest extends BaseTestCase {
|
||||||
* Check the IPathEntryContainer.
|
* Check the IPathEntryContainer.
|
||||||
*/
|
*/
|
||||||
public void testPathEntryContainer() throws CoreException {
|
public void testPathEntryContainer() throws CoreException {
|
||||||
ICProject testProject;
|
|
||||||
testProject = CProjectHelper.createCProject("cpathtest", "none", IPDOMManager.ID_NO_INDEXER);
|
|
||||||
if (testProject == null) {
|
|
||||||
fail("Unable to create project");
|
|
||||||
}
|
|
||||||
final IPath containerID = new Path("Testing/Container");
|
final IPath containerID = new Path("Testing/Container");
|
||||||
IContainerEntry containerEntry = CoreModel.newContainerEntry(containerID);
|
IContainerEntry containerEntry = CoreModel.newContainerEntry(containerID);
|
||||||
IPathEntryContainer container = new IPathEntryContainer() {
|
IPathEntryContainer container = new IPathEntryContainer() {
|
||||||
|
@ -239,17 +199,6 @@ public class CPathEntryTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSetExclusionFilter_Bug197486() throws Exception {
|
public void testSetExclusionFilter_Bug197486() throws Exception {
|
||||||
ICProject testProject = null;
|
|
||||||
try {
|
|
||||||
testProject = CProjectHelper.createCProject("cpathtest", "none", IPDOMManager.ID_NO_INDEXER);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (testProject == null) {
|
|
||||||
fail("Unable to create project");
|
|
||||||
}
|
|
||||||
|
|
||||||
// get project description
|
// get project description
|
||||||
ICProjectDescription prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
|
ICProjectDescription prjDesc= CoreModel.getDefault().getProjectDescription(testProject.getProject(), true);
|
||||||
ICConfigurationDescription activeCfg= prjDesc.getActiveConfiguration();
|
ICConfigurationDescription activeCfg= prjDesc.getActiveConfiguration();
|
||||||
|
|
Loading…
Add table
Reference in a new issue