Commit 7fd86439 authored by Alexander's avatar Alexander

Daily Release 17.03.2018

parents 727d9672 c832cc04
......@@ -26,6 +26,13 @@ public final class Terminal {
public static boolean useMyErrorMessagesInTestCreation = true;
private static StringBuilder testPairFile = new StringBuilder();
/**
* Progressbar stuff
*/
private static boolean showTestProgress = false;
private static int inputCount = 1;
private static int numInput = 0;
private static long time = 0;
/**
* This field represents the input from a test to a tested program
*/
......@@ -148,6 +155,18 @@ public final class Terminal {
throw new RuntimeException(e);
}
else {
if (showTestProgress) {
numInput++;
if (numInput % (inputCount / 100) == 0) {
long t = System.nanoTime();
System.out.printf("%03d%% +%.2f ms%n", Math.round((double) numInput / inputCount * 100.0)
, (t - time) / 1000000.0);
time = t;
if (numInput == inputCount) {
System.out.println();
}
}
}
//If the program outputted nothing we still have null which means "no output"
OUT_TEST.add(null);
......@@ -239,4 +258,11 @@ public final class Terminal {
useMyErrorMessagesInTestCreation = !doNotUseMyErrorMessages;
startTestCreation(args);
}
public static void setupShowProgress(boolean showTestProgress, int inputCount) {
Terminal.showTestProgress = showTestProgress;
Terminal.inputCount = inputCount;
Terminal.numInput = 0;
time = System.nanoTime();
}
}
......@@ -29,6 +29,7 @@ public class PerformanceTest extends Assignment2TestBase {
@Test
@DisplayName("PerformanceTest2")
void performanceTest2() {
enableShowTestProgress();
String path = getDataFolderDirectory() + "performance/performance_test_2.io";
TestPair[] pairs = loadTestPairsFromIOFile(path);
enablePerformanceTest();
......@@ -39,6 +40,7 @@ public class PerformanceTest extends Assignment2TestBase {
@Test
@DisplayName("PerformanceTest3")
void performanceTest3() {
enableShowTestProgress();
String path = getDataFolderDirectory() + "performance/performance_test_3.io";
TestPair[] pairs = loadTestPairsFromIOFile(path);
enablePerformanceTest();
......
......@@ -38,6 +38,7 @@ public abstract class TestBase {
private String testName;
private boolean alwaysShowLog;
private boolean showAllProgramOutput = false;
private boolean showTestProgress;
/**
* Initializes testing
......@@ -57,6 +58,7 @@ public abstract class TestBase {
protected void initTest(TestInfo testInfo) {
alwaysShowLog = false;
testPassed = false;
showTestProgress = false;
testName = testInfo.getDisplayName();
log = Logger.getLogger(testInfo.getClass().getName());
log.setUseParentHandlers(false);
......@@ -199,6 +201,7 @@ public abstract class TestBase {
}
pushProgramInput("quit");
Terminal.setupShowProgress(showTestProgress, Terminal.IN_TEST.size());
testedMethod.run();
for (TestPair testPair : testPairs) {
......@@ -206,7 +209,7 @@ public abstract class TestBase {
assert !Terminal.OUT_TEST.isEmpty()
: "got no output, this should never happen, since this is handled by the Terminal";
String output = popProgramOutput();
switch (testPair.getType()) {
......@@ -366,4 +369,11 @@ public abstract class TestBase {
protected void enableShowAllProgramOutput() {
this.showAllProgramOutput = true;
}
/**
* Shows a progress-bar for this test
*/
protected void enableShowTestProgress() {
showTestProgress = true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment