{"thread":{"id":"59383","subject":"[PATCH 0/2] test: framework API cleanup","startedAt":"2023-03-13T05:01:51Z","lastAt":"2023-03-13T05:01:55Z","messageCount":3,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"473445","messageId":"20230313050132.3464802-1-felipe.contreras@gmail.com","threadId":"59383","inReplyTo":null,"subject":"[PATCH 0/2] test: framework API cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-03-13T05:01:30Z","receivedAt":"2023-03-13T05:01:51Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The functions in the testing framework were supposed to be split between\ntest-lib.sh and test-lib-functions.sh, however some functions that\nbelong to the former are on the latter, and vice versa.\n\nMove them back to where they belong.\n\nFelipe Contreras (2):\n  test: relocate test_expect_{success,failure}\n  test: relocate yes\n\n t/test-lib-functions.sh | 63 ++++++++++++++---------------------------\n t/test-lib.sh           | 63 +++++++++++++++++++++++++++--------------\n 2 files changed, 63 insertions(+), 63 deletions(-)\n\n-- \n2.39.2.13.g1fb56cf030\n\n"},{"id":"473446","messageId":"20230313050132.3464802-2-felipe.contreras@gmail.com","threadId":"59383","inReplyTo":"20230313050132.3464802-1-felipe.contreras@gmail.com","subject":"[PATCH 1/2] test: relocate test_expect_{success,failure}","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-03-13T05:01:31Z","receivedAt":"2023-03-13T05:01:53Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Their proper place is in test-lib.sh since they aren't meant to be\ncalled in a subshell, except in t0000-basic.sh of course.\n\nThe rationale behind the move (12a29b1a50 (Move the user-facing test\nlibrary to test-lib-functions.sh, 2012-02-17)) was that the tests in\nt/perf would need test-lib-functions.sh inside the subshells, for\nexample:\n\n        test_perf 'perf test' 'test_expect_success foo :'\n\nBut that doesn't actually happens in any of the perf tests.\n\nSo move these functions back where they belong.\n\nCc: Thomas Rast <tr@thomasrast.ch>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/test-lib-functions.sh | 42 -----------------------------------------\n t/test-lib.sh           | 42 +++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 42 insertions(+), 42 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 999d46fafe..49a850989a 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -801,48 +801,6 @@ test_verify_prereq () {\n \tBUG \"'$test_prereq' does not look like a prereq\"\n }\n \n-test_expect_failure () {\n-\ttest_start_ \"$@\"\n-\ttest \"$#\" = 3 && { test_prereq=$1; shift; } || test_prereq=\n-\ttest \"$#\" = 2 ||\n-\tBUG \"not 2 or 3 parameters to test-expect-failure\"\n-\ttest_verify_prereq\n-\texport test_prereq\n-\tif ! test_skip \"$@\"\n-\tthen\n-\t\ttest -n \"$test_skip_test_preamble\" ||\n-\t\tsay >&3 \"checking known breakage of $TEST_NUMBER.$test_count '$1': $2\"\n-\t\tif test_run_ \"$2\" expecting_failure\n-\t\tthen\n-\t\t\ttest_known_broken_ok_ \"$1\"\n-\t\telse\n-\t\t\ttest_known_broken_failure_ \"$1\"\n-\t\tfi\n-\tfi\n-\ttest_finish_\n-}\n-\n-test_expect_success () {\n-\ttest_start_ \"$@\"\n-\ttest \"$#\" = 3 && { test_prereq=$1; shift; } || test_prereq=\n-\ttest \"$#\" = 2 ||\n-\tBUG \"not 2 or 3 parameters to test-expect-success\"\n-\ttest_verify_prereq\n-\texport test_prereq\n-\tif ! test_skip \"$@\"\n-\tthen\n-\t\ttest -n \"$test_skip_test_preamble\" ||\n-\t\tsay >&3 \"expecting success of $TEST_NUMBER.$test_count '$1': $2\"\n-\t\tif test_run_ \"$2\"\n-\t\tthen\n-\t\t\ttest_ok_ \"$1\"\n-\t\telse\n-\t\t\ttest_failure_ \"$@\"\n-\t\tfi\n-\tfi\n-\ttest_finish_\n-}\n-\n # debugging-friendly alternatives to \"test [-f|-d|-e]\"\n # The commands test the existence or non-existence of $1\n test_path_is_file () {\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 62136caee5..388075a6c6 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1269,6 +1269,48 @@ check_test_results_san_file_ () {\n \tfi\n }\n \n+test_expect_failure () {\n+\ttest_start_ \"$@\"\n+\ttest \"$#\" = 3 && { test_prereq=$1; shift; } || test_prereq=\n+\ttest \"$#\" = 2 ||\n+\tBUG \"not 2 or 3 parameters to test-expect-failure\"\n+\ttest_verify_prereq\n+\texport test_prereq\n+\tif ! test_skip \"$@\"\n+\tthen\n+\t\ttest -n \"$test_skip_test_preamble\" ||\n+\t\tsay >&3 \"checking known breakage of $TEST_NUMBER.$test_count '$1': $2\"\n+\t\tif test_run_ \"$2\" expecting_failure\n+\t\tthen\n+\t\t\ttest_known_broken_ok_ \"$1\"\n+\t\telse\n+\t\t\ttest_known_broken_failure_ \"$1\"\n+\t\tfi\n+\tfi\n+\ttest_finish_\n+}\n+\n+test_expect_success () {\n+\ttest_start_ \"$@\"\n+\ttest \"$#\" = 3 && { test_prereq=$1; shift; } || test_prereq=\n+\ttest \"$#\" = 2 ||\n+\tBUG \"not 2 or 3 parameters to test-expect-success\"\n+\ttest_verify_prereq\n+\texport test_prereq\n+\tif ! test_skip \"$@\"\n+\tthen\n+\t\ttest -n \"$test_skip_test_preamble\" ||\n+\t\tsay >&3 \"expecting success of $TEST_NUMBER.$test_count '$1': $2\"\n+\t\tif test_run_ \"$2\"\n+\t\tthen\n+\t\t\ttest_ok_ \"$1\"\n+\t\telse\n+\t\t\ttest_failure_ \"$@\"\n+\t\tfi\n+\tfi\n+\ttest_finish_\n+}\n+\n test_done () {\n \t# Run the atexit commands _before_ the trash directory is\n \t# removed, so the commands can access pidfiles and socket files.\n-- \n2.39.2.13.g1fb56cf030\n\n"},{"id":"473447","messageId":"20230313050132.3464802-3-felipe.contreras@gmail.com","threadId":"59383","inReplyTo":"20230313050132.3464802-1-felipe.contreras@gmail.com","subject":"[PATCH 2/2] test: relocate yes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-03-13T05:01:32Z","receivedAt":"2023-03-13T05:01:55Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This is a command meant to be called by the subshells: therefore it\nbelongs in test-lib-functions.sh.\n\nCc: Brandon Casey <drafnel@gmail.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/test-lib-functions.sh | 21 +++++++++++++++++++++\n t/test-lib.sh           | 21 ---------------------\n 2 files changed, 21 insertions(+), 21 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 49a850989a..da39d98391 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -87,6 +87,27 @@ test_decode_color () {\n \t'\n }\n \n+# Provide an implementation of the 'yes' utility; the upper bound\n+# limit is there to help Windows that cannot stop this loop from\n+# wasting cycles when the downstream stops reading, so do not be\n+# tempted to turn it into an infinite loop. cf. 6129c930 (\"test-lib:\n+# limit the output of the yes utility\", 2016-02-02)\n+yes () {\n+\tif test $# = 0\n+\tthen\n+\t\ty=y\n+\telse\n+\t\ty=\"$*\"\n+\tfi\n+\n+\ti=0\n+\twhile test $i -lt 99\n+\tdo\n+\t\techo \"$y\"\n+\t\ti=$(($i+1))\n+\tdone\n+}\n+\n lf_to_nul () {\n \tperl -pe 'y/\\012/\\000/'\n }\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 388075a6c6..24aedc122d 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1694,27 +1694,6 @@ OIDPATH_REGEX=$(test_oid_to_path $ZERO_OID | sed -e 's/0/[0-9a-f]/g')\n EMPTY_TREE=$(test_oid empty_tree)\n EMPTY_BLOB=$(test_oid empty_blob)\n \n-# Provide an implementation of the 'yes' utility; the upper bound\n-# limit is there to help Windows that cannot stop this loop from\n-# wasting cycles when the downstream stops reading, so do not be\n-# tempted to turn it into an infinite loop. cf. 6129c930 (\"test-lib:\n-# limit the output of the yes utility\", 2016-02-02)\n-yes () {\n-\tif test $# = 0\n-\tthen\n-\t\ty=y\n-\telse\n-\t\ty=\"$*\"\n-\tfi\n-\n-\ti=0\n-\twhile test $i -lt 99\n-\tdo\n-\t\techo \"$y\"\n-\t\ti=$(($i+1))\n-\tdone\n-}\n-\n # The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and\n # thus needs to be set up really early, and set an internal variable\n # for convenience so the hot test_set_prereq() codepath doesn't need\n-- \n2.39.2.13.g1fb56cf030\n\n"}]}