mask necessary whitespace policy violations in test scripts
All of these violations are necessary parts of the tests (which are generally checking the behavior of trailing whitespace, or contain diff fragments with empty lines). Our solution is two-fold: 1. Process input with whitespace problems using tr. This has the added bonus that it becomes very obvious where the bogus whitespace is intended to go. 2. Move large diff fragments into their own supplemental files. This gets rid of the whitespace problem, since supplemental files are not checked, and it also makes the test script a bit easier to read. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 14, 2008 at 03:26 UTC
74f16b0c6fece88f585f9556fa1d3a7406e7a42e
8 files changed
+131
-136
t/t3800-mktag.sh
+2
-2
@@ -241,11 +241,11 @@ check_verify_failure 'disallow spaces in tag email' \
241
############################################################
242
# 17. disallow missing tag timestamp
243
244
-cat >tag.sig <<EOF
244
+tr '_' ' ' >tag.sig <<EOF
245
object $head
246
type commit
247
tag mytag
248
-tagger T A Gger <tagger@example.com>
248
+tagger T A Gger <tagger@example.com>__
249
250
EOF
251
t/t4015-diff-whitespace.sh
+4
-4
@@ -62,16 +62,16 @@ EOF
62
63
git update-index x
64
65
-cat << EOF > x
65
+tr '_' ' ' << EOF > x
66
whitespace at beginning
67
whitespace change
68
white space in the middle
69
-whitespace at end
69
+whitespace at end__
70
unchanged line
71
CR at end
72
EOF
73
74
-tr 'Q' '\015' << EOF > expect
74
+tr 'Q_' '\015 ' << EOF > expect
75
diff --git a/x b/x
76
index d99af23..8b32fb5 100644
77
--- a/x
@@ -84,7 +84,7 @@ index d99af23..8b32fb5 100644
84
+ whitespace at beginning
85
+whitespace change
86
+white space in the middle
87
-+whitespace at end
87
++whitespace at end__
88
unchanged line
89
-CR at endQ
90
+CR at end
t/t4109-apply-multifrag.sh
+4
-128
@@ -9,134 +9,10 @@ test_description='git apply test patches with multiple fragments.
9
'
10
. ./test-lib.sh
11
12
-# setup
13
-
14
-cat > patch1.patch <<\EOF
15
-diff --git a/main.c b/main.c
16
-new file mode 100644
17
---- /dev/null
18
-+++ b/main.c
19
-@@ -0,0 +1,23 @@
20
-+#include <stdio.h>
21
-+
22
-+int func(int num);
23
-+void print_int(int num);
24
-+
25
-+int main() {
26
-+ int i;
27
-+
28
-+ for (i = 0; i < 10; i++) {
29
-+ print_int(func(i));
30
-+ }
31
-+
32
-+ return 0;
33
-+}
34
-+
35
-+int func(int num) {
36
-+ return num * num;
37
-+}
38
-+
39
-+void print_int(int num) {
40
-+ printf("%d", num);
41
-+}
42
-+
43
-EOF
44
-cat > patch2.patch <<\EOF
45
-diff --git a/main.c b/main.c
46
---- a/main.c
47
-+++ b/main.c
48
-@@ -1,7 +1,9 @@
49
-+#include <stdlib.h>
50
- #include <stdio.h>
51
-
52
- int func(int num);
53
- void print_int(int num);
54
-+void print_ln();
55
-
56
- int main() {
57
- int i;
58
-@@ -10,6 +12,8 @@
59
- print_int(func(i));
60
- }
61
-
62
-+ print_ln();
63
-+
64
- return 0;
65
- }
66
-
67
-@@ -21,3 +25,7 @@
68
- printf("%d", num);
69
- }
70
-
71
-+void print_ln() {
72
-+ printf("\n");
73
-+}
74
-+
75
-EOF
76
-cat > patch3.patch <<\EOF
77
-diff --git a/main.c b/main.c
78
---- a/main.c
79
-+++ b/main.c
80
-@@ -1,9 +1,7 @@
81
--#include <stdlib.h>
82
- #include <stdio.h>
83
-
84
- int func(int num);
85
- void print_int(int num);
86
--void print_ln();
87
-
88
- int main() {
89
- int i;
90
-@@ -12,8 +10,6 @@
91
- print_int(func(i));
92
- }
93
-
94
-- print_ln();
95
--
96
- return 0;
97
- }
98
-
99
-@@ -25,7 +21,3 @@
100
- printf("%d", num);
101
- }
102
-
103
--void print_ln() {
104
-- printf("\n");
105
--}
106
--
107
-EOF
108
-cat > patch4.patch <<\EOF
109
-diff --git a/main.c b/main.c
110
---- a/main.c
111
-+++ b/main.c
112
-@@ -1,13 +1,14 @@
113
- #include <stdio.h>
114
-
115
- int func(int num);
116
--void print_int(int num);
117
-+int func2(int num);
118
-
119
- int main() {
120
- int i;
121
-
122
- for (i = 0; i < 10; i++) {
123
-- print_int(func(i));
124
-+ printf("%d", func(i));
125
-+ printf("%d", func3(i));
126
- }
127
-
128
- return 0;
129
-@@ -17,7 +18,7 @@
130
- return num * num;
131
- }
132
-
133
--void print_int(int num) {
134
-- printf("%d", num);
135
-+int func2(int num) {
136
-+ return num * num * num;
137
- }
138
-
139
-EOF
12
+cp ../t4109/patch1.patch .
13
+cp ../t4109/patch2.patch .
14
+cp ../t4109/patch3.patch .
15
+cp ../t4109/patch4.patch .
16
17
test_expect_success "S = git apply (1)" \
18
'git apply patch1.patch patch2.patch'
t/t4109/patch1.patch
new
+28
@@ -0,0 +1,28 @@
1
+diff --git a/main.c b/main.c
2
+new file mode 100644
3
+--- /dev/null
4
++++ b/main.c
5
+@@ -0,0 +1,23 @@
6
++#include <stdio.h>
7
++
8
++int func(int num);
9
++void print_int(int num);
10
++
11
++int main() {
12
++ int i;
13
++
14
++ for (i = 0; i < 10; i++) {
15
++ print_int(func(i));
16
++ }
17
++
18
++ return 0;
19
++}
20
++
21
++int func(int num) {
22
++ return num * num;
23
++}
24
++
25
++void print_int(int num) {
26
++ printf("%d", num);
27
++}
28
++
t/t4109/patch2.patch
new
+30
@@ -0,0 +1,30 @@
1
+diff --git a/main.c b/main.c
2
+--- a/main.c
3
++++ b/main.c
4
+@@ -1,7 +1,9 @@
5
++#include <stdlib.h>
6
+ #include <stdio.h>
7
+
8
+ int func(int num);
9
+ void print_int(int num);
10
++void print_ln();
11
+
12
+ int main() {
13
+ int i;
14
+@@ -10,6 +12,8 @@
15
+ print_int(func(i));
16
+ }
17
+
18
++ print_ln();
19
++
20
+ return 0;
21
+ }
22
+
23
+@@ -21,3 +25,7 @@
24
+ printf("%d", num);
25
+ }
26
+
27
++void print_ln() {
28
++ printf("\n");
29
++}
30
++
t/t4109/patch3.patch
new
+31
@@ -0,0 +1,31 @@
1
+cat > patch3.patch <<\EOF
2
+diff --git a/main.c b/main.c
3
+--- a/main.c
4
++++ b/main.c
5
+@@ -1,9 +1,7 @@
6
+-#include <stdlib.h>
7
+ #include <stdio.h>
8
+
9
+ int func(int num);
10
+ void print_int(int num);
11
+-void print_ln();
12
+
13
+ int main() {
14
+ int i;
15
+@@ -12,8 +10,6 @@
16
+ print_int(func(i));
17
+ }
18
+
19
+- print_ln();
20
+-
21
+ return 0;
22
+ }
23
+
24
+@@ -25,7 +21,3 @@
25
+ printf("%d", num);
26
+ }
27
+
28
+-void print_ln() {
29
+- printf("\n");
30
+-}
31
+-
t/t4109/patch4.patch
new
+30
@@ -0,0 +1,30 @@
1
+diff --git a/main.c b/main.c
2
+--- a/main.c
3
++++ b/main.c
4
+@@ -1,13 +1,14 @@
5
+ #include <stdio.h>
6
+
7
+ int func(int num);
8
+-void print_int(int num);
9
++int func2(int num);
10
+
11
+ int main() {
12
+ int i;
13
+
14
+ for (i = 0; i < 10; i++) {
15
+- print_int(func(i));
16
++ printf("%d", func(i));
17
++ printf("%d", func3(i));
18
+ }
19
+
20
+ return 0;
21
+@@ -17,7 +18,7 @@
22
+ return num * num;
23
+ }
24
+
25
+-void print_int(int num) {
26
+- printf("%d", num);
27
++int func2(int num) {
28
++ return num * num * num;
29
+ }
30
+
t/t4119-apply-config.sh
+2
-2
@@ -19,12 +19,12 @@ test_expect_success setup '
19
'
20
21
# Also handcraft GNU diff output; note this has trailing whitespace.
22
-cat >gpatch.file <<\EOF &&
22
+tr '_' ' ' >gpatch.file <<\EOF &&
23
--- file1 2007-02-21 01:04:24.000000000 -0800
24
+++ file1+ 2007-02-21 01:07:44.000000000 -0800
25
@@ -1 +1 @@
26
-A
27
-+B
27
++B_
28
EOF
29
30
sed -e 's|file1|sub/&|' gpatch.file >gpatch-sub.file &&