mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Fixes occasional failures of selection tests.
This commit is contained in:
parent
c5b863d340
commit
609472bf8f
3 changed files with 21 additions and 18 deletions
|
@ -741,9 +741,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
CodeReader reader;
|
||||
reader = getCodeReader();
|
||||
|
||||
ILanguage language= getLanguage();
|
||||
if (language != null) {
|
||||
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService());
|
||||
if (reader != null) {
|
||||
ILanguage language= getLanguage();
|
||||
if (language != null) {
|
||||
return language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, ParserUtil.getParserLogService());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -109,19 +109,24 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
|
|||
//Obtain file handle
|
||||
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());
|
||||
if (!linkFile.exists()) {
|
||||
linkFile.createNewFile();
|
||||
if (linkFile.exists()) {
|
||||
linkFile.delete();
|
||||
}
|
||||
|
||||
file.createLink(location, IResource.ALLOW_MISSING_LOCAL, null);
|
||||
|
||||
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
||||
//Create file input stream
|
||||
if( file.exists() )
|
||||
file.setContents( stream, false, false, monitor );
|
||||
if( file.exists() ) {
|
||||
long timestamp= file.getLocalTimeStamp();
|
||||
file.setContents( stream, false, false, monitor );
|
||||
if (file.getLocalTimeStamp() == timestamp) {
|
||||
file.setLocalTimeStamp(timestamp+1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
file.create( stream, false, monitor );
|
||||
|
||||
|
|
|
@ -107,12 +107,8 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
|||
}
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
try{
|
||||
project.delete( true, false, monitor );
|
||||
project = null;
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
}
|
||||
CProjectHelper.delete(cPrj);
|
||||
project= null;
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
|
@ -126,7 +122,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
|||
if (members[i].getName().equals(".settings"))
|
||||
continue;
|
||||
try{
|
||||
members[i].delete( false, monitor );
|
||||
members[i].delete( true, monitor );
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
}
|
||||
|
@ -153,7 +149,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
|||
//Obtain file handle
|
||||
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());
|
||||
if (!linkFile.exists()) {
|
||||
|
@ -206,7 +202,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
|||
//Obtain file handle
|
||||
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());
|
||||
if (!linkFile.exists()) {
|
||||
|
@ -655,7 +651,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
|
|||
String code = buffer.toString();
|
||||
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);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue