diff --git a/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java b/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java index 2365c8f28..885be0a97 100644 --- a/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java +++ b/de.gebit.integrity.runner/src/de/gebit/integrity/runner/console/ConsoleTestExecutor.java @@ -86,6 +86,11 @@ public class ConsoleTestExecutor { */ protected WeakHashMap threadsRunningBeforeTestExecution = new WeakHashMap(); + /** + * Whether to check for zombie threads at the end of test execution. + */ + protected boolean enableZombieThreadWarning; + /** * Creates a new instance using the default setup class. */ @@ -156,6 +161,9 @@ public void checkForZombieThreads() { + "all threads being started during test execution!"); for (Thread tempThread : tempZombieThreads) { getStdOut().println(" Thread #" + tempThread.getId() + ": " + tempThread.getName()); + for (StackTraceElement tempTraceElement : tempThread.getStackTrace()) { + getStdOut().println(" - " + tempTraceElement); + } } } } @@ -174,7 +182,9 @@ public int runWithZombieThreadDetection(String[] someArgs) { return run(someArgs); } finally { // At this point, all threads started by the test run should have finished. - checkForZombieThreads(); + if (enableZombieThreadWarning) { + checkForZombieThreads(); + } } } @@ -220,10 +230,15 @@ public int run(String[] someArgs) { "Sets the seed number to use for the RNG custom operation", "[{--seed} number]"); SimpleCommandLineParser.BooleanOption tempExcludeConsoleStreamsOption = new SimpleCommandLineParser.BooleanOption( null, "noconsole", "Do not capture stdout & stderr for test XML/HTML output", "[{--noconsole}]"); + SimpleCommandLineParser.BooleanOption tempZombieThreadDetectionOption = new SimpleCommandLineParser.BooleanOption( + null, "zombiewarn", "Do warn about threads started during test execution, " + + "but not terminated until the end (zombie threads)", + "[{--zombiewarn}]"); tempParser.addOptions(tempConsoleOption, tempXmlOption, tempXsltOption, tempNameOption, tempVariantOption, tempNoremoteOption, tempRemotePortOption, tempRemoteHostOption, tempWaitForPlayOption, - tempSkipModelCheck, tempParameterizedConstantOption, tempSeedOption, tempExcludeConsoleStreamsOption); + tempSkipModelCheck, tempParameterizedConstantOption, tempSeedOption, tempExcludeConsoleStreamsOption, + tempZombieThreadDetectionOption); if (someArgs.length == 0) { getStdOut().print(tempParser.getHelp(REMAINING_ARGS_HELP)); @@ -244,6 +259,8 @@ public int run(String[] someArgs) { return EXIT_CODE_PARAMETER_ERROR; } + enableZombieThreadWarning = tempZombieThreadDetectionOption.isSet(); + TransformHandling tempTransformHandling = evaluateTransformHandling(tempXsltOption); String tempExecutionName = tempNameOption.getValue("unnamed"); String tempRootSuiteName = getRootSuiteNameFrom(tempRemainingParameters);