mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 453275 - Codan tests cannot test for checkers throwing an exception
Added system flag that is used to propagate exception instead of swallowing. Set by default in codan junit tests. Change-Id: Iccda9a7b2e419192bb9f4eec4b89d525e152fc81 Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com> Reviewed-on: https://git.eclipse.org/r/37482
This commit is contained in:
parent
c6865cfb7d
commit
863def95be
3 changed files with 23 additions and 21 deletions
|
@ -78,6 +78,8 @@ public class CodanTestCase extends BaseTestCase {
|
||||||
removeLeftOverProjects();
|
removeLeftOverProjects();
|
||||||
cproject = createProject(isCpp());
|
cproject = createProject(isCpp());
|
||||||
tmpDir = cproject.getProject().getLocation().makeAbsolute().toFile();
|
tmpDir = cproject.getProject().getLocation().makeAbsolute().toFile();
|
||||||
|
// this make CodanRunner to propagate all exceptions it normally just logs
|
||||||
|
System.setProperty("codan.rethrow", "true"); // test can override setUp and unset this
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -95,6 +95,8 @@ public class CodanCorePlugin extends Plugin {
|
||||||
* @noreference This method is not intended to be referenced by clients.
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
public static void log(Throwable e) {
|
public static void log(Throwable e) {
|
||||||
|
if (Boolean.valueOf(System.getProperty("codan.rethrow"))) //$NON-NLS-1$
|
||||||
|
throw new RuntimeException(e);
|
||||||
log("Internal Error", e); //$NON-NLS-1$
|
log("Internal Error", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ public class CodanRunner {
|
||||||
ICheckerInvocationContext context = new CheckerInvocationContext(resource);
|
ICheckerInvocationContext context = new CheckerInvocationContext(resource);
|
||||||
try {
|
try {
|
||||||
for (IChecker checker : chegistry) {
|
for (IChecker checker : chegistry) {
|
||||||
try {
|
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) {
|
if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) {
|
||||||
|
@ -89,6 +88,10 @@ public class CodanRunner {
|
||||||
} else {
|
} else {
|
||||||
checker.processResource(resource, context);
|
checker.processResource(resource, context);
|
||||||
}
|
}
|
||||||
|
} catch (OperationCanceledException e) {
|
||||||
|
return;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CodanCorePlugin.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName());
|
CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName());
|
||||||
checker.after(resource);
|
checker.after(resource);
|
||||||
|
@ -96,11 +99,6 @@ public class CodanRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
} catch (OperationCanceledException e) {
|
|
||||||
return;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
CodanCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
context.dispose();
|
context.dispose();
|
||||||
|
|
Loading…
Add table
Reference in a new issue