mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
Fixed the tests to use the CTestPlugin findFileInPlugin
method. This should get the tests working on M6 and M7.
This commit is contained in:
parent
c48ea4de7f
commit
7e32d05829
13 changed files with 111 additions and 96 deletions
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
|||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -667,13 +668,11 @@ import org.eclipse.core.runtime.Platform;
|
|||
String testCaseName = this.getName();
|
||||
//Obtain file handle
|
||||
file = testProject.getProject().getFile(fileName);
|
||||
String pluginRoot = Platform.asLocalURL(
|
||||
Platform.getPlugin("org.eclipse.cdt.core.tests")
|
||||
.getDescriptor().getInstallURL()).getFile();
|
||||
//Create file input stream
|
||||
monitor = new NullProgressMonitor();
|
||||
if (!file.exists()) {
|
||||
file.create(new FileInputStream(pluginRoot + resourceLocation),
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path(resourceLocation))),
|
||||
false, monitor);
|
||||
}
|
||||
fileDoc = new IFileDocument(file);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.internal.core.index.impl.IFileDocument;
|
|||
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -35,7 +36,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @author bgheorgh
|
||||
|
@ -132,13 +133,11 @@ public class IndexManagerTests extends TestCase {
|
|||
private IFile importFile(String fileName, String resourceLocation)throws Exception {
|
||||
//Obtain file handle
|
||||
file = testProject.getProject().getFile(fileName);
|
||||
String pluginRoot = Platform.asLocalURL(
|
||||
Platform.getPlugin("org.eclipse.cdt.core.tests")
|
||||
.getDescriptor().getInstallURL()).getFile();
|
||||
//Create file input stream
|
||||
monitor = new NullProgressMonitor();
|
||||
if (!file.exists()) {
|
||||
file.create(new FileInputStream(pluginRoot + resourceLocation),
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path(resourceLocation))),
|
||||
false, monitor);
|
||||
}
|
||||
fileDoc = new IFileDocument(file);
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.model.IBinary;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.testplugin.util.ExpectedStrings;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
|
@ -25,9 +26,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Peter Graves
|
||||
|
@ -80,48 +78,50 @@ public class ArchiveTests extends TestCase {
|
|||
* Setup the various files, paths and projects that are needed by the
|
||||
* tests
|
||||
*/
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
testProject=CProjectHelper.createCProject("filetest", "none");
|
||||
if (testProject==null)
|
||||
fail("Unable to create project");
|
||||
|
||||
cfile = testProject.getProject().getFile("exetest.c");
|
||||
if (!cfile.exists()) {
|
||||
cfile.create(new FileInputStream(pluginRoot+"resources/exe/main.c"),false, monitor);
|
||||
|
||||
cfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
|
||||
false, monitor);
|
||||
}
|
||||
cpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.c");
|
||||
|
||||
objfile = testProject.getProject().getFile("exetest.o");
|
||||
if (!objfile.exists()) {
|
||||
objfile.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/main.o"),false, monitor);
|
||||
|
||||
objfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
|
||||
false, monitor);
|
||||
}
|
||||
objpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.o");
|
||||
|
||||
exefile = testProject.getProject().getFile("test_g");
|
||||
if (!exefile.exists()) {
|
||||
exefile.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/exe_g"),false, monitor);
|
||||
|
||||
exefile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
|
||||
false, monitor);
|
||||
}
|
||||
exepath=new Path(workspace.getRoot().getLocation()+"/filetest/exe_g");
|
||||
|
||||
archfile = testProject.getProject().getFile("libtestlib_g.a");
|
||||
if (!archfile.exists()) {
|
||||
archfile.create(new FileInputStream(pluginRoot+"resources/testlib/x86/a.g/libtestlib_g.a"),false, monitor);
|
||||
|
||||
archfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
|
||||
false, monitor);
|
||||
}
|
||||
libpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.so");
|
||||
|
||||
libfile = testProject.getProject().getFile("libtestlib_g.so");
|
||||
if (!libfile.exists()) {
|
||||
libfile.create(new FileInputStream(pluginRoot+"resources/testlib/x86/so.g/libtestlib_g.so"),false, monitor);
|
||||
|
||||
libfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
|
||||
false, monitor);
|
||||
}
|
||||
archpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.a");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the test fixture.
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.IBinary;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.testplugin.util.ExpectedStrings;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
|
@ -26,7 +27,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
|
||||
|
||||
|
@ -65,7 +65,6 @@ public class BinaryTests extends TestCase {
|
|||
* "com.qnx.tools.ide.cdt.core"
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
String pluginRoot;
|
||||
/***
|
||||
* The tests assume that they have a working workspace
|
||||
* and workspace root object to use to create projects/files in,
|
||||
|
@ -99,58 +98,64 @@ public class BinaryTests extends TestCase {
|
|||
if (testProject==null)
|
||||
fail("Unable to create project");
|
||||
|
||||
pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
|
||||
cfile = testProject.getProject().getFile("exetest.c");
|
||||
if (!cfile.exists()) {
|
||||
cfile.create(new FileInputStream(pluginRoot+"resources/exe/main.c"),false, monitor);
|
||||
|
||||
cfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
|
||||
false, monitor);
|
||||
}
|
||||
cpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.c");
|
||||
|
||||
objfile = testProject.getProject().getFile("exetest.o");
|
||||
if (!objfile.exists()) {
|
||||
objfile.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/main.o"),false, monitor);
|
||||
|
||||
objfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
|
||||
false, monitor);
|
||||
}
|
||||
objpath=new Path(workspace.getRoot().getLocation()+"/filetest/exetest.o");
|
||||
|
||||
exefile = testProject.getProject().getFile("test_g");
|
||||
if (!exefile.exists()) {
|
||||
exefile.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/exe_g"),false, monitor);
|
||||
|
||||
exefile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
|
||||
false, monitor);
|
||||
}
|
||||
exepath=new Path(workspace.getRoot().getLocation()+"/filetest/exe_g");
|
||||
ppcexefile = testProject.getProject().getFile("ppctest_g");
|
||||
if (!ppcexefile.exists()) {
|
||||
ppcexefile.create(new FileInputStream(pluginRoot+"resources/exe/ppc/be.g/exe_g"),false, monitor);
|
||||
|
||||
ppcexefile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/ppc/be.g/exe_g"))),
|
||||
false, monitor);
|
||||
}
|
||||
ndexe = testProject.getProject().getFile("exetest");
|
||||
if (!ndexe.exists()) {
|
||||
ndexe.create(new FileInputStream(pluginRoot+"resources/exe/x86/o/exe"),false, monitor);
|
||||
|
||||
ndexe.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o/exe"))),
|
||||
false, monitor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bigexe = testProject.getProject().getFile("exebig_g");
|
||||
if (!bigexe.exists()) {
|
||||
bigexe.create(new FileInputStream(pluginRoot+"resources/exebig/x86/o.g/exebig_g"),false, monitor);
|
||||
|
||||
bigexe.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exebig/x86/o.g/exebig_g"))),
|
||||
false, monitor);
|
||||
}
|
||||
|
||||
archfile = testProject.getProject().getFile("libtestlib_g.a");
|
||||
if (!archfile.exists()) {
|
||||
archfile.create(new FileInputStream(pluginRoot+"resources/testlib/x86/a.g/libtestlib_g.a"),false, monitor);
|
||||
|
||||
archfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
|
||||
false, monitor);
|
||||
}
|
||||
libpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.so");
|
||||
|
||||
libfile = testProject.getProject().getFile("libtestlib_g.so");
|
||||
if (!libfile.exists()) {
|
||||
libfile.create(new FileInputStream(pluginRoot+"resources/testlib/x86/so.g/libtestlib_g.so"),false, monitor);
|
||||
|
||||
libfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
|
||||
false, monitor);
|
||||
}
|
||||
archpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.a");
|
||||
|
||||
|
|
|
@ -42,9 +42,11 @@ import org.eclipse.cdt.internal.core.model.MethodTemplate;
|
|||
import org.eclipse.cdt.internal.core.model.StructureTemplate;
|
||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class CModelElementsTests extends TestCase {
|
||||
|
@ -64,14 +66,12 @@ public class CModelElementsTests extends TestCase {
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
monitor = new NullProgressMonitor();
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL())
|
||||
.getFile();
|
||||
|
||||
fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
|
||||
headerFile = fCProject.getProject().getFile("CModelElementsTest.h");
|
||||
if (!headerFile.exists()) {
|
||||
try{
|
||||
FileInputStream fileIn = new FileInputStream(pluginRoot+ "resources/cfiles/CModelElementsTestStart.h");
|
||||
FileInputStream fileIn = new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/CModelElementsTestStart.h")));
|
||||
headerFile.create(fileIn,false, monitor);
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.CCProjectNature;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.internal.resources.ResourceException;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -41,7 +42,6 @@ public class CModelTests extends TestCase {
|
|||
IWorkspaceRoot root;
|
||||
IProject project_c, project_cc;
|
||||
NullProgressMonitor monitor;
|
||||
String pluginRoot;
|
||||
|
||||
/**
|
||||
* Constructor for CModelTests.
|
||||
|
@ -73,7 +73,6 @@ public class CModelTests extends TestCase {
|
|||
fail("Workspace was not setup");
|
||||
if (root==null)
|
||||
fail("Workspace root was not setup");
|
||||
pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
desc=workspace.getDescription();
|
||||
desc.setAutoBuilding(false);
|
||||
workspace.setDescription(desc);
|
||||
|
@ -144,8 +143,9 @@ public class CModelTests extends TestCase {
|
|||
|
||||
IFile file = testProject.getProject().getFile("exetest_g");
|
||||
if (!file.exists()) {
|
||||
file.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/exe_g"),false, monitor);
|
||||
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
|
||||
false, monitor);
|
||||
}
|
||||
/***
|
||||
* file should be a binary, executable, not shared or archive
|
||||
|
@ -160,8 +160,9 @@ public class CModelTests extends TestCase {
|
|||
|
||||
file = testProject.getProject().getFile("exetest.c");
|
||||
if (!file.exists()) {
|
||||
file.create(new FileInputStream(pluginRoot+"resources/exe/main.c"),false, monitor);
|
||||
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/main.c"))),
|
||||
false, monitor);
|
||||
}
|
||||
/***
|
||||
* file should be a translation unit
|
||||
|
@ -175,8 +176,9 @@ public class CModelTests extends TestCase {
|
|||
|
||||
file = testProject.getProject().getFile("exetest.o");
|
||||
if (!file.exists()) {
|
||||
file.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/main.o"),false, monitor);
|
||||
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
|
||||
false, monitor);
|
||||
}
|
||||
/***
|
||||
* file should be a object file unit
|
||||
|
@ -190,8 +192,9 @@ public class CModelTests extends TestCase {
|
|||
|
||||
file = testProject.getProject().getFile("liblibtest_g.so");
|
||||
if (!file.exists()) {
|
||||
file.create(new FileInputStream(pluginRoot+"resources/testlib/x86/so.g/libtestlib_g.so"),false, monitor);
|
||||
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
|
||||
false, monitor);
|
||||
}
|
||||
/***
|
||||
* file should be a sharedlib/binary file
|
||||
|
@ -205,8 +208,9 @@ public class CModelTests extends TestCase {
|
|||
|
||||
file = testProject.getProject().getFile("liblibtest_g.a");
|
||||
if (!file.exists()) {
|
||||
file.create(new FileInputStream(pluginRoot+"resources/testlib/x86/a.g/libtestlib_g.a"),false, monitor);
|
||||
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
|
||||
false, monitor);
|
||||
} else {
|
||||
fail("Does not exist?");
|
||||
}
|
||||
|
|
|
@ -33,11 +33,12 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
|
|||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.testplugin.TestPluginLauncher;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* Class for testing the C Element Delta Builder.
|
||||
|
@ -66,15 +67,15 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
monitor = new NullProgressMonitor();
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
|
||||
fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
|
||||
//Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h");
|
||||
headerFile = fCProject.getProject().getFile("WorkingCopyTest.h");
|
||||
if (!headerFile.exists()) {
|
||||
try{
|
||||
FileInputStream fileIn = new FileInputStream(pluginRoot+ "resources/cfiles/WorkingCopyTestStart.h");
|
||||
headerFile.create(fileIn,false, monitor);
|
||||
FileInputStream fileIn = new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/WorkingCopyTestStart.h")));
|
||||
headerFile.create(fileIn,false, monitor);
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
|
|
|
@ -14,10 +14,11 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @author bnicolle
|
||||
|
@ -56,14 +57,12 @@ public abstract class IntegratedCModelTest extends TestCase {
|
|||
|
||||
public void setUp() throws Exception {
|
||||
monitor = new NullProgressMonitor();
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
|
||||
fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
|
||||
|
||||
sourceFile = fCProject.getProject().getFile( getSourcefileResource() );
|
||||
if (!sourceFile.exists()) {
|
||||
try{
|
||||
FileInputStream fileIn = new FileInputStream(pluginRoot+ getSourcefileSubdir() + getSourcefileResource() );
|
||||
FileInputStream fileIn = new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path(getSourcefileSubdir() + getSourcefileResource())));
|
||||
sourceFile.create(fileIn,false, monitor);
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -17,6 +17,7 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.internal.resources.ResourceException;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
|
@ -80,7 +81,6 @@ public class TranslationUnitBaseTest extends TestCase
|
|||
* so we need to get them setup first.
|
||||
*/
|
||||
IWorkspaceDescription desc;
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
workspace= ResourcesPlugin.getWorkspace();
|
||||
root= workspace.getRoot();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
@ -104,36 +104,41 @@ public class TranslationUnitBaseTest extends TestCase
|
|||
|
||||
cfile = testProject.getProject().getFile("exetest.c");
|
||||
if (!cfile.exists()) {
|
||||
cfile.create(new FileInputStream(pluginRoot+"resources/cfiles/TranslationUnits.c"),false, monitor);
|
||||
|
||||
cfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/TranslationUnits.c"))),
|
||||
false, monitor);
|
||||
}
|
||||
cpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.c");
|
||||
|
||||
objfile = testProject.getProject().getFile("exetest.o");
|
||||
if (!objfile.exists()) {
|
||||
objfile.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/main.o"),false, monitor);
|
||||
|
||||
objfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/main.o"))),
|
||||
false, monitor);
|
||||
}
|
||||
objpath=new Path(workspace.getRoot().getLocation()+"/filetest/main.o");
|
||||
|
||||
exefile = testProject.getProject().getFile("test_g");
|
||||
if (!exefile.exists()) {
|
||||
exefile.create(new FileInputStream(pluginRoot+"resources/exe/x86/o.g/exe_g"),false, monitor);
|
||||
|
||||
exefile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/exe/x86/o.g/exe_g"))),
|
||||
false, monitor);
|
||||
}
|
||||
exepath=new Path(workspace.getRoot().getLocation()+"/filetest/exe_g");
|
||||
|
||||
archfile = testProject.getProject().getFile("libtestlib_g.a");
|
||||
if (!archfile.exists()) {
|
||||
archfile.create(new FileInputStream(pluginRoot+"resources/testlib/x86/a.g/libtestlib_g.a"),false, monitor);
|
||||
|
||||
archfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/a.g/libtestlib_g.a"))),
|
||||
false, monitor);
|
||||
}
|
||||
libpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.so");
|
||||
|
||||
libfile = testProject.getProject().getFile("libtestlib_g.so");
|
||||
if (!libfile.exists()) {
|
||||
libfile.create(new FileInputStream(pluginRoot+"resources/testlib/x86/so.g/libtestlib_g.so"),false, monitor);
|
||||
|
||||
libfile.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/testlib/x86/so.g/libtestlib_g.so"))),
|
||||
false, monitor);
|
||||
}
|
||||
archpath=new Path(workspace.getRoot().getLocation()+"/filetest/libtestlib_g.a");
|
||||
|
||||
|
|
|
@ -24,11 +24,12 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
|||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.testplugin.TestPluginLauncher;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* Contains unit test cases for Working Copies. Run using JUnit Plugin Test
|
||||
|
@ -56,14 +57,14 @@ public class WorkingCopyTests extends TestCase {
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
monitor = new NullProgressMonitor();
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
|
||||
|
||||
fCProject= CProjectHelper.createCCProject("TestProject1", "bin");
|
||||
//Path filePath = new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()+ fCProject.getPath().toString()+ "/WorkingCopyTest.h");
|
||||
headerFile = fCProject.getProject().getFile("WorkingCopyTest.h");
|
||||
if (!headerFile.exists()) {
|
||||
try{
|
||||
FileInputStream fileIn = new FileInputStream(pluginRoot+ "resources/cfiles/WorkingCopyTestStart.h");
|
||||
FileInputStream fileIn = new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/cfiles/WorkingCopyTestStart.h")));
|
||||
headerFile.create(fileIn,false, monitor);
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
|||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.testplugin.FileManager;
|
||||
import org.eclipse.core.internal.resources.ResourceException;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -34,7 +35,7 @@ import org.eclipse.core.resources.IWorkspace;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -109,11 +110,12 @@ public class BaseSearchTest extends TestCase implements ICSearchConstants {
|
|||
private void importFile(String fileName, String resourceLocation) throws Exception{
|
||||
//Obtain file handle
|
||||
file = testProject.getProject().getFile(fileName);
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
//Create file input stream
|
||||
|
||||
if (!file.exists()){
|
||||
file.create(new FileInputStream(pluginRoot + resourceLocation),false,monitor);
|
||||
file.create(new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path(resourceLocation))),
|
||||
false,monitor);
|
||||
fileManager.addFile(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,9 @@ import org.eclipse.cdt.internal.core.search.matching.FieldDeclarationPattern;
|
|||
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
|
||||
import org.eclipse.cdt.internal.core.search.matching.NamespaceDeclarationPattern;
|
||||
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
|
@ -318,8 +320,7 @@ public class OtherPatternTests extends BaseSearchTest {
|
|||
}
|
||||
|
||||
public void testNoResourceSearching() throws Exception {
|
||||
String pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
String path = pluginRoot + "resources/search/include.h";
|
||||
String path = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/search/include.h")).getAbsolutePath();
|
||||
|
||||
ICSearchPattern pattern = SearchEngine.createSearchPattern( "Head", CLASS, REFERENCES, true );
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ 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.core.runtime.Platform;
|
||||
import org.eclipse.cdt.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -32,7 +33,6 @@ import org.eclipse.core.runtime.Platform;
|
|||
*/
|
||||
public class ParseTestOnSearchFiles extends TestCase
|
||||
{
|
||||
private String pluginRoot;
|
||||
private FileInputStream fileIn;
|
||||
private String name;
|
||||
/**
|
||||
|
@ -51,9 +51,8 @@ public class ParseTestOnSearchFiles extends TestCase
|
|||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
pluginRoot = Platform.asLocalURL(Platform.getPlugin("org.eclipse.cdt.core.tests").getDescriptor().getInstallURL()).getFile();
|
||||
name = pluginRoot+ "resources/search/classDecl.cpp";
|
||||
fileIn = new FileInputStream(name);
|
||||
name = "resources/search/classDecl.cpp";
|
||||
fileIn = new FileInputStream(CTestPlugin.getDefault().getFileInPlugin(new Path(name)));
|
||||
}
|
||||
|
||||
public void testParseOfAndrewsFile() throws Exception
|
||||
|
|
Loading…
Add table
Reference in a new issue