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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2009-12-06 20:15:40 +00:00
parent b77877aea8
commit c5ef494d1f
2 changed files with 40 additions and 61 deletions

View file

@ -101,8 +101,7 @@ public class IndexIncludeTest extends IndexTestBase {
try { try {
IIndexBinding[] result= fIndex.findBindings(Pattern.compile(".*included"), true, IndexFilter.ALL, NPM); IIndexBinding[] result= fIndex.findBindings(Pattern.compile(".*included"), true, IndexFilter.ALL, NPM);
assertEquals(all ? 2 : 1, result.length); assertEquals(all ? 2 : 1, result.length);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -132,8 +131,7 @@ public class IndexIncludeTest extends IndexTestBase {
result= fIndex.findBindings("testInclude_cpp".toCharArray(), IndexFilter.ALL, NPM); result= fIndex.findBindings("testInclude_cpp".toCharArray(), IndexFilter.ALL, NPM);
assertEquals(1, result.length); assertEquals(1, result.length);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -159,8 +157,7 @@ public class IndexIncludeTest extends IndexTestBase {
checkInclude(includes[0], content, "user20061107.h", false); checkInclude(includes[0], content, "user20061107.h", false);
checkInclude(includes[1], content, "system20061107.h", true); checkInclude(includes[1], content, "system20061107.h", true);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -183,8 +180,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertEquals(1, includes.length); assertEquals(1, includes.length);
checkInclude(includes[0], content, "header20061107.h", false); checkInclude(includes[0], content, "header20061107.h", false);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -205,8 +201,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertFalse(includes[0].isActive()); assertFalse(includes[0].isActive());
checkInclude(includes[0], content, "inactive20070213.h", false); checkInclude(includes[0], content, "inactive20070213.h", false);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -228,8 +223,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertTrue(includes[0].isActive()); assertTrue(includes[0].isActive());
assertFalse(includes[0].isResolved()); assertFalse(includes[0].isResolved());
checkInclude(includes[0], content, "unresolved20070213.h", false); checkInclude(includes[0], content, "unresolved20070213.h", false);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -259,8 +253,7 @@ public class IndexIncludeTest extends IndexTestBase {
IBinding[] bindings= fIndex.findBindings("ctx_20070404x".toCharArray(), IndexFilter.ALL, NPM); IBinding[] bindings= fIndex.findBindings("ctx_20070404x".toCharArray(), IndexFilter.ALL, NPM);
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof IVariable); assertTrue(bindings[0] instanceof IVariable);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
@ -277,11 +270,9 @@ public class IndexIncludeTest extends IndexTestBase {
IBinding[] bindings= fIndex.findBindings("ctx_20070404y".toCharArray(), IndexFilter.ALL, NPM); IBinding[] bindings= fIndex.findBindings("ctx_20070404y".toCharArray(), IndexFilter.ALL, NPM);
assertEquals(1, bindings.length); assertEquals(1, bindings.length);
assertTrue(bindings[0] instanceof IVariable); assertTrue(bindings[0] instanceof IVariable);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
// #define SOME_MACRO1 ok_1_220358 // #define SOME_MACRO1 ok_1_220358
@ -308,8 +299,7 @@ public class IndexIncludeTest extends IndexTestBase {
IIndexBinding[] binding= fIndex.findBindings("ok_1_220358".toCharArray(), IndexFilter.ALL_DECLARED, NPM); IIndexBinding[] binding= fIndex.findBindings("ok_1_220358".toCharArray(), IndexFilter.ALL_DECLARED, NPM);
assertEquals(1, binding.length); assertEquals(1, binding.length);
assertTrue(binding[0] instanceof IVariable); assertTrue(binding[0] instanceof IVariable);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
@ -321,13 +311,11 @@ public class IndexIncludeTest extends IndexTestBase {
IIndexBinding[] binding= fIndex.findBindings("ok_2_220358".toCharArray(), IndexFilter.ALL_DECLARED, NPM); IIndexBinding[] binding= fIndex.findBindings("ok_2_220358".toCharArray(), IndexFilter.ALL_DECLARED, NPM);
assertEquals(1, binding.length); assertEquals(1, binding.length);
assertTrue(binding[0] instanceof IVariable); assertTrue(binding[0] instanceof IVariable);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
// #include "resolved20070426.h" // #include "resolved20070426.h"
public void testFixedContext() throws Exception { public void testFixedContext() throws Exception {
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
@ -355,8 +343,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath()); assertEquals(s1.getFullPath().toString(), includes[0].getIncludedByLocation().getFullPath());
assertEquals(s2.getFullPath().toString(), includes[1].getIncludedByLocation().getFullPath()); assertEquals(s2.getFullPath().toString(), includes[1].getIncludedByLocation().getFullPath());
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
@ -374,8 +361,7 @@ public class IndexIncludeTest extends IndexTestBase {
IIndexInclude context= ifile.getParsedInContext(); IIndexInclude context= ifile.getParsedInContext();
assertNotNull(context); assertNotNull(context);
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath()); assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
@ -393,8 +379,7 @@ public class IndexIncludeTest extends IndexTestBase {
IIndexInclude context= ifile.getParsedInContext(); IIndexInclude context= ifile.getParsedInContext();
assertNotNull(context); assertNotNull(context);
assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath()); assertEquals(s1.getFullPath().toString(), context.getIncludedByLocation().getFullPath());
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -500,8 +485,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertFalse(includes[2].isActive()); assertFalse(includes[2].isActive());
assertFalse(includes[2].isResolved()); assertFalse(includes[2].isResolved());
assertFalse(includes[2].isSystemInclude()); assertFalse(includes[2].isSystemInclude());
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -532,8 +516,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertFalse(includes[1].isActive()); assertFalse(includes[1].isActive());
assertFalse(includes[1].isResolved()); assertFalse(includes[1].isResolved());
assertTrue(includes[1].isSystemInclude()); assertTrue(includes[1].isSystemInclude());
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -568,8 +551,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertFalse(includes[1].isActive()); assertFalse(includes[1].isActive());
assertFalse(includes[1].isResolved()); assertFalse(includes[1].isResolved());
assertTrue(includes[1].isSystemInclude()); assertTrue(includes[1].isSystemInclude());
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -604,8 +586,7 @@ public class IndexIncludeTest extends IndexTestBase {
assertTrue(includes[1].isActive()); assertTrue(includes[1].isActive());
assertFalse(includes[1].isResolved()); assertFalse(includes[1].isResolved());
assertFalse(includes[1].isSystemInclude()); assertFalse(includes[1].isSystemInclude());
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }

View file

@ -123,7 +123,7 @@ public class BaseTestCase extends TestCase {
final List<IStatus> statusLog= Collections.synchronizedList(new ArrayList()); final List<IStatus> statusLog= Collections.synchronizedList(new ArrayList());
ILogListener logListener= new ILogListener() { ILogListener logListener= new ILogListener() {
public void logging(IStatus status, String plugin) { public void logging(IStatus status, String plugin) {
if(!status.isOK() && status.getSeverity() != IStatus.INFO) { if (!status.isOK() && status.getSeverity() != IStatus.INFO) {
switch (status.getCode()) { switch (status.getCode()) {
case IResourceStatus.NOT_FOUND_LOCAL: case IResourceStatus.NOT_FOUND_LOCAL:
case IResourceStatus.NO_LOCATION_LOCAL: case IResourceStatus.NO_LOCATION_LOCAL:
@ -145,32 +145,32 @@ public class BaseTestCase extends TestCase {
try { try {
try { try {
super.runBare(); super.runBare();
} catch(Throwable e) { } catch (Throwable e) {
testThrowable=e; testThrowable=e;
} }
if(statusLog.size()!=fExpectedLoggedNonOK) { if (statusLog.size()!=fExpectedLoggedNonOK) {
StringBuffer msg= new StringBuffer("Expected number ("+fExpectedLoggedNonOK+") of "); StringBuffer msg= new StringBuffer("Expected number ("+fExpectedLoggedNonOK+") of ");
msg.append("non-OK status objects differs from actual ("+statusLog.size()+").\n"); msg.append("non-OK status objects differs from actual ("+statusLog.size()+").\n");
Throwable cause= null; Throwable cause= null;
if(!statusLog.isEmpty()) { if (!statusLog.isEmpty()) {
for(IStatus status : statusLog) { for (IStatus status : statusLog) {
IStatus[] ss= {status}; IStatus[] ss= {status};
ss= status instanceof MultiStatus ? ((MultiStatus)status).getChildren() : ss; ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;
for(IStatus s : ss) { for (IStatus s : ss) {
msg.append("\t"+s.getMessage()+" "); msg.append("\t" + s.getMessage()+" ");
Throwable t= s.getException(); Throwable t= s.getException();
cause= (cause==null) ? t : cause; cause= cause != null ? cause : t;
if(t != null) { if (t != null) {
msg.append(t.getMessage()!=null ? t.getMessage() : t.getClass().getCanonicalName()); msg.append(t.getMessage() != null ? t.getMessage() : t.getClass().getCanonicalName());
} }
msg.append("\n"); msg.append("\n");
} }
} }
} }
cause= (cause==null) ? testThrowable : cause; cause= cause != null ? cause : testThrowable;
AssertionFailedError afe= new AssertionFailedError(msg.toString()); AssertionFailedError afe= new AssertionFailedError(msg.toString());
afe.initCause(cause); afe.initCause(cause);
throw afe; throw afe;
@ -181,38 +181,36 @@ public class BaseTestCase extends TestCase {
} }
} }
if(testThrowable!=null) if (testThrowable!=null)
throw testThrowable; throw testThrowable;
} }
@Override @Override
public void run( TestResult result ) { public void run(TestResult result) {
if (!fExpectFailure || "true".equals(System.getProperty("SHOW_EXPECTED_FAILURES"))) { if (!fExpectFailure || "true".equals(System.getProperty("SHOW_EXPECTED_FAILURES"))) {
super.run(result); super.run(result);
return; return;
} }
result.startTest( this ); result.startTest(this);
TestResult r = new TestResult(); TestResult r = new TestResult();
super.run( r ); super.run(r);
if (r.failureCount() == 1) { if (r.failureCount() == 1) {
TestFailure failure= (TestFailure) r.failures().nextElement(); TestFailure failure= (TestFailure) r.failures().nextElement();
String msg= failure.exceptionMessage(); String msg= failure.exceptionMessage();
if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) { if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) {
result.addFailure(this, new AssertionFailedError(msg)); result.addFailure(this, new AssertionFailedError(msg));
} }
} } else if (r.errorCount() == 0 && r.failureCount() == 0) {
else if( r.errorCount() == 0 && r.failureCount() == 0 )
{
String err = "Unexpected success of " + getName(); String err = "Unexpected success of " + getName();
if( fBugnumber > 0 ) { if (fBugnumber > 0) {
err += ", bug #" + fBugnumber; err += ", bug #" + fBugnumber;
} }
result.addFailure( this, new AssertionFailedError( err ) ); result.addFailure(this, new AssertionFailedError(err));
} }
result.endTest( this ); result.endTest(this);
} }
public void setExpectFailure(int bugnumber) { public void setExpectFailure(int bugnumber) {
@ -253,12 +251,12 @@ public class BaseTestCase extends TestCase {
public void join() throws CoreException { public void join() throws CoreException {
try { try {
synchronized(changed) { synchronized(changed) {
while(!changed[0]) { while (!changed[0]) {
changed.wait(); changed.wait();
} }
} }
} catch(InterruptedException ie) { } catch (InterruptedException e) {
throw new CoreException(CCorePlugin.createStatus("Interrupted", ie)); throw new CoreException(CCorePlugin.createStatus("Interrupted", e));
} }
} }