Skip to content

Commit d871111

Browse files
committed
Repace diff with test_cmp in several tests
Several `diff` invocations are replaced with `test_cmp`, which has the advantage of showing any differences in the test log when the comparison fails. Signed-off-by: Peter Grayson <[email protected]>
1 parent 1db5f0c commit d871111

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

t/t0006-patches.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ EOF
4242
test_expect_success 'Modifications and no file args' '
4343
echo "six" >> even.txt &&
4444
stg patches > mod-no-files.log &&
45-
diff -u mod-no-files.log expected-evens.log &&
45+
test_cmp mod-no-files.log expected-evens.log &&
4646
git checkout even.txt
4747
'
4848

@@ -57,16 +57,16 @@ test_expect_success 'Patches relative to dir' '
5757
(
5858
cd dir0 &&
5959
stg patches dir1/odd.txt > relative-odd.log &&
60-
diff -u relative-odd.log ../expected-odds.log &&
60+
test_cmp relative-odd.log ../expected-odds.log &&
6161
echo "seven" > dir1/odd.txt &&
6262
stg patches > relative-odd-mod.log &&
63-
diff -u relative-odd-mod.log ../expected-odds.log &&
63+
test_cmp relative-odd-mod.log ../expected-odds.log &&
6464
stg patches ../even.txt > relative-even.log &&
65-
diff -u relative-even.log ../expected-evens.log &&
65+
test_cmp relative-even.log ../expected-evens.log &&
6666
git checkout dir1/odd.txt &&
6767
echo "six" >> ../even.txt &&
6868
stg patches > relative-even-mod.log &&
69-
diff -u relative-even-mod.log ../expected-evens.log &&
69+
test_cmp relative-even-mod.log ../expected-evens.log &&
7070
git checkout ../even.txt
7171
)
7272
'

t/t0007-files.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ EOF
3939

4040
test_expect_success 'No patch args' '
4141
stg files > b-c.log &&
42-
diff -u b-c.log expected-b-c.log &&
42+
test_cmp b-c.log expected-b-c.log &&
4343
stg files -- patch-b-c > b-c2.log &&
44-
diff -u b-c.log b-c2.log
44+
test_cmp b-c.log b-c2.log
4545
'
4646

4747
cat > expected-a-b-bare.log <<EOF
@@ -51,7 +51,7 @@ EOF
5151

5252
test_expect_success 'Bare file names' '
5353
stg files --bare patch-a-b > a-b-bare.log &&
54-
diff -u a-b-bare.log expected-a-b-bare.log
54+
test_cmp a-b-bare.log expected-a-b-bare.log
5555
'
5656

5757
cat > expected-b-c-stat.log <<EOF
@@ -63,7 +63,7 @@ EOF
6363

6464
test_expect_success 'Stat output' '
6565
stg files --stat patch-b-c > b-c-stat.log &&
66-
diff -u b-c-stat.log expected-b-c-stat.log
66+
test_cmp b-c-stat.log expected-b-c-stat.log
6767
'
6868

6969
test_expect_success 'Empty patch' '
@@ -81,7 +81,7 @@ test_expect_success 'Moved file' '
8181
git mv a.txt d.txt &&
8282
stg refresh &&
8383
stg files > a-d.log &&
84-
diff -u a-d.log expected-a-d.log
84+
test_cmp a-d.log expected-a-d.log
8585
'
8686

8787
cat > expected-a-d-bare.log <<EOF
@@ -91,7 +91,7 @@ EOF
9191

9292
test_expect_success 'Moved file bare' '
9393
stg files --bare -- patch-a-d > a-d-bare.log &&
94-
diff -u a-d-bare.log expected-a-d-bare.log
94+
test_cmp a-d-bare.log expected-a-d-bare.log
9595
'
9696

9797
test_done

t/t2400-diff.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ EOF
3030

3131
test_expect_success 'Diff stat with some local changes' '
3232
stg diff --stat > add-foo-stat.diff &&
33-
diff -u add-foo-stat.diff expected-add-foo-stat.diff
33+
test_cmp add-foo-stat.diff expected-add-foo-stat.diff
3434
'
3535

