[PATCH 1/2] test: relocate test_expect_{success,failure}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Their proper place is in test-lib.sh since they aren't meant to be
called in a subshell, except in t0000-basic.sh of course.

The rationale behind the move (12a29b1a50 (Move the user-facing test
library to test-lib-functions.sh, 2012-02-17)) was that the tests in
t/perf would need test-lib-functions.sh inside the subshells, for
example:

        test_perf 'perf test' 'test_expect_success foo :'

But that doesn't actually happens in any of the perf tests.

So move these functions back where they belong.

Cc: Thomas Rast <tr@xxxxxxxxxxxxx>
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 t/test-lib-functions.sh | 42 -----------------------------------------
 t/test-lib.sh           | 42 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 999d46fafe..49a850989a 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -801,48 +801,6 @@ test_verify_prereq () {
 	BUG "'$test_prereq' does not look like a prereq"
 }
 
-test_expect_failure () {
-	test_start_ "$@"
-	test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
-	test "$#" = 2 ||
-	BUG "not 2 or 3 parameters to test-expect-failure"
-	test_verify_prereq
-	export test_prereq
-	if ! test_skip "$@"
-	then
-		test -n "$test_skip_test_preamble" ||
-		say >&3 "checking known breakage of $TEST_NUMBER.$test_count '$1': $2"
-		if test_run_ "$2" expecting_failure
-		then
-			test_known_broken_ok_ "$1"
-		else
-			test_known_broken_failure_ "$1"
-		fi
-	fi
-	test_finish_
-}
-
-test_expect_success () {
-	test_start_ "$@"
-	test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
-	test "$#" = 2 ||
-	BUG "not 2 or 3 parameters to test-expect-success"
-	test_verify_prereq
-	export test_prereq
-	if ! test_skip "$@"
-	then
-		test -n "$test_skip_test_preamble" ||
-		say >&3 "expecting success of $TEST_NUMBER.$test_count '$1': $2"
-		if test_run_ "$2"
-		then
-			test_ok_ "$1"
-		else
-			test_failure_ "$@"
-		fi
-	fi
-	test_finish_
-}
-
 # debugging-friendly alternatives to "test [-f|-d|-e]"
 # The commands test the existence or non-existence of $1
 test_path_is_file () {
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62136caee5..388075a6c6 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1269,6 +1269,48 @@ check_test_results_san_file_ () {
 	fi
 }
 
+test_expect_failure () {
+	test_start_ "$@"
+	test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
+	test "$#" = 2 ||
+	BUG "not 2 or 3 parameters to test-expect-failure"
+	test_verify_prereq
+	export test_prereq
+	if ! test_skip "$@"
+	then
+		test -n "$test_skip_test_preamble" ||
+		say >&3 "checking known breakage of $TEST_NUMBER.$test_count '$1': $2"
+		if test_run_ "$2" expecting_failure
+		then
+			test_known_broken_ok_ "$1"
+		else
+			test_known_broken_failure_ "$1"
+		fi
+	fi
+	test_finish_
+}
+
+test_expect_success () {
+	test_start_ "$@"
+	test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
+	test "$#" = 2 ||
+	BUG "not 2 or 3 parameters to test-expect-success"
+	test_verify_prereq
+	export test_prereq
+	if ! test_skip "$@"
+	then
+		test -n "$test_skip_test_preamble" ||
+		say >&3 "expecting success of $TEST_NUMBER.$test_count '$1': $2"
+		if test_run_ "$2"
+		then
+			test_ok_ "$1"
+		else
+			test_failure_ "$@"
+		fi
+	fi
+	test_finish_
+}
+
 test_done () {
 	# Run the atexit commands _before_ the trash directory is
 	# removed, so the commands can access pidfiles and socket files.
-- 
2.39.2.13.g1fb56cf030




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux