perf: export some important test-lib variables
The only bug right now is that $GIT_TEST_CMP is needed for test_cmp to work. However, we also export the three most important paths for tests: TEST_DIRECTORY TRASH_DIRECTORY GIT_BUILD_DIR Since they are available within test_expect_success, a future test writer may expect them to also be defined in test_perf. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Mar 8, 2012 at 09:54 UTC
561ae0673569f43a92ea6b0776ae0f4c01472dca
2 files changed
+14
-1
t/perf/p0000-perf-lib-sanity.sh
+10
-1
@@ -38,9 +38,18 @@ test_expect_success 'test_export works with weird vars' '
38
test "$bar" = "weird # variable"
39
'
40
41
+test_perf 'important variables available in subshells' '
42
+ test -n "$HOME" &&
43
+ test -n "$TEST_DIRECTORY" &&
44
+ test -n "$TRASH_DIRECTORY" &&
45
+ test -n "$GIT_BUILD_DIR"
46
+'
47
+
48
test_perf 'test-lib-functions correctly loaded in subshells' '
49
: >a &&
43
- test_path_is_file a
50
+ test_path_is_file a &&
51
+ : >b &&
52
+ test_cmp a b
53
'
54
55
test_done
t/perf/perf-lib.sh
+4
@@ -45,6 +45,10 @@ TEST_NO_CREATE_REPO=t
45
46
. ../test-lib.sh
47
48
+# Variables from test-lib that are normally internal to the tests; we
49
+# need to export them for test_perf subshells
50
+export TEST_DIRECTORY TRASH_DIRECTORY GIT_BUILD_DIR GIT_TEST_CMP
51
+
52
perf_results_dir=$TEST_OUTPUT_DIRECTORY/test-results
53
mkdir -p "$perf_results_dir"
54
rm -f "$perf_results_dir"/$(basename "$0" .sh).subtests