From 6e8c25eaee350a550b28a5d358225644747785b5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 18 Feb 2020 15:12:56 -0500 Subject: [PATCH] test(sharness): test our tests Make sure they: 1. Report that they're done. Otherwise, we'll silently succeed. 2. Have a description. 3. Make sure we cleanup IPFS. --- test/sharness/t0001-tests-work.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 test/sharness/t0001-tests-work.sh diff --git a/test/sharness/t0001-tests-work.sh b/test/sharness/t0001-tests-work.sh new file mode 100755 index 00000000000..79557e10943 --- /dev/null +++ b/test/sharness/t0001-tests-work.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +test_description="Test sharness tests are correctly written" + +. lib/test-lib.sh + +for file in $(find .. -maxdepth 1 -name 't*.sh' -type f); do + test_expect_success "test in $file finishes" ' + grep -q "^test_done\b" "$file" + ' + + test_expect_success "test in $file has a description" ' + test_must_fail grep -L "^test_description=" "$file" + ' + + # We have some tests that manually kill. + case "$(basename "$file")" in + t0060-daemon.sh|t0023-shutdown.sh) continue ;; + esac + + test_expect_success "test in $file has matching ipfs start/stop" ' + awk "/^ *[^#]*test_launch_ipfs_daemon/ { if (count != 0) { exit(1) }; count++ } /^ *[^#]*test_kill_ipfs_daemon/ { if (count != 1) { exit(1) }; count-- } END { exit(count) }" "$file" + ' +done + +test_done