From 41ac414ea2bef81af94474cbef25a38868b4788e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 1 Feb 2008 01:50:53 -0800 Subject: Sane use of test_expect_failure Originally, test_expect_failure was designed to be the opposite of test_expect_success, but this was a bad decision. Most tests run a series of commands that leads to the single command that needs to be tested, like this: test_expect_{success,failure} 'test title' ' setup1 && setup2 && setup3 && what is to be tested ' And expecting a failure exit from the whole sequence misses the point of writing tests. Your setup$N that are supposed to succeed may have failed without even reaching what you are trying to test. The only valid use of test_expect_failure is to check a trivial single command that is expected to fail, which is a minority in tests of Porcelain-ish commands. This large-ish patch rewrites all uses of test_expect_failure to use test_expect_success and rewrites the condition of what is tested, like this: test_expect_success 'test title' ' setup1 && setup2 && setup3 && ! this command should fail ' test_expect_failure is redefined to serve as a reminder that that test *should* succeed but due to a known breakage in git it currently does not pass. So if git-foo command should create a file 'bar' but you discovered a bug that it doesn't, you can write a test like this: test_expect_failure 'git-foo should create bar' ' rm -f bar && git foo && test -f bar ' This construct acts similar to test_expect_success, but instead of reporting "ok/FAIL" like test_expect_success does, the outcome is reported as "FIXED/still broken". Signed-off-by: Junio C Hamano --- t/t5500-fetch-pack.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t5500-fetch-pack.sh') diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 7b6798d8b5..788b4a5aae 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -176,7 +176,7 @@ test_expect_success "deepening fetch in shallow repo" \ test_expect_success "clone shallow object count" \ "test \"count: 18\" = \"$(grep count count.shallow)\"" -test_expect_failure "pull in shallow repo with missing merge base" \ - "(cd shallow; git pull --depth 4 .. A)" +test_expect_success "pull in shallow repo with missing merge base" \ + "(cd shallow && ! git pull --depth 4 .. A)" test_done -- cgit v1.2.3 From 0e46e704626af5189c9c9ff2c0f348d2205c10f3 Mon Sep 17 00:00:00 2001 From: Bryan Donlan Date: Sun, 4 May 2008 01:37:58 -0400 Subject: Don't use the 'export NAME=value' in the test scripts. This form is not portable across all shells, so replace instances of: export FOO=bar with: FOO=bar export FOO Signed-off-by: Bryan Donlan Signed-off-by: Junio C Hamano --- t/t5500-fetch-pack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t5500-fetch-pack.sh') diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 788b4a5aae..1700d0794c 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -31,7 +31,7 @@ add () { sec=$(($sec+1)) commit=$(echo "$text" | GIT_AUTHOR_DATE=$sec \ git commit-tree $tree $parents 2>>log2.txt) - export $name=$commit + eval "$name=$commit; export $name" echo $commit > .git/refs/heads/$branch eval ${branch}TIP=$commit } -- cgit v1.2.3 From f69e836fab2b634281d92a0d304de4d768e479cc Mon Sep 17 00:00:00 2001 From: Bryan Donlan Date: Sun, 4 May 2008 01:37:59 -0400 Subject: Fix tests breaking when checkout path contains shell metacharacters This fixes the remainder of the issues where the test script itself is at fault for failing when the git checkout path contains whitespace or other shell metacharacters. The majority of git svn tests used the idiom test_expect_success "title" "test script using $svnrepo" These were changed to have the test script in single-quotes: test_expect_success "title" 'test script using "$svnrepo"' which unfortunately makes the patch appear larger than it really is. One consequence of this change is that in the verbose test output the value of $svnrepo (and in some cases other variables, too) is no longer expanded, i.e. previously we saw * expecting success: test script using /path/to/git/t/trash/svnrepo but now it is: * expecting success: test script using "$svnrepo" Signed-off-by: Bryan Donlan Signed-off-by: Junio C Hamano --- t/t5500-fetch-pack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t5500-fetch-pack.sh') diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 1700d0794c..140e874581 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -129,7 +129,7 @@ pull_to_client 2nd "B" $((64*3)) pull_to_client 3rd "A" $((1*3)) # old fails -test_expect_success "clone shallow" "git-clone --depth 2 file://`pwd`/. shallow" +test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow' (cd shallow; git count-objects -v) > count.shallow -- cgit v1.2.3 From d492b31cafe9aa5ce001b1d48815f4c0bb40d01a Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Sat, 12 Jul 2008 17:47:52 +0200 Subject: t/: Use "test_must_fail git" instead of "! git" This patch changes every occurrence of "! git" -- with the meaning that a git call has to gracefully fail -- into "test_must_fail git". This is useful to - make sure the test does not fail because of a signal, e.g. SIGSEGV, and - advertise the use of "test_must_fail" for new tests. Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- t/t5500-fetch-pack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t5500-fetch-pack.sh') diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 140e874581..362cf7e928 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -177,6 +177,6 @@ test_expect_success "clone shallow object count" \ "test \"count: 18\" = \"$(grep count count.shallow)\"" test_expect_success "pull in shallow repo with missing merge base" \ - "(cd shallow && ! git pull --depth 4 .. A)" + "(cd shallow && test_must_fail git pull --depth 4 .. A)" test_done -- cgit v1.2.3 From f223824943e23e593b5e9cc647417a4267acc82d Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Fri, 15 Aug 2008 00:20:20 -0400 Subject: count-objects: Add total pack size to verbose output Adds the total pack size (including indexes) the verbose count-objects output, floored to the nearest kilobyte. Updates documentation to match this addition. Signed-off-by: Marcus Griep Signed-off-by: Junio C Hamano --- t/t5500-fetch-pack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t5500-fetch-pack.sh') diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 362cf7e928..7125baebb8 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -137,7 +137,7 @@ test_expect_success "clone shallow object count" \ "test \"in-pack: 18\" = \"$(grep in-pack count.shallow)\"" count_output () { - sed -e '/^in-pack:/d' -e '/^packs:/d' -e '/: 0$/d' "$1" + sed -e '/^in-pack:/d' -e '/^packs:/d' -e '/^size-pack:/d' -e '/: 0$/d' "$1" } test_expect_success "clone shallow object count (part 2)" ' -- cgit v1.2.3 From 3604e7c5c6f8d48e221ea5b21ef26fc3e27eff9e Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Wed, 3 Sep 2008 17:59:29 +0900 Subject: tests: use "git xyzzy" form (t3600 - t6999) Converts tests between t3600-t6300. Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- t/t5500-fetch-pack.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t5500-fetch-pack.sh') diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 362cf7e928..448ec71565 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -58,7 +58,7 @@ pull_to_client () { cd client test_expect_success "$number pull" \ - "git-fetch-pack -k -v .. $heads" + "git fetch-pack -k -v .. $heads" case "$heads" in *A*) echo $ATIP > .git/refs/heads/A;; esac case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac git symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'` @@ -129,7 +129,7 @@ pull_to_client 2nd "B" $((64*3)) pull_to_client 3rd "A" $((1*3)) # old fails -test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow' +test_expect_success "clone shallow" 'git clone --depth 2 "file://$(pwd)/." shallow' (cd shallow; git count-objects -v) > count.shallow -- cgit v1.2.3