chiark / gitweb /
New policy: Only use test_expect_failure for broken tests
authorKarl Hasselström <kha@treskal.com>
Sun, 23 Sep 2007 12:18:50 +0000 (14:18 +0200)
committerKarl Hasselström <kha@treskal.com>
Sun, 23 Sep 2007 22:54:07 +0000 (00:54 +0200)
New policy for tests:

  * For subtests whose commands fail when the test succeeds, use
    test_expect_success and shell negation (!). test_expect_failure is
    to be used only for subtests that are known to be broken.

  * Patches that introduce a subtest failure must change that subtest
    to use test_expect_failure.

The reason for this change is to ensure that the test suite passes at
all times, even in the middle of disruptive rewrites spread over
several commits.

Signed-off-by: Karl Hasselström <kha@treskal.com>
t/README
t/t0001-subdir-branches.sh
t/t1000-branch-create.sh
t/t1001-branch-rename.sh
t/t1002-branch-clone.sh
t/t1200-push-modified.sh
t/t1202-push-undo.sh
t/t2000-sync.sh
t/t2100-pull-policy-fetch.sh
t/t2102-pull-policy-rebase.sh
t/t2200-rebase.sh

index d88bad2724954900bc80a71fc9f25fcd8ea97e12..77f0b6cf63e498291aac9b83bb2afb4165eea650 100644 (file)
--- a/t/README
+++ b/t/README
@@ -162,11 +162,10 @@ library for your script to use.
    This is the opposite of test_expect_success.  If <script>
    yields success, test is considered a failure.
 
-   Example:
-
-       test_expect_failure \
-           'git-update-index without --add should fail adding.' \
-           'git-update-index should-be-empty'
+   This should _not_ be used for tests that succeed when their
+   commands fail -- use test_expect_success and shell negation (!) for
+   that. test_expect_failure is for cases when a test is known to be
+   broken.
 
  - test_debug <script>
 
index 1685233401df71738c5ef935a594cc29939dab2e..0eed3a44088c1d7adede76ab90d090d04b86fba6 100755 (executable)
@@ -38,10 +38,11 @@ test_expect_success 'Try new form of id with slashy branch' \
    stg id foo@x/y/z &&
    stg id foo@x/y/z//top'
 
-test_expect_failure 'Try old id with slashy branch' \
-  'stg id foo/ ||
-   stg id foo/top ||
-   stg id foo@x/y/z/top'
+test_expect_success 'Try old id with slashy branch' '
+   ! stg id foo/ &&
+   ! stg id foo/top &&
+   ! stg id foo@x/y/z/top
+   '
 
 test_expect_success 'Create patch in slashy branch' \
   'echo "bar" >> foo.txt &&
index e920e934e241df0e2f3e2f714aaf14becfab7120..848686c40bfe66768a80974d9cf51b861ce93644 100755 (executable)
@@ -18,9 +18,9 @@ test_expect_success \
     mkdir -p .git/patches && touch .git/patches/foo
 '
 
-test_expect_failure \
+test_expect_success \
     'Try to create an stgit branch with a spurious patches/ entry' '
-    stg branch -c foo
+    stg branch -c foo
 '
 
 test_expect_success \
@@ -35,9 +35,9 @@ test_expect_success \
     cp .git/refs/heads/master .git/refs/heads/foo
 '
 
-test_expect_failure \
+test_expect_success \
     'Try to create an stgit branch with an existing git branch by that name' '
-    stg branch -c foo
+    stg branch -c foo
 '
 
 test_expect_success \
index 285440f00365be8486218f4d75e12f6125a8ce20..dd121326417434b127fd5a265d429f10670494dc 100755 (executable)
@@ -17,9 +17,9 @@ test_expect_success \
      stg new p1 -m "p1"
 '
 
-test_expect_failure \
+test_expect_success \
     'Rename the current stgit branch' \
-    'stg branch -r foo bar
+    'stg branch -r foo bar
 '
 
 test_expect_success \