3636
test_expect_success 'Diff with bad diff-opts' '
@@ -44,7 +44,7 @@ test_expect_success 'Initialize StGit stuff' '
4444

4545
test_expect_success 'Diff with some local changes' '
4646
stg diff > add-foo2.diff &&
47-
diff -u add-foo.diff add-foo2.diff
47+
test_cmp add-foo.diff add-foo2.diff
4848
'
4949

5050
test_expect_success 'Refresh patch' '
@@ -77,9 +77,9 @@ test_expect_success 'Add more patches' '
7777

7878
test_expect_success 'Diff revs parent-child' '
7979
stg diff -r foo..bar > foo-bar.diff &&
80-
diff -u foo-bar.diff bar.diff &&
80+
test_cmp foo-bar.diff bar.diff &&
8181
stg diff -r foo..bar --stat > foo-bar-stat.diff &&
82-
diff -u foo-bar-stat.diff bar-stat.diff
82+
test_cmp foo-bar-stat.diff bar-stat.diff
8383
'
8484

8585
test_expect_success 'Diff invalid rev patch name' '
@@ -108,11 +108,11 @@ EOF
108108
test_expect_success 'Diff range just rev1' '
109109
stg diff -r bar.. > bar-head.diff &&
110110
stg diff -r bar.. --stat > bar-head-stat.diff &&
111-
diff -u bar-head-stat.diff expected-bar-head-stat.diff &&
111+
test_cmp bar-head-stat.diff expected-bar-head-stat.diff &&
112112
stg diff -r bar..p4 > bar-p4.diff &&
113-
diff -u bar-head.diff bar-p4.diff &&
113+
test_cmp bar-head.diff bar-p4.diff &&
114114
stg diff -r bar > bar-only.diff &&
115-
diff -u bar-head.diff bar-only.diff
115+
test_cmp bar-head.diff bar-only.diff
116116
'
117117

118118
test_expect_success 'Diff range with path' '
@@ -129,9 +129,9 @@ test_expect_success 'Diff from dir' '
129129
(
130130
cd dir0 &&
131131
stg diff > threes2.diff &&
132-
diff -u ../threes.diff threes2.diff &&
132+
test_cmp ../threes.diff threes2.diff &&
133133
stg diff ../bar.txt > threes-bar2.diff &&
134-
diff -u ../threes-bar.diff threes-bar2.diff &&
134+
test_cmp ../threes-bar.diff threes-bar2.diff &&
135135
test -z "$(stg diff dir1/baz.txt)"
136136
)
137137
'
@@ -161,7 +161,7 @@ EOF
161161

162162
test_expect_success 'Binary diff stat' '
163163
stg diff --stat > num-stat.diff &&
164-
diff -u num-stat.diff expected-num-stat.diff
164+
test_cmp num-stat.diff expected-num-stat.diff
165165
'
166166

167167
test_expect_success 'Refresh binary' '
@@ -171,12 +171,12 @@ test_expect_success 'Refresh binary' '
171171

172172
test_expect_success 'Binary diff range' '
173173
stg diff -r p5..p6 > num2.diff &&
174-
diff -u num.diff num2.diff
174+
test_cmp num.diff num2.diff
175175
'
176176

177177
test_expect_success 'Binary diff range with --binary' '
178178
stg diff -r p5..p6 --diff-opts=--binary > num-binary2.diff &&
179-
diff -u num-binary.diff num-binary2.diff
179+
test_cmp num-binary.diff num-binary2.diff
180180
'
181181

182182
test_done

t/t3200-non-ascii-filenames.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ cat > expected.txt <<EOF
4242
EOF
4343
test_expect_success 'Status of modified non-ASCII file' '
4444
stg status > output.txt &&
45-
diff -u expected.txt output.txt
45+
test_cmp expected.txt output.txt
4646
'
4747

4848
test_expect_success 'Refresh changes to non-ASCII file' '
@@ -53,7 +53,7 @@ cat > expected.txt <<EOF
5353
EOF
5454
test_expect_success 'Status after refresh' '
5555
stg status > output.txt &&
56-
diff -u expected.txt output.txt
56+
test_cmp expected.txt output.txt
5757
'
5858

5959
test_done

0 commit comments

Comments
 (0)