Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Getting ICElement from junit TestCases

I'm trying to put together some test cases for PTP/PLDT's use of CDT APIs for analysis.

The ICElement returned from IFile.getAdapter(ICElement.class) is null.
Do I have to do something to force the index to be run first in the test setup?
This is in cvsroot/tools/org.eclipse.ptp/tools/org.eclipse.ptp.pldt.tests (and needs o.e.ptp.pldt.common and o.e.ptp.pldt.mpi.core to run), if anyone feels inclined to mess with it.
I looked thru some of org.eclipse.cdt.core.tests but couldn't find where this must be setup in the CDT testcases.

I want to write test cases, I really do!!!

public void testMPIartifacts() throws Exception {
IFile file = importFile("resources", "testMPI.c");
assertNotNull(file);

IFile mpiInclude = importFile("resources/includes","mpi.h");
assertNotNull(mpiInclude);

project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

String tempPath = mpiInclude.getFullPath().toOSString();//includePath= /RegressionTestProject/mpi.h
System.out.println("tempPath="+tempPath);
String includePath = mpiInclude.getWorkspace().getRoot().getRawLocation().toOSString()
+ mpiInclude.getFullPath().toFile().getAbsolutePath();
System.out.println("includePath= "+includePath);

assertTrue(file instanceof IAdaptable);
// ICElement covers folders and translationunits
     // ICElement is always null here!!
final ICElement ce = (ICElement) ((IAdaptable) file).getAdapter(ICElement.class);
assertNotNull(ce);
List<String> includes = Arrays.asList(new String[] {includePath});
RunAnalyseMPIcommandHandler racm = new RunAnalyseMPIcommandHandler();

racm.runResource(new NullProgressMonitor(), ce, 0, includes);

IMarker[] markers=file.findMarkers(MpiIDs.MARKER_ID, true, IResource.DEPTH_INFINITE);
assertNotNull(markers);
System.out.println("numMarkers: "+markers.length);
for (int i = 0; i < markers.length; i++) {
IMarker marker = markers[i];
System.out.println(i+ " marker: "+marker.toString());


}


...Beth

Beth Tibbitts (859) 243-4981 (TL 545-4981)
Eclipse Parallel Tools Platform http://eclipse.org/ptp
Mailing Address: IBM Corp., Coldstream Research Campus, 745 West New Circle Road, Lexington, KY 40511


Back to the top