From 1e63f0165e743bd99ed645a0e004edeb93412a74 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 2 Aug 2017 08:14:31 -0400 Subject: [PATCH 1/3] fill in dev cruft stub parameter --- test/tools/libtest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/libtest.sh b/test/tools/libtest.sh index b04158654..99477a835 100644 --- a/test/tools/libtest.sh +++ b/test/tools/libtest.sh @@ -306,7 +306,7 @@ EOF assert_vars() { if [ -e "$expected_var_file" ]; then - assert_equals "$vars_file" strict "message" < "$expected_var_file" + assert_equals "$vars_file" strict "$*" < "$expected_var_file" else printf '[FAIL] %s not found\n' "$expected_var_file" >> .test-result fi From ef9e538fac5d2420281b700a6c21aa5d467cbd24 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 2 Aug 2017 08:15:23 -0400 Subject: [PATCH 2/3] whitespace_arg more readable default value --- test/tools/libtest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/libtest.sh b/test/tools/libtest.sh index 99477a835..01eee3f00 100644 --- a/test/tools/libtest.sh +++ b/test/tools/libtest.sh @@ -232,7 +232,7 @@ ORIG_IFS= assert_equals() { file="$1"; shift - whitespace_arg="ignore"; + whitespace_arg='-w'; if [ "$#" -ge 1 ]; then whitespace_arg="${1:-}" From 4a86bf17e2417871c240b6c4bb83a7d2b9a3323c Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 2 Aug 2017 08:16:20 -0400 Subject: [PATCH 3/3] require expected-count argument to assert_vars --- test/main/all-arg-test | 2 +- test/main/branch-var-test | 2 +- test/refs/branch-var-test | 2 +- test/status/repo-var-test | 2 +- test/tools/libtest.sh | 22 ++++++++++++++++------ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/test/main/all-arg-test b/test/main/all-arg-test index a2e026510..b7327046a 100755 --- a/test/main/all-arg-test +++ b/test/main/all-arg-test @@ -21,7 +21,7 @@ in_work_dir create_repo_from_tgz "$base_dir/files/refs-repo.tgz" test_tig --all -assert_vars +assert_vars 1 assert_equals stderr <> "$HOME/$vars_file" -printf '%s\\n' "\$rhs" >> "$expected_var_file" +printf '%s\\n' "\$rhs" >> "$expected_vars_file" EOF assert_vars() { - if [ -e "$expected_var_file" ]; then - assert_equals "$vars_file" strict "$*" < "$expected_var_file" + if [ -n "${1:-}" ]; then + printf '%s\n' "$1" > "$vars_count_file" + shift + else + die "Test must supply the expected count of assertions to assert_vars()" + fi + + grep -c . "$vars_file" | assert_equals "$vars_count_file" strict "$*" + + if [ -e "$expected_vars_file" ]; then + assert_equals "$vars_file" strict "$*" < "$expected_vars_file" else - printf '[FAIL] %s not found\n' "$expected_var_file" >> .test-result + printf '[FAIL] %s not found\n' "$expected_vars_file" >> .test-result fi }