index 1d7fc395d5b482edcd5fb56a682c8d88987c5f4e..b0087e91a3bdd48d95295f04ebdaf05d98502e8f 100755 (executable)
@@ -18,10 +18,10 @@ test_expect_success \
     git commit -a -m bar
     '
 
-test_expect_failure \
+test_expect_success \
     'Try to create a patch in a GIT branch' \
     '
-    stg new p0 -m "p0"
+    stg new p0 -m "p0"
     '
 
 test_expect_success \
index 0e408d07888f12f309b5635b388b18333e9b1590..cfec6960a29fba3793fdd1d57f2923893bfcab2c 100755 (executable)
@@ -47,9 +47,9 @@ test_expect_success \
      )
 "
 
-test_expect_failure \
+test_expect_success \
     'Attempt to push the first of those patches without --merged' \
-    "(cd bar && stg push
+    "(cd bar && stg push
      )
 "
 
index 335b554b40649b106123de3bbb85d49521d0f26d..039103aec01229ee6da57d1a53a88ad59a175212 100755 (executable)
@@ -40,10 +40,10 @@ test_expect_success \
        stg pop --all
        '
 
-test_expect_failure \
+test_expect_success \
        'Push the second patch with conflict' \
        '
-       stg push bar
+       stg push bar
        '
 
 test_expect_success \
index f831df78fb59a9576f9d8cc5f19e438a1b314a1a..484dbabb75702d2c38ca0b73e84c0a1f3d9930a4 100755 (executable)
@@ -106,10 +106,10 @@ test_expect_success \
     test $(cat bar2.txt) = "bar2"
     '
 
-test_expect_failure \
+test_expect_success \
     'Synchronise the first two patches with the master branch (to fail)' \
     '
-    stg sync -B master -a
+    stg sync -B master -a
     '
 
 test_expect_success \
@@ -124,10 +124,10 @@ test_expect_success \
     [ "$(echo $(stg unapplied))" = "" ]
     '
 
-test_expect_failure \
+test_expect_success \
     'Synchronise the third patch with the exported series (to fail)' \
     '
-    stg sync -s patches-master/series p3
+    stg sync -s patches-master/series p3
     '
 
 test_expect_success \
index e1398a380ee93fb95699c0014fdb6409029ee4a0..1f50069e583292cae3e4f877f344deda569f3656 100755 (executable)
@@ -65,8 +65,8 @@ test_expect_success \
     (cd clone && stg commit && stg new c2 -m c2 &&
      echo a >> file && stg refresh)
     '
-test_expect_failure \
+test_expect_success \
     'Try to  and commit a patch in clone' \
-    '(cd clone && stg pull)'
+    '(cd clone && stg pull)'
 
 test_done
index 670673d58cd21baccf28781dd9652c79c606dfb6..b2fbfcf63657ef9ca62c88767f3132c7c3d58023 100755 (executable)
@@ -46,18 +46,18 @@ test_expect_success \
     stg branch stack && stg commit && stg new c2 -m c2 &&
      echo a >> file && stg refresh
     '
-test_expect_failure \
+test_expect_success \
     'Try to pull/rebase now that stack base has moved' \
-    'stg pull'
+    'stg pull'
 
 test_expect_success \
     'Force the pull/rebase, but do not push yet' \
     'stg pull --force --nopush'
-test_expect_failure \
+test_expect_success \
     '...check we lost the committed patch' \
-    'test -e file'
-test_expect_failure \
+    'test -e file'
+test_expect_success \
     '...and check we get a conflict while pushing' \
-    'stg push'
+    'stg push'
 
 test_done
index c142e08d1934f68b23bb6671a68015012ded4c09..ec2a104fc2e089a5d9653faa852cf416b987c909 100755 (executable)
@@ -31,10 +31,10 @@ test_expect_success \
        test `stg applied | wc -l` = 1
        '
 
-test_expect_failure \
+test_expect_success \
        'Attempt rebase to non-existing commit' \
        '
-       stg rebase not-a-ref
+       stg rebase not-a-ref
        '
 
 test_expect_success \