Skip to content

Commit

Permalink
test: Use bats-assert to see differences in failed test outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
wentasah committed Nov 12, 2022
1 parent 447129d commit f6d6435
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion demos-sched.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ let
copySub $srcSpdlog $out/subprojects/spdlog
'';
};
bats-wl = bats.withLibraries (p: [ p.bats-support p.bats-assert ]);
in stdenv.mkDerivation ({
name = "demos-sched";
src = if withSubmodules then srcWithSubmodules else builtins.fetchGit { url = ./.; };
# Delete subprojects if building with Nix-provided dependencies
patchPhase = lib.optionalString (!withSubmodules) "rm -rf subprojects";
nativeBuildInputs = [ meson ninja perl pkg-config bats gcovr ];
nativeBuildInputs = [ meson ninja perl pkg-config bats-wl gcovr ];
buildInputs = []
++ lib.optional (!withSubmodules) [ libev-patched libyamlcpp spdlog_dev ];
} // extraAttrs)
9 changes: 6 additions & 3 deletions test/0100-api.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats
load testlib
bats_load_library bats-support
bats_load_library bats-assert

@test "running api-test outside of demos-sched fails" {
run ! api-test
Expand Down Expand Up @@ -51,12 +53,13 @@ partitions:
- name: SC2
processes: [{cmd: api-init-test, budget: 50, init: yes}]
'
[[ $output = \
"init start
assert_output - <<EOF
init start
init start
init done
init done
<test>" ]]
<test>
EOF
}


Expand Down

0 comments on commit f6d6435

Please sign in to comment.