1 write_sub_test_lib_test
() {
2 name
="$1" # stdin is the body of the test code
4 write_script
"$name/$name.sh" "$TEST_SHELL_PATH" <<-EOF &&
5 test_description='A test of test-lib.sh itself'
7 # Point to the t/test-lib.sh, which isn't in ../ as usual
8 . "\$TEST_DIRECTORY"/test-lib.sh
10 cat >>"$name/$name.sh"
13 _run_sub_test_lib_test_common
() {
14 neg
="$1" name
="$2" # stdin is the body of the test code
17 # intercept pseudo-options at the front of the argument list that we
18 # will not pass to child script
36 # Pretend we're not running under a test harness, whether we
37 # are or not. The test-lib output depends on the setting of
38 # this variable, so we need a stable setting under which to run
40 sane_unset HARNESS_ACTIVE
&&
42 export TEST_DIRECTORY
&&
43 # The child test re-sources GIT-BUILD-OPTIONS and may thus
44 # override the test output directory. We thus pass it as an
45 # explicit override to the child.
46 TEST_OUTPUT_DIRECTORY_OVERRIDE
=$
(pwd) &&
47 export TEST_OUTPUT_DIRECTORY_OVERRIDE
&&
48 GIT_SKIP_TESTS
=$skip &&
49 export GIT_SKIP_TESTS
&&
50 sane_unset GIT_TEST_FAIL_PREREQS
&&
53 .
/"$name.sh" "$@" >out
2>err
55 ! .
/"$name.sh" "$@" >out
2>err
60 write_and_run_sub_test_lib_test
() {
61 name
="$1" descr
="$2" # stdin is the body of the test code
62 write_sub_test_lib_test
"$@" ||
return 1
63 _run_sub_test_lib_test_common
'' "$@"
66 write_and_run_sub_test_lib_test_err
() {
67 name
="$1" descr
="$2" # stdin is the body of the test code
68 write_sub_test_lib_test
"$@" ||
return 1
69 _run_sub_test_lib_test_common
'!' "$@"
72 run_sub_test_lib_test
() {
73 _run_sub_test_lib_test_common
'' "$@"
76 run_sub_test_lib_test_err
() {
77 _run_sub_test_lib_test_common
'!' "$@"
80 check_sub_test_lib_test
() {
81 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
87 check_sub_test_lib_test_err
() {
88 name
="$1" # stdin is the expected output from the test
89 # 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
&&
92 sed -e 's/^> //' -e 's/Z$//' <&3 >"$name"/expect.err
&&
93 test_cmp
"$name"/expect.err
"$name"/err