diff --git a/test/acceptance/fixture/LispInterpreterFixture.java b/test/acceptance/fixture/LispInterpreterFixture.java index a4b759a..bb4f0d2 100644 --- a/test/acceptance/fixture/LispInterpreterFixture.java +++ b/test/acceptance/fixture/LispInterpreterFixture.java @@ -17,7 +17,7 @@ public class LispInterpreterFixture { private static LispInterpreter interpreter = null; public static void buildInterpreter() { - LispInterpreterBuilder builder = LispInterpreterBuilderImpl.getInstance(); + LispInterpreterBuilder builder = new LispInterpreterBuilderImpl() {}; builder.setOutput(new PrintStream(outputStream)); builder.setErrorOutput(new PrintStream(outputStream)); builder.setNotInteractive(); diff --git a/test/main/MainTest.java b/test/main/MainTest.java index 462dd75..03e32c8 100644 --- a/test/main/MainTest.java +++ b/test/main/MainTest.java @@ -41,9 +41,12 @@ public class MainTest { latch = new CountDownLatch(1); new Thread(() -> { - LispMain main = new LispMain(new LispInterpreterBuilderImpl() {}, terminal.getConfiguration()); - main.runInteractive(); - latch.countDown(); + try { + LispMain main = new LispMain(new LispInterpreterBuilderImpl() {}, terminal.getConfiguration()); + main.runInteractive(); + } finally { + latch.countDown(); + } }).start(); return terminal; @@ -121,8 +124,11 @@ public class MainTest { } @Test - public void defaultConstructorCoverage() { - new LispMain(); + public void runMain() { + LispMain.main(new String[] { "test/main/test-files/file.lisp" }); + + assertEquals("", getSystemErrLog()); + assertEquals(format("{0}{1}{2}\n\n", ANSI_GREEN, "RADISH", ANSI_RESET), getSystemOutLog()); } } diff --git a/test/terminal/FlushListener.java b/test/terminal/FlushListener.java index a754875..8d7c377 100644 --- a/test/terminal/FlushListener.java +++ b/test/terminal/FlushListener.java @@ -12,12 +12,12 @@ public class FlushListener implements VirtualTerminalListener { this.flushCount = 0; } - public int getFlushCount() { + public synchronized int getFlushCount() { return flushCount; } - public void resetFlushCount() { - flushCount = 0; + public synchronized void reduceFlushCount(int reduction) { + flushCount -= reduction; } @Override diff --git a/test/terminal/VirtualTerminalInteractor.java b/test/terminal/VirtualTerminalInteractor.java index e72ee18..f916dca 100644 --- a/test/terminal/VirtualTerminalInteractor.java +++ b/test/terminal/VirtualTerminalInteractor.java @@ -110,7 +110,7 @@ public class VirtualTerminalInteractor { while (flushListener.getFlushCount() < flushCount) flushListener.wait(); - flushListener.resetFlushCount(); + flushListener.reduceFlushCount(flushCount); } } catch (InterruptedException ignored) {} }