Skip to content

Commit e07b817

Browse files
avargitster
authored andcommitted
test-lib tests: refactor common part of check_sub_test_lib_test*()
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 0445e6f (test-lib: '--run' to run only specific tests, 2014-04-30). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 12fe490 commit e07b817

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

t/lib-subtest.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,22 @@ run_sub_test_lib_test_err () {
7777
_run_sub_test_lib_test_common '!' "$@"
7878
}
7979

80+
_check_sub_test_lib_test_common () {
81+
name="$1" &&
82+
sed -e 's/^> //' -e 's/Z$//' >"$name"/expect.out &&
83+
test_cmp "$name"/expect.out "$name"/out
84+
}
85+
8086
check_sub_test_lib_test () {
8187
name="$1" # stdin is the expected output from the test
82-
test_must_be_empty "$name"/err &&
83-
sed -e 's/^> //' -e 's/Z$//' >"$name"/expect &&
84-
test_cmp "$name/"expect "$name"/out
88+
_check_sub_test_lib_test_common "$name" &&
89+
test_must_be_empty "$name"/err
8590
}
8691

8792
check_sub_test_lib_test_err () {
8893
name="$1" # stdin is the expected output from the test
94+
_check_sub_test_lib_test_common "$name" &&
8995
# expected error output is in descriptor 3
90-
sed -e 's/^> //' -e 's/Z$//' >"$name"/expect.out &&
91-
test_cmp "$name"/expect.out "$name"/out &&
9296
sed -e 's/^> //' -e 's/Z$//' <&3 >"$name"/expect.err &&
9397
test_cmp "$name"/expect.err "$name"/err
9498
}

0 commit comments

Comments
 (0)