[PATCH 5/6] t9103: modernize test style

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

 



The main goal here was to avoid double-quotes for
surrounding the test snippet, since it makes the code hard
to read (and to grep for common problems).

But while we're here, we can fix a few other things:

  - use test_path_* helpers, which are more robust and give
    better error messages

  - only "cd" inside a subshell, which leaves the
    environment pristine if further tests are added

  - consistently quote shell arguments. These aren't wrong
    if we assume find-rev output doesn't have any
    whitespace, but it doesn't hurt to be careful.

  - replace the old-style 'test x$foo = x' with 'test -z
    "$foo"'. Besides the quoting fix, this is the form we
    generally use in our test suite.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 t/t9103-git-svn-tracked-directory-removed.sh | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/t/t9103-git-svn-tracked-directory-removed.sh b/t/t9103-git-svn-tracked-directory-removed.sh
index 3413164..b282713 100755
--- a/t/t9103-git-svn-tracked-directory-removed.sh
+++ b/t/t9103-git-svn-tracked-directory-removed.sh
@@ -23,17 +23,19 @@ test_expect_success 'make history for tracking' '
 
 test_expect_success 'clone repo with git' '
 	git svn clone -s "$svnrepo" x &&
-	test -f x/FOLLOWME &&
-	test ! -f x/README
+	test_path_is_file x/FOLLOWME &&
+	test_path_is_missing x/README
 '
 
-test_expect_success 'make sure r2 still has old file' "
-	cd x &&
-		test -n \"\$(git svn find-rev r1)\" &&
-		git reset --hard \$(git svn find-rev r1) &&
-		test -f README &&
-		test ! -f FOLLOWME &&
-		test x\$(git svn find-rev r2) = x
-"
+test_expect_success 'make sure r2 still has old file' '
+	(
+		cd x &&
+		test -n "$(git svn find-rev r1)" &&
+		git reset --hard "$(git svn find-rev r1)" &&
+		test_path_is_file README &&
+		test_path_is_missing FOLLOWME &&
+		test -z "$(git svn find-rev r2)"
+	)
+'
 
 test_done
-- 
2.8.2.825.gea31738

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]