@matheusbsbs / matheus-bagliano / commits / cb78f4f0fe
Fork 0

t4202: abstract away SHA-1-specific constants

Adjust the test so that it computes values for object IDs instead of using hard-coded hashes. Additionally, update the sanitize_output function to sanitize the index lines in diff output, since it's clear from the assertions in question that we are not interested in the specific object IDs. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Dec 21, 2019 at 19:49 UTC cb78f4f0fef7d45c33a22c28fcd575bed66a16d2
1 file changed +65 -62
t/t4202-log.sh
+65 -62
@@ -87,12 +87,12 @@ test_expect_success 'format %w(,1,2)' '
87 '
88
89 cat > expect << EOF
90 -804a787 sixth
91 -394ef78 fifth
92 -5d31159 fourth
93 -2fbe8c0 third
94 -f7dab8e second
95 -3a2fdcb initial
90 +$(git rev-parse --short :/sixth ) sixth
91 +$(git rev-parse --short :/fifth ) fifth
92 +$(git rev-parse --short :/fourth ) fourth
93 +$(git rev-parse --short :/third ) third
94 +$(git rev-parse --short :/second ) second
95 +$(git rev-parse --short :/initial) initial
96 EOF
97 test_expect_success 'oneline' '
98
@@ -173,43 +173,45 @@ test_expect_success 'git config log.follow is overridden by --no-follow' '
173 verbose test "$actual" = "$expect"
174 '
175
176 +# Note that these commits are intentionally listed out of order.
177 +last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
178 cat > expect << EOF
177 -804a787 sixth
178 -394ef78 fifth
179 -5d31159 fourth
179 +$(git rev-parse --short :/sixth ) sixth
180 +$(git rev-parse --short :/fifth ) fifth
181 +$(git rev-parse --short :/fourth) fourth
182 EOF
183 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
182 - git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
184 + git log --no-walk --oneline $last_three > actual &&
185 test_cmp expect actual
186 '
187
188 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
187 - git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
189 + git log --no-walk=sorted --oneline $last_three > actual &&
190 test_cmp expect actual
191 '
192
193 cat > expect << EOF
192 -=== 804a787 sixth
193 -=== 394ef78 fifth
194 -=== 5d31159 fourth
194 +=== $(git rev-parse --short :/sixth ) sixth
195 +=== $(git rev-parse --short :/fifth ) fifth
196 +=== $(git rev-parse --short :/fourth) fourth
197 EOF
198 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
197 - git log --line-prefix="=== " --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
199 + git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
200 test_cmp expect actual
201 '
202
203 cat > expect << EOF
202 -5d31159 fourth
203 -804a787 sixth
204 -394ef78 fifth
204 +$(git rev-parse --short :/fourth) fourth
205 +$(git rev-parse --short :/sixth ) sixth
206 +$(git rev-parse --short :/fifth ) fifth
207 EOF
208 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
207 - git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
209 + git log --no-walk=unsorted --oneline $last_three > actual &&
210 test_cmp expect actual
211 '
212
213 test_expect_success 'git show <commits> leaves list of commits as given' '
212 - git show --oneline -s 5d31159 804a787 394ef78 > actual &&
214 + git show --oneline -s $last_three > actual &&
215 test_cmp expect actual
216 '
217
@@ -957,7 +959,7 @@ cat >expect <<\EOF
959 | |
960 | | diff --git a/reach.t b/reach.t
961 | | new file mode 100644
960 -| | index 0000000..10c9591
962 +| | index BEFORE..AFTER
963 | | --- /dev/null
964 | | +++ b/reach.t
965 | | @@ -0,0 +1 @@
@@ -980,7 +982,7 @@ cat >expect <<\EOF
982 | | |
983 | | | diff --git a/octopus-b.t b/octopus-b.t
984 | | | new file mode 100644
983 -| | | index 0000000..d5fcad0
985 +| | | index BEFORE..AFTER
986 | | | --- /dev/null
987 | | | +++ b/octopus-b.t
988 | | | @@ -0,0 +1 @@
@@ -996,7 +998,7 @@ cat >expect <<\EOF
998 | |
999 | | diff --git a/octopus-a.t b/octopus-a.t
1000 | | new file mode 100644
999 -| | index 0000000..11ee015
1001 +| | index BEFORE..AFTER
1002 | | --- /dev/null
1003 | | +++ b/octopus-a.t
1004 | | @@ -0,0 +1 @@
@@ -1012,7 +1014,7 @@ cat >expect <<\EOF
1014 |
1015 | diff --git a/seventh.t b/seventh.t
1016 | new file mode 100644
1015 -| index 0000000..9744ffc
1017 +| index BEFORE..AFTER
1018 | --- /dev/null
1019 | +++ b/seventh.t
1020 | @@ -0,0 +1 @@
@@ -1046,7 +1048,7 @@ cat >expect <<\EOF
1048 | | | |
1049 | | | | diff --git a/tangle-a b/tangle-a
1050 | | | | new file mode 100644
1049 -| | | | index 0000000..7898192
1051 +| | | | index BEFORE..AFTER
1052 | | | | --- /dev/null
1053 | | | | +++ b/tangle-a
1054 | | | | @@ -0,0 +1 @@
@@ -1068,7 +1070,7 @@ cat >expect <<\EOF
1070 | | | |
1071 | | | | diff --git a/2 b/2
1072 | | | | new file mode 100644
1071 -| | | | index 0000000..0cfbf08
1073 +| | | | index BEFORE..AFTER
1074 | | | | --- /dev/null
1075 | | | | +++ b/2
1076 | | | | @@ -0,0 +1 @@
@@ -1084,7 +1086,7 @@ cat >expect <<\EOF
1086 | | | |
1087 | | | | diff --git a/1 b/1
1088 | | | | new file mode 100644
1087 -| | | | index 0000000..d00491f
1089 +| | | | index BEFORE..AFTER
1090 | | | | --- /dev/null
1091 | | | | +++ b/1
1092 | | | | @@ -0,0 +1 @@
@@ -1100,7 +1102,7 @@ cat >expect <<\EOF
1102 | | | |
1103 | | | | diff --git a/one b/one
1104 | | | | new file mode 100644
1103 -| | | | index 0000000..9a33383
1105 +| | | | index BEFORE..AFTER
1106 | | | | --- /dev/null
1107 | | | | +++ b/one
1108 | | | | @@ -0,0 +1 @@
@@ -1116,7 +1118,7 @@ cat >expect <<\EOF
1118 | | |
1119 | | | diff --git a/a/two b/a/two
1120 | | | deleted file mode 100644
1119 -| | | index 9245af5..0000000
1121 +| | | index BEFORE..AFTER
1122 | | | --- a/a/two
1123 | | | +++ /dev/null
1124 | | | @@ -1 +0,0 @@
@@ -1132,7 +1134,7 @@ cat >expect <<\EOF
1134 | | |
1135 | | | diff --git a/a/two b/a/two
1136 | | | new file mode 100644
1135 -| | | index 0000000..9245af5
1137 +| | | index BEFORE..AFTER
1138 | | | --- /dev/null
1139 | | | +++ b/a/two
1140 | | | @@ -0,0 +1 @@
@@ -1148,7 +1150,7 @@ cat >expect <<\EOF
1150 | |
1151 | | diff --git a/ein b/ein
1152 | | new file mode 100644
1151 -| | index 0000000..9d7e69f
1153 +| | index BEFORE..AFTER
1154 | | --- /dev/null
1155 | | +++ b/ein
1156 | | @@ -0,0 +1 @@
@@ -1165,14 +1167,14 @@ cat >expect <<\EOF
1167 |
1168 | diff --git a/ichi b/ichi
1169 | new file mode 100644
1168 -| index 0000000..9d7e69f
1170 +| index BEFORE..AFTER
1171 | --- /dev/null
1172 | +++ b/ichi
1173 | @@ -0,0 +1 @@
1174 | +ichi
1175 | diff --git a/one b/one
1176 | deleted file mode 100644
1175 -| index 9d7e69f..0000000
1177 +| index BEFORE..AFTER
1178 | --- a/one
1179 | +++ /dev/null
1180 | @@ -1 +0,0 @@
@@ -1187,7 +1189,7 @@ cat >expect <<\EOF
1189 | 1 file changed, 1 insertion(+), 1 deletion(-)
1190 |
1191 | diff --git a/one b/one
1190 -| index 5626abf..9d7e69f 100644
1192 +| index BEFORE..AFTER 100644
1193 | --- a/one
1194 | +++ b/one
1195 | @@ -1 +1 @@
@@ -1204,7 +1206,7 @@ cat >expect <<\EOF
1206
1207 diff --git a/one b/one
1208 new file mode 100644
1207 - index 0000000..5626abf
1209 + index BEFORE..AFTER
1210 --- /dev/null
1211 +++ b/one
1212 @@ -0,0 +1 @@
@@ -1221,7 +1223,8 @@ sanitize_output () {
1223 -e 's/, 0 insertions(+)//' \
1224 -e 's/ 1 files changed, / 1 file changed, /' \
1225 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
1224 - -e 's/, 1 insertions(+)/, 1 insertion(+)/'
1226 + -e 's/, 1 insertions(+)/, 1 insertion(+)/' \
1227 + -e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/'
1228 }
1229
1230 test_expect_success 'log --graph with diff and stats' '
@@ -1247,7 +1250,7 @@ cat >expect <<\EOF
1250 *** | |
1251 *** | | diff --git a/reach.t b/reach.t
1252 *** | | new file mode 100644
1250 -*** | | index 0000000..10c9591
1253 +*** | | index BEFORE..AFTER
1254 *** | | --- /dev/null
1255 *** | | +++ b/reach.t
1256 *** | | @@ -0,0 +1 @@
@@ -1270,7 +1273,7 @@ cat >expect <<\EOF
1273 *** | | |
1274 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1275 *** | | | new file mode 100644
1273 -*** | | | index 0000000..d5fcad0
1276 +*** | | | index BEFORE..AFTER
1277 *** | | | --- /dev/null
1278 *** | | | +++ b/octopus-b.t
1279 *** | | | @@ -0,0 +1 @@
@@ -1286,7 +1289,7 @@ cat >expect <<\EOF
1289 *** | |
1290 *** | | diff --git a/octopus-a.t b/octopus-a.t
1291 *** | | new file mode 100644
1289 -*** | | index 0000000..11ee015
1292 +*** | | index BEFORE..AFTER
1293 *** | | --- /dev/null
1294 *** | | +++ b/octopus-a.t
1295 *** | | @@ -0,0 +1 @@
@@ -1302,7 +1305,7 @@ cat >expect <<\EOF
1305 *** |
1306 *** | diff --git a/seventh.t b/seventh.t
1307 *** | new file mode 100644
1305 -*** | index 0000000..9744ffc
1308 +*** | index BEFORE..AFTER
1309 *** | --- /dev/null
1310 *** | +++ b/seventh.t
1311 *** | @@ -0,0 +1 @@
@@ -1336,7 +1339,7 @@ cat >expect <<\EOF
1339 *** | | | |
1340 *** | | | | diff --git a/tangle-a b/tangle-a
1341 *** | | | | new file mode 100644
1339 -*** | | | | index 0000000..7898192
1342 +*** | | | | index BEFORE..AFTER
1343 *** | | | | --- /dev/null
1344 *** | | | | +++ b/tangle-a
1345 *** | | | | @@ -0,0 +1 @@
@@ -1358,7 +1361,7 @@ cat >expect <<\EOF
1361 *** | | | |
1362 *** | | | | diff --git a/2 b/2
1363 *** | | | | new file mode 100644
1361 -*** | | | | index 0000000..0cfbf08
1364 +*** | | | | index BEFORE..AFTER
1365 *** | | | | --- /dev/null
1366 *** | | | | +++ b/2
1367 *** | | | | @@ -0,0 +1 @@
@@ -1374,7 +1377,7 @@ cat >expect <<\EOF
1377 *** | | | |
1378 *** | | | | diff --git a/1 b/1
1379 *** | | | | new file mode 100644
1377 -*** | | | | index 0000000..d00491f
1380 +*** | | | | index BEFORE..AFTER
1381 *** | | | | --- /dev/null
1382 *** | | | | +++ b/1
1383 *** | | | | @@ -0,0 +1 @@
@@ -1390,7 +1393,7 @@ cat >expect <<\EOF
1393 *** | | | |
1394 *** | | | | diff --git a/one b/one
1395 *** | | | | new file mode 100644
1393 -*** | | | | index 0000000..9a33383
1396 +*** | | | | index BEFORE..AFTER
1397 *** | | | | --- /dev/null
1398 *** | | | | +++ b/one
1399 *** | | | | @@ -0,0 +1 @@
@@ -1406,7 +1409,7 @@ cat >expect <<\EOF
1409 *** | | |
1410 *** | | | diff --git a/a/two b/a/two
1411 *** | | | deleted file mode 100644
1409 -*** | | | index 9245af5..0000000
1412 +*** | | | index BEFORE..AFTER
1413 *** | | | --- a/a/two
1414 *** | | | +++ /dev/null
1415 *** | | | @@ -1 +0,0 @@
@@ -1422,7 +1425,7 @@ cat >expect <<\EOF
1425 *** | | |
1426 *** | | | diff --git a/a/two b/a/two
1427 *** | | | new file mode 100644
1425 -*** | | | index 0000000..9245af5
1428 +*** | | | index BEFORE..AFTER
1429 *** | | | --- /dev/null
1430 *** | | | +++ b/a/two
1431 *** | | | @@ -0,0 +1 @@
@@ -1438,7 +1441,7 @@ cat >expect <<\EOF
1441 *** | |
1442 *** | | diff --git a/ein b/ein
1443 *** | | new file mode 100644
1441 -*** | | index 0000000..9d7e69f
1444 +*** | | index BEFORE..AFTER
1445 *** | | --- /dev/null
1446 *** | | +++ b/ein
1447 *** | | @@ -0,0 +1 @@
@@ -1455,14 +1458,14 @@ cat >expect <<\EOF
1458 *** |
1459 *** | diff --git a/ichi b/ichi
1460 *** | new file mode 100644
1458 -*** | index 0000000..9d7e69f
1461 +*** | index BEFORE..AFTER
1462 *** | --- /dev/null
1463 *** | +++ b/ichi
1464 *** | @@ -0,0 +1 @@
1465 *** | +ichi
1466 *** | diff --git a/one b/one
1467 *** | deleted file mode 100644
1465 -*** | index 9d7e69f..0000000
1468 +*** | index BEFORE..AFTER
1469 *** | --- a/one
1470 *** | +++ /dev/null
1471 *** | @@ -1 +0,0 @@
@@ -1477,7 +1480,7 @@ cat >expect <<\EOF
1480 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1481 *** |
1482 *** | diff --git a/one b/one
1480 -*** | index 5626abf..9d7e69f 100644
1483 +*** | index BEFORE..AFTER 100644
1484 *** | --- a/one
1485 *** | +++ b/one
1486 *** | @@ -1 +1 @@
@@ -1494,7 +1497,7 @@ cat >expect <<\EOF
1497 ***
1498 *** diff --git a/one b/one
1499 *** new file mode 100644
1497 -*** index 0000000..5626abf
1500 +*** index BEFORE..AFTER
1501 *** --- /dev/null
1502 *** +++ b/one
1503 *** @@ -0,0 +1 @@
@@ -1709,10 +1712,10 @@ test_expect_success 'set up --source tests' '
1712 '
1713
1714 test_expect_success 'log --source paints branch names' '
1712 - cat >expect <<-\EOF &&
1713 - 09e12a9 source-b three
1714 - 8e393e1 source-a two
1715 - 1ac6c77 source-b one
1715 + cat >expect <<-EOF &&
1716 + $(git rev-parse --short :/three) source-b three
1717 + $(git rev-parse --short :/two ) source-a two
1718 + $(git rev-parse --short :/one ) source-b one
1719 EOF
1720 git log --oneline --source source-a source-b >actual &&
1721 test_cmp expect actual
@@ -1720,19 +1723,19 @@ test_expect_success 'log --source paints branch names' '
1723
1724 test_expect_success 'log --source paints tag names' '
1725 git tag -m tagged source-tag &&
1723 - cat >expect <<-\EOF &&
1724 - 09e12a9 source-tag three
1725 - 8e393e1 source-a two
1726 - 1ac6c77 source-tag one
1726 + cat >expect <<-EOF &&
1727 + $(git rev-parse --short :/three) source-tag three
1728 + $(git rev-parse --short :/two ) source-a two
1729 + $(git rev-parse --short :/one ) source-tag one
1730 EOF
1731 git log --oneline --source source-tag source-a >actual &&
1732 test_cmp expect actual
1733 '
1734
1735 test_expect_success 'log --source paints symmetric ranges' '
1733 - cat >expect <<-\EOF &&
1734 - 09e12a9 source-b three
1735 - 8e393e1 source-a two
1736 + cat >expect <<-EOF &&
1737 + $(git rev-parse --short :/three) source-b three
1738 + $(git rev-parse --short :/two ) source-a two
1739 EOF
1740 git log --oneline --source source-a...source-b >actual &&
1741 test_cmp expect actual