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.
Steven Allen committed
Feb 18, 2020 at 15:12 UTC
6e8c25eaee350a550b28a5d358225644747785b5
1 file changed
+26
test/sharness/t0001-tests-work.sh
new
+26
@@ -0,0 +1,26 @@
1
+#!/usr/bin/env bash
2
+
3
+test_description="Test sharness tests are correctly written"
4
+
5
+. lib/test-lib.sh
6
+
7
+for file in $(find .. -maxdepth 1 -name 't*.sh' -type f); do
8
+ test_expect_success "test in $file finishes" '
9
+ grep -q "^test_done\b" "$file"
10
+ '
11
+
12
+ test_expect_success "test in $file has a description" '
13
+ test_must_fail grep -L "^test_description=" "$file"
14
+ '
15
+
16
+ # We have some tests that manually kill.
17
+ case "$(basename "$file")" in
18
+ t0060-daemon.sh|t0023-shutdown.sh) continue ;;
19
+ esac
20
+
21
+ test_expect_success "test in $file has matching ipfs start/stop" '
22
+ 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"
23
+ '
24
+done
25
+
26
+test_done