1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

Updated testcase for bug 179322.

This commit is contained in:
Markus Schorn 2007-03-27 07:28:09 +00:00
parent a197545748
commit ea528b7933

View file

@ -16,9 +16,6 @@ import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import junit.framework.TestSuite; import junit.framework.TestSuite;
@ -47,9 +44,7 @@ import org.eclipse.cdt.core.index.IIndexMacro;
import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
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.CTestPlugin;
@ -87,6 +82,8 @@ public class IndexBugsTests extends BaseTestCase {
} }
protected void tearDown() throws CoreException { protected void tearDown() throws CoreException {
TestScannerProvider.sIncludeFiles= TestScannerProvider.sIncludes=
TestScannerProvider.sMacroFiles= null;
if (fCProject != null) { if (fCProject != null) {
CProjectHelper.delete(fCProject); CProjectHelper.delete(fCProject);
} }
@ -208,61 +205,51 @@ public class IndexBugsTests extends BaseTestCase {
public void test164360_1() throws Exception { public void test164360_1() throws Exception {
waitForIndexer(); waitForIndexer();
try { IFile include= TestSourceReader.createFile(fCProject.getProject(), "test164360.h", "");
IFile include= TestSourceReader.createFile(fCProject.getProject(), "test164360.h", ""); TestScannerProvider.sIncludeFiles= new String[]{include.getLocation().toOSString()};
TestScannerProvider.sIncludeFiles= new String[]{include.getLocation().toOSString()}; IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", "");
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", ""); TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
fIndex.acquireReadLock(); fIndex.acquireReadLock();
try { try {
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file)); IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
assertNotNull(ifile); assertNotNull(ifile);
IIndexInclude[] includes= ifile.getIncludes(); IIndexInclude[] includes= ifile.getIncludes();
assertEquals(1, includes.length); assertEquals(1, includes.length);
IIndexInclude i= includes[0]; IIndexInclude i= includes[0];
assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI()); assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI());
assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI()); assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI());
assertEquals(true, i.isSystemInclude()); assertEquals(true, i.isSystemInclude());
assertEquals(0, i.getNameOffset()); assertEquals(0, i.getNameOffset());
assertEquals(0, i.getNameLength()); assertEquals(0, i.getNameLength());
}
finally {
fIndex.releaseReadLock();
}
} }
finally { finally {
TestScannerProvider.sIncludeFiles= null; fIndex.releaseReadLock();
} }
} }
public void test164360_2() throws Exception { public void test164360_2() throws Exception {
waitForIndexer(); waitForIndexer();
try { IFile include= TestSourceReader.createFile(fCProject.getProject(), "test164360.h", "");
IFile include= TestSourceReader.createFile(fCProject.getProject(), "test164360.h", ""); TestScannerProvider.sMacroFiles= new String[]{include.getLocation().toOSString()};
TestScannerProvider.sMacroFiles= new String[]{include.getLocation().toOSString()}; IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", "");
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164360.cpp", ""); TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
fIndex.acquireReadLock(); fIndex.acquireReadLock();
try { try {
IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file)); IIndexFile ifile= fIndex.getFile(IndexLocationFactory.getWorkspaceIFL(file));
assertNotNull(ifile); assertNotNull(ifile);
IIndexInclude[] includes= ifile.getIncludes(); IIndexInclude[] includes= ifile.getIncludes();
assertEquals(1, includes.length); assertEquals(1, includes.length);
IIndexInclude i= includes[0]; IIndexInclude i= includes[0];
assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI()); assertEquals(file.getLocationURI(), i.getIncludedByLocation().getURI());
assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI()); assertEquals(include.getLocationURI(), i.getIncludesLocation().getURI());
assertEquals(true, i.isSystemInclude()); assertEquals(true, i.isSystemInclude());
assertEquals(0, i.getNameOffset()); assertEquals(0, i.getNameOffset());
assertEquals(0, i.getNameLength()); assertEquals(0, i.getNameLength());
}
finally {
fIndex.releaseReadLock();
}
} }
finally { finally {
TestScannerProvider.sMacroFiles= null; fIndex.releaseReadLock();
} }
} }
@ -549,24 +536,26 @@ public class IndexBugsTests extends BaseTestCase {
* Linked headers, referenced via include <> syntax are missed * Linked headers, referenced via include <> syntax are missed
*/ */
public void _test179322() throws Exception { public void _test179322() throws Exception {
String baseDir= FileLocator.toFileURL(FileLocator.find(CTestPlugin.getDefault().getBundle(), new Path("/resources/indexTests/bugs/179322"), null)).getFile(); String baseDir= FileLocator.toFileURL(FileLocator.find(CTestPlugin.getDefault().getBundle(), new Path("/resources/indexTests/bugs/179322"), null)).getFile();
IFolder content= fCProject.getProject().getFolder("content"); IFolder content= fCProject.getProject().getFolder("content");
content.createLink(new Path(baseDir), IResource.NONE, null); content.createLink(new Path(baseDir), IResource.NONE, null);
// List entries= new ArrayList(Arrays.asList(CoreModel.getRawPathEntries(fCProject)));
// entries.add(
// CoreModel.newIncludeEntry(fCProject.getPath(),
// null, content.getLocation(), true));
// entries.add(
// CoreModel.newIncludeEntry(fCProject.getPath(),
// null, content.getLocation(), false));
// entries.add(CoreModel.newSourceEntry(content.getProjectRelativePath()));
// fCProject.setRawPathEntries(
// (IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]),
// new NullProgressMonitor()
// );
// Setup path entries TestScannerProvider.sIncludes= new String[] {
List entries= new ArrayList(Arrays.asList(CoreModel.getRawPathEntries(fCProject))); content.getLocation().toString()
entries.add( };
CoreModel.newIncludeEntry(fCProject.getPath(),
null, content.getLocation(), true));
entries.add(
CoreModel.newIncludeEntry(fCProject.getPath(),
null, content.getLocation(), false));
entries.add(CoreModel.newSourceEntry(content.getProjectRelativePath()));
fCProject.setRawPathEntries(
(IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]),
new NullProgressMonitor()
);
CCorePlugin.getIndexManager().reindex(fCProject); CCorePlugin.getIndexManager().reindex(fCProject);
CCorePlugin.getIndexManager().joinIndexer(10000, NPM); CCorePlugin.getIndexManager().joinIndexer(10000, NPM);