Skip to content

Commit 9b42c3a

Browse files
committed
Use test_when_finished in t2702-refresh-rm.sh
The previous method of calling the custom `reset` function between tests resulted in output from `stg pop` and `git reset` leaking to stdout when running tests. Using test_when_finished achieves the same thing, but with the test harness able to properly capture the output of those commands. Signed-off-by: Peter Grayson <[email protected]>
1 parent 8fc8f8e commit 9b42c3a

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

t/t2702-refresh-rm.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ files*.txt
1111
status*.txt
1212
EOF
1313

14-
reset () {
15-
stg pop -a > /dev/null
16-
git reset --hard > /dev/null
17-
}
18-
1914
test_expect_success 'Initialize StGit stack' '
2015
stg init &&
2116
echo x > x.txt &&
@@ -29,6 +24,7 @@ D y.txt
2924
EOF
3025
printf '' > expected1.txt
3126
test_expect_success 'stg rm a file' '
27+
test_when_finished "stg pop -a; git reset --hard"
3228
stg new -m p0 &&
3329
stg rm y.txt &&
3430
stg status > status0.txt &&
@@ -40,14 +36,13 @@ test_expect_success 'stg rm a file' '
4036
test_cmp -w expected0.txt files.txt
4137
'
4238

43-
reset
44-
4539
cat > expected0.txt <<EOF
4640
M x.txt
4741
D y.txt
4842
EOF
4943
printf '' > expected1.txt
5044
test_expect_success 'stg rm a file together with other changes' '
45+
test_when_finished "stg pop -a; git reset --hard"
5146
stg new -m p1 &&
5247
echo x2 >> x.txt &&
5348
stg rm y.txt &&
@@ -60,13 +55,12 @@ test_expect_success 'stg rm a file together with other changes' '
6055
test_cmp -w expected0.txt files.txt
6156
'
6257

63-
reset
64-
6558
cat > expected0.txt <<EOF
6659
D y.txt
6760
EOF
6861
printf '' > expected1.txt
6962
test_expect_success 'rm a file' '
63+
test_when_finished "stg pop -a; git reset --hard"
7064
stg new -m p2 &&
7165
rm y.txt &&
7266
stg status > status0.txt &&
@@ -78,14 +72,13 @@ test_expect_success 'rm a file' '
7872
test_cmp -w expected0.txt files.txt
7973
'
8074

81-
reset
82-
8375
cat > expected0.txt <<EOF
8476
M x.txt
8577
D y.txt
8678
EOF
8779
printf '' > expected1.txt
8880
test_expect_success 'rm a file together with other changes' '
81+
test_when_finished "stg pop -a; git reset --hard"
8982
stg new -m p3 &&
9083
echo x2 >> x.txt &&
9184
rm y.txt &&

0 commit comments

Comments
 (0)