1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for JUnit failures.

This commit is contained in:
Markus Schorn 2010-05-05 11:50:56 +00:00
parent 843b5f6343
commit 8e12e974ec
2 changed files with 16 additions and 8 deletions

View file

@ -56,12 +56,14 @@ public class IndexLocationTest extends BaseTestCase {
return suite(IndexLocationTest.class); return suite(IndexLocationTest.class);
} }
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
cproject= CProjectHelper.createCProject("LocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER); cproject= CProjectHelper.createCProject("LocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
deleteOnTearDown(cproject); deleteOnTearDown(cproject);
} }
@Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
for(Iterator i= projects.iterator(); i.hasNext(); ) { for(Iterator i= projects.iterator(); i.hasNext(); ) {
ICProject ptd= (ICProject) i.next(); ICProject ptd= (ICProject) i.next();
@ -180,6 +182,8 @@ public class IndexLocationTest extends BaseTestCase {
public void testSameFileLinkedToOnceInTwoProjects_186214() throws Exception { public void testSameFileLinkedToOnceInTwoProjects_186214() throws Exception {
File location = new File(CProjectHelper.freshDir(),"external2.h"); File location = new File(CProjectHelper.freshDir(),"external2.h");
createExternalFile(location, "struct External {};\n"); createExternalFile(location, "struct External {};\n");
assertTrue(location.isFile());
IFolder content= cproject.getProject().getFolder("content"); IFolder content= cproject.getProject().getFolder("content");
content.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null); content.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null);
@ -189,8 +193,9 @@ public class IndexLocationTest extends BaseTestCase {
IFolder content2= cproject2.getProject().getFolder("content"); IFolder content2= cproject2.getProject().getFolder("content");
content2.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null); content2.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null);
waitForIndexer(cproject2);
CCorePlugin.getIndexManager().reindex(cproject); CCorePlugin.getIndexManager().reindex(cproject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor())); waitForIndexer(cproject);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject); IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock(); index.acquireReadLock();
try { try {
@ -210,8 +215,8 @@ public class IndexLocationTest extends BaseTestCase {
deleteOnTearDown(emptyCProject); deleteOnTearDown(emptyCProject);
String[] paths = new String[] {"this.cpp", "inc/header.h", "a b c/d/e f/g.h", "a \\b /c.d"}; String[] paths = new String[] {"this.cpp", "inc/header.h", "a b c/d/e f/g.h", "a \\b /c.d"};
for(int i=0; i<paths.length; i++) { for (String path : paths) {
IFile file= cproject.getProject().getFile(paths[i]); IFile file= cproject.getProject().getFile(path);
IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file); IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file);
ResourceContainerRelativeLocationConverter prlc1= new ResourceContainerRelativeLocationConverter(cproject.getProject()); ResourceContainerRelativeLocationConverter prlc1= new ResourceContainerRelativeLocationConverter(cproject.getProject());
String r1= prlc1.toInternalFormat(ifl1); String r1= prlc1.toInternalFormat(ifl1);
@ -283,6 +288,8 @@ public class IndexLocationTest extends BaseTestCase {
"/"+cproject.getProject().getName()+"/a /b /c.d", "/"+cproject.getProject().getName()+"/a /b /c.d",
"/"+cproject.getProject().getName()+"/a b c/d-e/f.g" "/"+cproject.getProject().getName()+"/a b c/d-e/f.g"
}; };
URI base = URI.create("file:/" + basePath);
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
// loc -project-> raw -uri-> loc // loc -project-> raw -uri-> loc
for(int i=0; i<paths.length; i++) { for(int i=0; i<paths.length; i++) {
IFile file= cproject.getProject().getFile(paths[i]); IFile file= cproject.getProject().getFile(paths[i]);
@ -290,8 +297,6 @@ public class IndexLocationTest extends BaseTestCase {
ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(cproject.getProject()); ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(cproject.getProject());
String r1= prlc.toInternalFormat(ifl1); String r1= prlc.toInternalFormat(ifl1);
assertNotNull(r1); assertNotNull(r1);
URI base = URIUtil.toURI(basePath);
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
IIndexFileLocation ifl2= c1.fromInternalFormat(r1); IIndexFileLocation ifl2= c1.fromInternalFormat(r1);
assertNotNull(ifl2); assertNotNull(ifl2);
assertEquals(expectedFullPaths[i], ifl1.getFullPath()); assertEquals(expectedFullPaths[i], ifl1.getFullPath());
@ -321,14 +326,14 @@ public class IndexLocationTest extends BaseTestCase {
linkedFolder.getFullPath()+"/a b c/d-e/f.g" linkedFolder.getFullPath()+"/a b c/d-e/f.g"
}; };
// loc -project-> raw -uri-> loc // loc -project-> raw -uri-> loc
URI base = URI.create("file:/" + basePath);
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
for(int i=0; i<paths.length; i++) { for(int i=0; i<paths.length; i++) {
IFile file= linkedFolder.getFile(paths[i]); IFile file= linkedFolder.getFile(paths[i]);
IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file); IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file);
ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(linkedFolder); ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(linkedFolder);
String r1= prlc.toInternalFormat(ifl1); String r1= prlc.toInternalFormat(ifl1);
assertNotNull(r1); assertNotNull(r1);
URI base = URIUtil.toURI(basePath);
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
IIndexFileLocation ifl2= c1.fromInternalFormat(r1); IIndexFileLocation ifl2= c1.fromInternalFormat(r1);
assertNotNull(ifl2); assertNotNull(ifl2);
assertEquals(expectedFullPaths[i], ifl1.getFullPath()); assertEquals(expectedFullPaths[i], ifl1.getFullPath());

View file

@ -40,7 +40,10 @@ public class URIRelativeLocationConverter implements IIndexLocationConverter {
} }
public IIndexFileLocation fromInternalFormat(String raw) { public IIndexFileLocation fromInternalFormat(String raw) {
URI uri= baseURI.resolve(URIUtil.toURI(raw).getRawPath().substring(1)); String rawPath = URIUtil.toURI(raw).getRawPath();
if (rawPath.length() > 0 && rawPath.charAt(0) == '/')
rawPath= rawPath.substring(1);
URI uri= baseURI.resolve(rawPath);
return new IndexFileLocation(uri, null); return new IndexFileLocation(uri, null);
} }