]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-lib tests: refactor common part of check_sub_test_lib_test*()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 22 Sep 2021 11:19:51 +0000 (13:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Sep 2021 23:22:41 +0000 (16:22 -0700)
Refactor the two check_sub_test_lib_test*() functions to avoid
duplicating the same comparison they did of stdout. This duplication
was initially added when check_sub_test_lib_test_err() was added in
0445e6f0a12 (test-lib: '--run' to run only specific tests,
2014-04-30).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-subtest.sh

index 0737fab98ad4cfd7da6fc4ecd81988c3b17fda0c..cdadc0c7fc284088ec429ef24a4e64a21ba93bed 100644 (file)
@@ -77,18 +77,22 @@ run_sub_test_lib_test_err () {
        _run_sub_test_lib_test_common '!' "$@"
 }
 
+_check_sub_test_lib_test_common () {
+       name="$1" &&
+       sed -e 's/^> //' -e 's/Z$//' >"$name"/expect.out &&
+       test_cmp "$name"/expect.out "$name"/out
+}
+
 check_sub_test_lib_test () {
        name="$1" # stdin is the expected output from the test
-       test_must_be_empty "$name"/err &&
-       sed -e 's/^> //' -e 's/Z$//' >"$name"/expect &&
-       test_cmp "$name/"expect "$name"/out
+       _check_sub_test_lib_test_common "$name" &&
+       test_must_be_empty "$name"/err
 }
 
 check_sub_test_lib_test_err () {
        name="$1" # stdin is the expected output from the test
+       _check_sub_test_lib_test_common "$name" &&
        # expected error output is in descriptor 3
-       sed -e 's/^> //' -e 's/Z$//' >"$name"/expect.out &&
-       test_cmp "$name"/expect.out "$name"/out &&
        sed -e 's/^> //' -e 's/Z$//' <&3 >"$name"/expect.err &&
        test_cmp "$name"/expect.err "$name"/err
 }