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:
parent
843b5f6343
commit
8e12e974ec
2 changed files with 16 additions and 8 deletions
|
@ -56,12 +56,14 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
return suite(IndexLocationTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
cproject= CProjectHelper.createCProject("LocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||
deleteOnTearDown(cproject);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
for(Iterator i= projects.iterator(); i.hasNext(); ) {
|
||||
ICProject ptd= (ICProject) i.next();
|
||||
|
@ -180,6 +182,8 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
public void testSameFileLinkedToOnceInTwoProjects_186214() throws Exception {
|
||||
File location = new File(CProjectHelper.freshDir(),"external2.h");
|
||||
createExternalFile(location, "struct External {};\n");
|
||||
assertTrue(location.isFile());
|
||||
|
||||
IFolder content= cproject.getProject().getFolder("content");
|
||||
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");
|
||||
content2.createLink(new Path(location.getParentFile().getAbsolutePath()), IResource.NONE, null);
|
||||
|
||||
waitForIndexer(cproject2);
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()));
|
||||
waitForIndexer(cproject);
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||
index.acquireReadLock();
|
||||
try {
|
||||
|
@ -210,8 +215,8 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
deleteOnTearDown(emptyCProject);
|
||||
|
||||
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++) {
|
||||
IFile file= cproject.getProject().getFile(paths[i]);
|
||||
for (String path : paths) {
|
||||
IFile file= cproject.getProject().getFile(path);
|
||||
IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file);
|
||||
ResourceContainerRelativeLocationConverter prlc1= new ResourceContainerRelativeLocationConverter(cproject.getProject());
|
||||
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-e/f.g"
|
||||
};
|
||||
URI base = URI.create("file:/" + basePath);
|
||||
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
|
||||
// loc -project-> raw -uri-> loc
|
||||
for(int i=0; i<paths.length; i++) {
|
||||
IFile file= cproject.getProject().getFile(paths[i]);
|
||||
|
@ -290,8 +297,6 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(cproject.getProject());
|
||||
String r1= prlc.toInternalFormat(ifl1);
|
||||
assertNotNull(r1);
|
||||
URI base = URIUtil.toURI(basePath);
|
||||
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
|
||||
IIndexFileLocation ifl2= c1.fromInternalFormat(r1);
|
||||
assertNotNull(ifl2);
|
||||
assertEquals(expectedFullPaths[i], ifl1.getFullPath());
|
||||
|
@ -321,14 +326,14 @@ public class IndexLocationTest extends BaseTestCase {
|
|||
linkedFolder.getFullPath()+"/a b c/d-e/f.g"
|
||||
};
|
||||
// loc -project-> raw -uri-> loc
|
||||
URI base = URI.create("file:/" + basePath);
|
||||
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
|
||||
for(int i=0; i<paths.length; i++) {
|
||||
IFile file= linkedFolder.getFile(paths[i]);
|
||||
IIndexFileLocation ifl1= IndexLocationFactory.getWorkspaceIFL(file);
|
||||
ResourceContainerRelativeLocationConverter prlc= new ResourceContainerRelativeLocationConverter(linkedFolder);
|
||||
String r1= prlc.toInternalFormat(ifl1);
|
||||
assertNotNull(r1);
|
||||
URI base = URIUtil.toURI(basePath);
|
||||
URIRelativeLocationConverter c1 = new URIRelativeLocationConverter(base);
|
||||
IIndexFileLocation ifl2= c1.fromInternalFormat(r1);
|
||||
assertNotNull(ifl2);
|
||||
assertEquals(expectedFullPaths[i], ifl1.getFullPath());
|
||||
|
|
|
@ -40,7 +40,10 @@ public class URIRelativeLocationConverter implements IIndexLocationConverter {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue