diff options
| author | Chris Boesch <[email protected]> | 2023-05-18 12:14:14 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-18 12:14:14 +0200 |
| commit | 282c50834a9b5945f920d3cb9514b2b203e04282 (patch) | |
| tree | 1557928b4f3cac3c87be10eda2a941899bef8b62 /test/tests.zig | |
| parent | 3dafa3518b9a9309de101abe225266a279a23a8c (diff) | |
| parent | 54d51869828ff6634e5a60805a65741b4436b3e7 (diff) | |
| download | ziglings-282c50834a9b5945f920d3cb9514b2b203e04282.tar.xz ziglings-282c50834a9b5945f920d3cb9514b2b203e04282.zip | |
Merge pull request #305 from perillo/improve-run-test
Improve running tests
Diffstat (limited to 'test/tests.zig')
| -rw-r--r-- | test/tests.zig | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/test/tests.zig b/test/tests.zig index b25b29c..45c075c 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -93,7 +93,7 @@ pub fn addCliTests(b: *std.Build, exercises: []const Exercise) *Step { const case_step = createCase(b, "case-3"); for (exercises[0 .. exercises.len - 1]) |ex| { - if (ex.skip or ex.run_test) continue; + if (ex.skip) continue; if (ex.hint) |hint| { const n = ex.number(); @@ -249,21 +249,6 @@ fn check_output(step: *Step, exercise: Exercise, reader: Reader) !void { return; } - if (exercise.run_test) { - { - const actual = try readLine(reader, &buf) orelse "EOF"; - const expect = b.fmt("Testing {s}...", .{exercise.main_file}); - try check(step, exercise, expect, actual); - } - - { - const actual = try readLine(reader, &buf) orelse "EOF"; - try check(step, exercise, "", actual); - } - - return; - } - { const actual = try readLine(reader, &buf) orelse "EOF"; const expect = b.fmt("Compiling {s}...", .{exercise.main_file}); @@ -278,12 +263,19 @@ fn check_output(step: *Step, exercise: Exercise, reader: Reader) !void { { const actual = try readLine(reader, &buf) orelse "EOF"; - const expect = "PASSED:"; + const expect = switch (exercise.kind) { + .exe => "PASSED:", + .@"test" => "PASSED", + }; try check(step, exercise, expect, actual); } // Skip the exercise output. - const nlines = 1 + mem.count(u8, exercise.output, "\n") + 1; + const nlines = switch (exercise.kind) { + .exe => 1 + mem.count(u8, exercise.output, "\n") + 1, + .@"test" => 1, + }; + var lineno: usize = 0; while (lineno < nlines) : (lineno += 1) { _ = try readLine(reader, &buf) orelse @panic("EOF"); |
