Skip to content

Commit

Permalink
Merge branch 'v0.17.x_bugfix' into v0.17.x
Browse files Browse the repository at this point in the history
  • Loading branch information
S1artie committed Jul 4, 2018
2 parents b642808 + a1d31b9 commit 4a1b0f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public class ConsoleTestExecutor {
*/
protected WeakHashMap<Thread, Boolean> threadsRunningBeforeTestExecution = new WeakHashMap<Thread, Boolean>();

/**
* Whether to check for zombie threads at the end of test execution.
*/
protected boolean enableZombieThreadWarning;

/**
* Creates a new instance using the default setup class.
*/
Expand Down Expand Up @@ -142,7 +147,7 @@ public void checkForZombieThreads() {

List<Thread> tempZombieThreads = new LinkedList<Thread>();
for (Thread tempThread : tempArray) {
if ((tempThread.getName() != null && tempThread.getName().startsWith("Integrity - "))
if ((tempThread.getName() != null && !tempThread.getName().startsWith("Integrity - "))
&& !threadsRunningBeforeTestExecution.containsKey(tempThread) && tempThread.isAlive()
&& !tempThread.isDaemon()) {
tempZombieThreads.add(tempThread);
Expand All @@ -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);
}
}
}
}
Expand All @@ -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();
}
}
}

Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ private class FilteringStreamCopier extends Thread {
FilteringStreamCopier(String aPrefix, String aThreadName, InputStream aSource, boolean anStdErrFlag,
boolean aFilterForHostAndPortFlag) {
super(aThreadName);
setDaemon(true);
prefix = aPrefix;
source = new BufferedReader(new InputStreamReader(aSource));
stdErr = anStdErrFlag;
Expand Down Expand Up @@ -857,6 +858,7 @@ private class ForkMonitor extends Thread {

ForkMonitor() {
super("Integrity - Fork Monitor Thread");
setDaemon(true);
}

/**
Expand Down

0 comments on commit 4a1b0f5

Please sign in to comment.