aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/backends
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-10-22 23:18:17 +0100
committerMichael Williamson <mike@zwobble.org>2023-10-22 23:18:17 +0100
commitc87ffcbab5927c660d339d3b47b75acb50deb085 (patch)
treed1bcebfdc82565179fd8718bea37c1dae6bca3b8 /src/test/java/org/shedlang/compiler/backends
parent9c35257a360c8bea20e766b44da7eb4897a223b3 (diff)
Check that main function is present
Diffstat (limited to 'src/test/java/org/shedlang/compiler/backends')
-rw-r--r--src/test/java/org/shedlang/compiler/backends/ExampleTests.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/ExampleTests.java b/src/test/java/org/shedlang/compiler/backends/ExampleTests.java
index 037041f3..adfdf5d8 100644
--- a/src/test/java/org/shedlang/compiler/backends/ExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/ExampleTests.java
@@ -31,19 +31,23 @@ public abstract class ExampleTests {
var backend = backend();
var compiler = new ShedCompiler();
- try {
- compiler.compile(exampleDirectory.toPath(), backend);
- } catch (CompilerError error) {
- System.err.println(error.source().describe());
- throw error;
- }
-
-
var config = ProjectConfig.read(exampleDirectory.toPath());
for (var example : config.examples()) {
+ try {
+ compiler.compile(exampleDirectory.toPath(), backend);
+ } catch (CompilerError error) {
+ if (example.expectedError().isPresent()) {
+ assertThat(error.getMessage(), equalTo(example.expectedError().get()));
+ return;
+ }
+
+ System.err.println(error.source().describe());
+ throw error;
+ }
+
var binPath = config.targetDir().resolve(backend.name()).resolve(example.bin()).toString();
var result = runExampleBinary(binPath).throwOnError();
- assertThat(result.stdout(), equalTo(example.expectedOutput()));
+ assertThat(result.stdout(), equalTo(example.expectedOutput().orElseThrow()));
}
}
));