* [PATCH 0/2] test: framework API cleanup
@ 2023-03-13 5:01 Felipe Contreras
2023-03-13 5:01 ` [PATCH 1/2] test: relocate test_expect_{success,failure} Felipe Contreras
2023-03-13 5:01 ` [PATCH 2/2] test: relocate yes Felipe Contreras
0 siblings, 2 replies; 3+ messages in thread
From: Felipe Contreras @ 2023-03-13 5:01 UTC (permalink / raw)
To: git
Cc: Ævar Arnfjörð Bjarmason, SZEDER Gábor,
Felipe Contreras
The functions in the testing framework were supposed to be split between
test-lib.sh and test-lib-functions.sh, however some functions that
belong to the former are on the latter, and vice versa.
Move them back to where they belong.
Felipe Contreras (2):
test: relocate test_expect_{success,failure}
test: relocate yes
t/test-lib-functions.sh | 63 ++++++++++++++---------------------------
t/test-lib.sh | 63 +++++++++++++++++++++++++++--------------
2 files changed, 63 insertions(+), 63 deletions(-)
--
2.39.2.13.g1fb56cf030
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] test: relocate test_expect_{success,failure}
2023-03-13 5:01 [PATCH 0/2] test: framework API cleanup Felipe Contreras
@ 2023-03-13 5:01 ` Felipe Contreras
2023-03-13 5:01 ` [PATCH 2/2] test: relocate yes Felipe Contreras
1 sibling, 0 replies; 3+ messages in thread
From: Felipe Contreras @ 2023-03-13 5:01 UTC (permalink / raw)
To: git
Cc: Ævar Arnfjörð Bjarmason, SZEDER Gábor,
Felipe Contreras, Thomas Rast
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@thomasrast.ch>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] test: relocate yes
2023-03-13 5:01 [PATCH 0/2] test: framework API cleanup Felipe Contreras
2023-03-13 5:01 ` [PATCH 1/2] test: relocate test_expect_{success,failure} Felipe Contreras
@ 2023-03-13 5:01 ` Felipe Contreras
1 sibling, 0 replies; 3+ messages in thread
From: Felipe Contreras @ 2023-03-13 5:01 UTC (permalink / raw)
To: git
Cc: Ævar Arnfjörð Bjarmason, SZEDER Gábor,
Felipe Contreras, Brandon Casey
This is a command meant to be called by the subshells: therefore it
belongs in test-lib-functions.sh.
Cc: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/test-lib-functions.sh | 21 +++++++++++++++++++++
t/test-lib.sh | 21 ---------------------
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 49a850989a..da39d98391 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -87,6 +87,27 @@ test_decode_color () {
'
}
+# Provide an implementation of the 'yes' utility; the upper bound
+# limit is there to help Windows that cannot stop this loop from
+# wasting cycles when the downstream stops reading, so do not be
+# tempted to turn it into an infinite loop. cf. 6129c930 ("test-lib:
+# limit the output of the yes utility", 2016-02-02)
+yes () {
+ if test $# = 0
+ then
+ y=y
+ else
+ y="$*"
+ fi
+
+ i=0
+ while test $i -lt 99
+ do
+ echo "$y"
+ i=$(($i+1))
+ done
+}
+
lf_to_nul () {
perl -pe 'y/\012/\000/'
}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 388075a6c6..24aedc122d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1694,27 +1694,6 @@ OIDPATH_REGEX=$(test_oid_to_path $ZERO_OID | sed -e 's/0/[0-9a-f]/g')
EMPTY_TREE=$(test_oid empty_tree)
EMPTY_BLOB=$(test_oid empty_blob)
-# Provide an implementation of the 'yes' utility; the upper bound
-# limit is there to help Windows that cannot stop this loop from
-# wasting cycles when the downstream stops reading, so do not be
-# tempted to turn it into an infinite loop. cf. 6129c930 ("test-lib:
-# limit the output of the yes utility", 2016-02-02)
-yes () {
- if test $# = 0
- then
- y=y
- else
- y="$*"
- fi
-
- i=0
- while test $i -lt 99
- do
- echo "$y"
- i=$(($i+1))
- done
-}
-
# The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and
# thus needs to be set up really early, and set an internal variable
# for convenience so the hot test_set_prereq() codepath doesn't need
--
2.39.2.13.g1fb56cf030
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-13 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 5:01 [PATCH 0/2] test: framework API cleanup Felipe Contreras
2023-03-13 5:01 ` [PATCH 1/2] test: relocate test_expect_{success,failure} Felipe Contreras
2023-03-13 5:01 ` [PATCH 2/2] test: relocate yes Felipe Contreras
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).