1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 15:25:49 +02:00

Fixes occasional failures of selection tests.

This commit is contained in:
Markus Schorn 2007-03-14 15:59:39 +00:00
parent c5b863d340
commit 609472bf8f
3 changed files with 21 additions and 18 deletions

View file

@ -741,9 +741,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
CodeReader reader; CodeReader reader;
reader = getCodeReader(); reader = getCodeReader();
ILanguage language= getLanguage(); if (reader != null) {
if (language != null) { ILanguage language= getLanguage();
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService()); if (language != null) {
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService());
}
} }
return null; return null;
} }

View file

@ -109,19 +109,24 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
//Obtain file handle //Obtain file handle
IFile file = fCProject.getProject().getFile(fileName); IFile file = fCProject.getProject().getFile(fileName);
IPath location = new Path(fCProject.getProject().getLocation().removeLastSegments(1).toOSString() + File.separator + fileName); //$NON-NLS-1$ IPath location = new Path(fCProject.getProject().getLocation().removeLastSegments(1).toOSString() + File.separator + fileName);
File linkFile = new File(location.toOSString()); File linkFile = new File(location.toOSString());
if (!linkFile.exists()) { if (linkFile.exists()) {
linkFile.createNewFile(); linkFile.delete();
} }
file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null); file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null);
InputStream stream = new ByteArrayInputStream( contents.getBytes() ); InputStream stream = new ByteArrayInputStream( contents.getBytes() );
//Create file input stream //Create file input stream
if( file.exists() ) if( file.exists() ) {
file.setContents( stream, false, false, monitor ); long timestamp= file.getLocalTimeStamp();
file.setContents( stream, false, false, monitor );
if (file.getLocalTimeStamp() == timestamp) {
file.setLocalTimeStamp(timestamp+1000);
}
}
else else
file.create( stream, false, monitor ); file.create( stream, false, monitor );

View file

@ -107,12 +107,8 @@ public class CSelectionTestsNoIndexer extends TestCase {
} }
public void cleanupProject() throws Exception { public void cleanupProject() throws Exception {
try{ CProjectHelper.delete(cPrj);
project.delete( true, false, monitor ); project= null;
project = null;
} catch( Throwable e ){
/*boo*/
}
} }
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
@ -126,7 +122,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
if (members[i].getName().equals(".settings")) if (members[i].getName().equals(".settings"))
continue; continue;
try{ try{
members[i].delete( false, monitor ); members[i].delete( true, monitor );
} catch( Throwable e ){ } catch( Throwable e ){
/*boo*/ /*boo*/
} }
@ -153,7 +149,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
//Obtain file handle //Obtain file handle
IFile file = project.getProject().getFile(fileName); IFile file = project.getProject().getFile(fileName);
IPath location = new Path(project.getLocation().removeLastSegments(1).toOSString() + File.separator + fileName); //$NON-NLS-1$ IPath location = new Path(project.getLocation().removeLastSegments(1).toOSString() + File.separator + fileName);
File linkFile = new File(location.toOSString()); File linkFile = new File(location.toOSString());
if (!linkFile.exists()) { if (!linkFile.exists()) {
@ -206,7 +202,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
//Obtain file handle //Obtain file handle
IFile file = project.getProject().getFile(fileName); IFile file = project.getProject().getFile(fileName);
IPath location = new Path(folder.getLocation().toOSString() + File.separator + fileName); //$NON-NLS-1$ IPath location = new Path(folder.getLocation().toOSString() + File.separator + fileName);
File linkFile = new File(location.toOSString()); File linkFile = new File(location.toOSString());
if (!linkFile.exists()) { if (!linkFile.exists()) {
@ -655,7 +651,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
String code = buffer.toString(); String code = buffer.toString();
IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$ IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$
int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$ int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$
IASTNode decl = testF3(file, offset); IASTNode decl = testF3(file, offset);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$ assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$