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>
This is the opposite of test_expect_success. If <script>
yields success, test is considered a failure.
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.
stg id foo@x/y/z &&
stg id foo@x/y/z//top'
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 &&
test_expect_success 'Create patch in slashy branch' \
'echo "bar" >> foo.txt &&
mkdir -p .git/patches && touch .git/patches/foo
'
mkdir -p .git/patches && touch .git/patches/foo
'
'Try to create an stgit branch with a spurious patches/ entry' '
'Try to create an stgit branch with a spurious patches/ entry' '
cp .git/refs/heads/master .git/refs/heads/foo
'
cp .git/refs/heads/master .git/refs/heads/foo
'
'Try to create an stgit branch with an existing git branch by that name' '
'Try to create an stgit branch with an existing git branch by that name' '
'Rename the current stgit branch' \
'Rename the current stgit branch' \
+ '! stg branch -r foo bar
'Try to create a patch in a GIT branch' \
'
'Try to create a patch in a GIT branch' \
'
'Attempt to push the first of those patches without --merged' \
'Attempt to push the first of those patches without --merged' \
'Push the second patch with conflict' \
'
'Push the second patch with conflict' \
'
test $(cat bar2.txt) = "bar2"
'
test $(cat bar2.txt) = "bar2"
'
'Synchronise the first two patches with the master branch (to fail)' \
'
'Synchronise the first two patches with the master branch (to fail)' \
'
+ ! stg sync -B master -a
[ "$(echo $(stg unapplied))" = "" ]
'
[ "$(echo $(stg unapplied))" = "" ]
'
'Synchronise the third patch with the exported series (to fail)' \
'
'Synchronise the third patch with the exported series (to fail)' \
'
- stg sync -s patches-master/series p3
+ ! stg sync -s patches-master/series p3
(cd clone && stg commit && stg new c2 -m c2 &&
echo a >> file && stg refresh)
'
(cd clone && stg commit && stg new c2 -m c2 &&
echo a >> file && stg refresh)
'
'Try to and commit a patch in clone' \
'Try to and commit a patch in clone' \
- '(cd clone && stg pull)'
+ '(cd clone && ! stg pull)'
stg branch stack && stg commit && stg new c2 -m c2 &&
echo a >> file && stg refresh
'
stg branch stack && stg commit && stg new c2 -m c2 &&
echo a >> file && stg refresh
'
'Try to pull/rebase now that stack base has moved' \
'Try to pull/rebase now that stack base has moved' \
test_expect_success \
'Force the pull/rebase, but do not push yet' \
'stg pull --force --nopush'
test_expect_success \
'Force the pull/rebase, but do not push yet' \
'stg pull --force --nopush'
'...check we lost the committed patch' \
'...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' \
'...and check we get a conflict while pushing' \
test `stg applied | wc -l` = 1
'
test `stg applied | wc -l` = 1
'
'Attempt rebase to non-existing commit' \
'
'Attempt rebase to non-existing commit' \
'