aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Simetsreiter <[email protected]>2022-11-16 13:00:36 +0100
committerTobias Simetsreiter <[email protected]>2022-11-16 13:00:36 +0100
commitae193c08c3bfbef3e144c427f647fdf8b77aad98 (patch)
treee486404cd70b3ac23530a059c8daf0fd649e76ae
parent980a278cccd342510f5d8513f1e05b15dcfc84a7 (diff)
downloadziglings-ae193c08c3bfbef3e144c427f647fdf8b77aad98.tar.xz
ziglings-ae193c08c3bfbef3e144c427f647fdf8b77aad98.zip
exclude trailing newlines and spaces
-rw-r--r--build.zig16
1 files changed, 9 insertions, 7 deletions
diff --git a/build.zig b/build.zig
index 4a67266..8be7ea3 100644
--- a/build.zig
+++ b/build.zig
@@ -54,12 +54,12 @@ const Exercise = struct {
const exercises = [_]Exercise{
.{
.main_file = "001_hello.zig",
- .output = "Hello world",
+ .output = "Hello world!",
.hint = "DON'T PANIC!\nRead the error above.\nSee how it has something to do with 'main'?\nOpen up the source file as noted and read the comments.\nYou can do this!",
},
.{
.main_file = "002_std.zig",
- .output = "Standard Library",
+ .output = "Standard Library.",
},
.{
.main_file = "003_assignment.zig",
@@ -420,7 +420,7 @@ const exercises = [_]Exercise{
},
.{
.main_file = "084_async.zig",
- .output = "foo() A",
+ .output = "foo() A\nfoo() B",
.hint = "Read the facts. Use the facts.",
.@"async" = true,
},
@@ -682,17 +682,19 @@ const ZiglingStep = struct {
},
}
+ const trimOutput = std.mem.trimRight(u8, output, " \r\n");
+ const trimExerciseOutput = std.mem.trimRight(u8, self.exercise.output, " \r\n");
// validate the output
- if (std.mem.indexOf(u8, output, self.exercise.output) == null or output.len != self.exercise.output.len) {
+ if (std.mem.indexOf(u8, trimOutput, trimExerciseOutput) == null or trimOutput.len != trimExerciseOutput.len) {
print(
\\
\\{s}----------- Expected this output -----------{s}
- \\{s}
+ \\"{s}"
\\{s}----------- but found -----------{s}
- \\{s}
+ \\"{s}"
\\{s}-----------{s}
\\
- , .{ red_text, reset_text, self.exercise.output, red_text, reset_text, output, red_text, reset_text });
+ , .{ red_text, reset_text, trimExerciseOutput, red_text, reset_text, trimOutput, red_text, reset_text });
return error.InvalidOutput;
}