[PATCH 15/15] t1507: teach full_name() to accept `!` arg

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

 



Before, we were running `test_must_fail full_name`. However,
`test_must_fail` should only be used on git commands. Teach full_name()
to accept `!` as a potential first argument which will prepend
`test_must_fail` to the enclosed git command. This increases the
granularity of test_must_fail since it no longer runs on the `cd` as
well.

Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx>
---
 t/t1507-rev-parse-upstream.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index 8b4cf8a6e3..9a941d68d8 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -29,8 +29,14 @@ test_expect_success 'setup' '
 '
 
 full_name () {
+	fail= &&
+	if test "x$1" = 'x!'
+	then
+		fail=test_must_fail &&
+		shift
+	fi &&
 	(cd clone &&
-	 git rev-parse --symbolic-full-name "$@")
+	 $fail git rev-parse --symbolic-full-name "$@")
 }
 
 commit_subject () {
@@ -79,7 +85,7 @@ test_expect_success 'upstream of branch with @ at end' '
 '
 
 test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' '
-	test_must_fail full_name refs/heads/my-side@{upstream}
+	full_name ! refs/heads/my-side@{upstream}
 '
 
 test_expect_success 'my-side@{u} resolves to correct commit' '
@@ -91,9 +97,9 @@ test_expect_success 'my-side@{u} resolves to correct commit' '
 '
 
 test_expect_success 'not-tracking@{u} fails' '
-	test_must_fail full_name non-tracking@{u} &&
+	full_name ! non-tracking@{u} &&
 	(cd clone && git checkout --no-track -b non-tracking) &&
-	test_must_fail full_name non-tracking@{u}
+	full_name ! non-tracking@{u}
 '
 
 test_expect_success '<branch>@{u}@{1} resolves correctly' '
-- 
2.24.0.627.geba02921db




[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