Skip to content

Commit 15b808d

Browse files
avargitster
authored andcommitted
"lib-diff" tests: make "README" and "COPYING" test data smaller
Follow-up the change in 459b8d2 (tests: do not borrow from COPYING and README from the real source, 2015-02-15) by not shipping a full copy of older versions of the top-level "COPYING" and "README" files. The tests that use them just need the small blurb at the top of "COPYING" as test data, or mock data that's dissimilar. Let's provide that with a "COPYING_test_data" function instead. We're not replacing this with some other generic test data (e.g. "lorum ipsum") because these tests require test file header to be the old "COPYING" file. See e.g. "t4003-diff-rename-1.sh" which changes the file, and then does full "test_cmp" comparisons on the resulting "git diff" output. This change only changes tests that used the "lib-diff.sh" library, but splits up what they need into a new "lib-diff-data.sh". A subsequent commit will change related tests that were missed in 459b8d2. For the test in "t4008-diff-break-rewrite.sh" the "README" file can go away in favor of echoing the line "some dissimilar content" to a file in the one test that needed it. The point of that test is to start with files "A" and "B", and then have A be more similar to the state of "B" than to its old version (by copying over the content from the "COPYING" file). Just comparing the pre-image of "some dissimilar content" and later a munged version of the "COPYING" output serves that purpose. While we're at it get rid of a stray "echo $tree" debugging line added in 15d061b ([PATCH] Fix the way diffcore-rename records unremoved source., 2005-05-27), and stop calling "hash-object" to get the hash of an object we've just added to the index. We can instead extract that information from the index itself with "rev-parse". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af6d1d6 commit 15b808d

10 files changed

+34
-419
lines changed

t/.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
t[0-9][0-9][0-9][0-9]/* -whitespace
22
/chainlint/*.expect eol=lf
3-
/lib-diff/* eol=lf
43
/t0110/url-* binary
54
/t3206/* eol=lf
65
/t3900/*.txt eol=lf

t/lib-diff-data.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
COPYING_test_data () {
2+
cat <<\EOF
3+
4+
Note that the only valid version of the GPL as far as this project
5+
is concerned is _this_ particular version of the license (ie v2, not
6+
v2.2 or v3.x or whatever), unless explicitly otherwise stated.
7+
8+
HOWEVER, in order to allow a migration to GPLv3 if that seems like
9+
a good idea, I also ask that people involved with the project make
10+
their preferences known. In particular, if you trust me to make that
11+
decision, you might note so in your copyright message, ie something
12+
like
13+
14+
This file is licensed under the GPL v2, or a later version
15+
at the discretion of Linus.
16+
17+
might avoid issues. But we can also just decide to synchronize and
18+
contact all copyright holders on record if/when the occasion arises.
19+
20+
Linus Torvalds
21+
EOF
22+
}

t/lib-diff.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
. "$TEST_DIRECTORY"/lib-diff-data.sh
2+
13
:
24

35
sanitize_diff_raw='/^:/s/ '"\($OID_REGEX\)"' '"\($OID_REGEX\)"' \([A-Z]\)[0-9]* / \1 \2 \3# /'

t/lib-diff/COPYING

Lines changed: 0 additions & 361 deletions
This file was deleted.

t/lib-diff/README

Lines changed: 0 additions & 46 deletions
This file was deleted.

t/t4003-diff-rename-1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_description='More rename detection
1111

1212
test_expect_success \
1313
'prepare reference tree' \
14-
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
14+
'COPYING_test_data >COPYING &&
1515
echo frotz >rezrov &&
1616
git update-index --add COPYING rezrov &&
1717
tree=$(git write-tree) &&
@@ -99,7 +99,7 @@ test_expect_success \
9999

100100
test_expect_success \
101101
'prepare work tree once again' \
102-
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
102+
'COPYING_test_data >COPYING &&
103103
git update-index --add --remove COPYING COPYING.1'
104104

105105
# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,

t/t4005-diff-rename-2.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test_description='Same rename detection as t4003 but testing diff-raw.'
99
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
1010

1111
test_expect_success 'setup reference tree' '
12-
cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
12+
COPYING_test_data >COPYING &&
1313
echo frotz >rezrov &&
1414
git update-index --add COPYING rezrov &&
1515
tree=$(git write-tree) &&
@@ -64,7 +64,7 @@ test_expect_success 'validate output from rename/copy detection (#2)' '
6464
# nows how to say Copy.
6565

6666
test_expect_success 'validate output from rename/copy detection (#3)' '
67-
cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
67+
COPYING_test_data >COPYING &&
6868
git update-index --add --remove COPYING COPYING.1 &&
6969
7070
cat <<-EOF >expected &&

t/t4007-rename-3.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ test_description='Rename interaction with pathspec.
1111

1212
test_expect_success 'prepare reference tree' '
1313
mkdir path0 path1 &&
14-
cp "$TEST_DIRECTORY"/lib-diff/COPYING path0/COPYING &&
14+
COPYING_test_data >path0/COPYING &&
1515
git update-index --add path0/COPYING &&
1616
tree=$(git write-tree) &&
17-
echo $tree
17+
blob=$(git rev-parse :path0/COPYING)
1818
'
1919

20-
blob=$(git hash-object "$TEST_DIRECTORY/lib-diff/COPYING")
2120
test_expect_success 'prepare work tree' '
2221
cp path0/COPYING path1/COPYING &&
2322
git update-index --add --remove path0/COPYING path1/COPYING

t/t4008-diff-break-rewrite.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Further, with -B and -M together, these should turn into two renames.
2525
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
2626

2727
test_expect_success setup '
28-
cat "$TEST_DIRECTORY"/lib-diff/README >file0 &&
29-
cat "$TEST_DIRECTORY"/lib-diff/COPYING >file1 &&
28+
echo some dissimilar content >file0 &&
29+
COPYING_test_data >file1 &&
3030
blob0_id=$(git hash-object file0) &&
3131
blob1_id=$(git hash-object file1) &&
3232
git update-index --add file0 file1 &&

t/t4009-diff-rename-4.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_description='Same rename detection as t4003 but testing diff-raw -z.
1111

1212
test_expect_success \
1313
'prepare reference tree' \
14-
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
14+
'COPYING_test_data >COPYING &&
1515
echo frotz >rezrov &&
1616
git update-index --add COPYING rezrov &&
1717
orig=$(git hash-object COPYING) &&
@@ -81,7 +81,7 @@ test_expect_success \
8181

8282
test_expect_success \
8383
'prepare work tree once again' \
84-
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
84+
'COPYING_test_data >COPYING &&
8585
git update-index --add --remove COPYING COPYING.1'
8686

8787
git diff-index -z -C --find-copies-harder $tree >current

0 commit comments

Comments
 (0)