Skip to content

Commit f1417d4

Browse files
author
Julien Letrouit
committed
Deactivate loop detection in case of Koans using std in
1 parent 8bd2c2d commit f1417d4

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/java/engine/KoanTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ public String[] stdInInputs(final Locale locale) {
5454
public void setupRandomForKoan() {
5555
Helpers.setupRandomForKoan(seed);
5656
}
57+
58+
public boolean hasStdInputs() {
59+
return stdInInputs.size() > 0;
60+
}
5761
}

src/main/java/engine/Sensei.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ private boolean offerTest(KoanTest test, int successfulCount) {
100100
thread.setDaemon(true);
101101
thread.start();
102102
try {
103-
thread.join(TIMEOUT_INFINITE_LOOPS_MS);
104-
//thread.join();
103+
if (test.hasStdInputs()) {
104+
// Can't detect infinite loop when the user has to enter data through the console, because we don't know how much time to wait for.
105+
thread.join();
106+
} else {
107+
thread.join(TIMEOUT_INFINITE_LOOPS_MS);
108+
}
105109
}
106110
catch(InterruptedException ie) {
107111
throw new IllegalStateException(String.format("Something very weird happened. We should not have been interrupted: %s.", ie.getMessage()));

0 commit comments

Comments
 (0)