File: srctest

package info (click to toggle)
simple-revision-control 1.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: python: 2,675; sh: 1,810; makefile: 69
file content (2221 lines) | stat: -rwxr-xr-x 63,606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
#!/bin/sh
# SPDX-FileCopyrightText: Copyright Eric S. Raymond <esr@thyrsus.com>
# SPDX-License-Identifier: BSD-2-Clause
#
# Regression tester for SRC.
#
# Emits messages in TAP (Test Anything Protocol).
#
# Use -b to test with a specified back end, rcs or sccs
# Use -e to test with an alternate src version
# Use -l to set a log-redirect option on src while tests are running
# Use -p to test with a specified Python interpreter, python2 or python3
# Use -t to put test files and masters at a fixed location, not removing on exit
# Use -c to do coverage analysis; the argument is the coverage data filename
#
# If the -b and -n options are not forced, all combinations
# are tested sequentially.

historify () {
    case $backend in
	rcs) history=.src/$1,v ;;
	sccs) history=SCCS/s.$1 ;;
	*) echo "srctest: unsupported backend $backend"
    esac
}

nuke() {
    rm -f "$1" ".src/$1,v" "RCS/$1,v" "SCCS/s.$1"
}

fresh_start() {
    rm -f .src/* RCS/* SCCS/*
}

# No dependencies on master name formats after this like

# Set the umask for a bit of defensiveness
umask 0077

# Set the PATH to include the current directory, so the repository
# head version of src can always be tested.
PATH="$(pwd)":$PATH

backend=""
python=""
testmode=no
testcount=1
passed=""
logfile=""
expect_empty="-e"

while getopts :b:c:e:l:p:t opt
do
    case $opt in
	b) backend=$OPTARG;;
	c) coverage erase;
	   src="coverage run -a --data-file=$(pwd)/$OPTARG $(pwd)/src"
	   logfile=/dev/null
	   passed="-L /dev/null -d -d -d -d"
	   expect_empty=""
	   ;;
	e) src=$OPTARG;;
	l) logfile="$(pwd)/$OPTARG"; echo "# Start $(date):" >"${logfile}";;
	p) python=$OPTARG;;
	t) testmode=yes;;
	*) echo "srctest: unknown option"; exit 1;;
    esac
done
# shellcheck disable=SC2004
shift $(($OPTIND - 1))

$backend >/dev/null 2>&1
if [ "$?" = 127 ]
then
    echo "not ok ${testcount} - backend ${backend} is missing."
    testcount=$((testcount + 1))
    exit 1
fi

if [ -z "$src" ]
then
    src="${python} ${PWD}/src"
fi

# Adapt if there's no python2 in the environment
if ! command -v "python2" >/dev/null
then
    python=python3
fi

# Generic TAP functions begin here

# The tap* functions are a mini-framework for controlled execution of
# CLI tests.  They ship reports in TAP format to stdout.  If the
# variable $logfile is set, they will also append stanza headers to
# the specified logfile.
#
# The point of these functions is twfold: to give us TAP logging of
# test outcomes to standard output, and so that any debug logging
# produced by the tool running under taptest/tapdiff control appears
# *after* a stanza header identifying the test.
#
# They are intended to be used in a particular pattern so they will
# produce useful stanzas in the logfile. First, call one of the
# primary functions that generates a new section - taplog, taptest, or
# tapdiff. Then call tapgrep and tapcheck to run as many auxiliary
# tests as you would like.
#
# The test group labels aren't used yet (except for being reported in
# the test log if $logfile is set). In the future they may be used to
# allow running only subspans of an entire test sequence.  Don't
# assume that the existence of generated test files soans the
# boundaries defined by a change in group label.

# If you want to change where command captures and diffs live, modifying
# this variable will do it.
tap_capture="/tmp/tap$$"

# Set this to add a fixed preamble to every TAP message
tap_preamble=""

# Options to pass diff.
tap_diffopts="--label Expected --label Actual -u"

# Start a new log stanza. First argument is the group label, second is the
# legend that later functions should use to report success or failure.
taplog() {
    label="$1"
    legend="$2"
    if [ "${logfile}" ]
    then
	echo "# ${label} ${tap_preamble}${legend}" >>"${logfile}"
    fi
}

# Produce a TAP line from the return status of the last command
# executed.  Does not start a new log stanza. First argument is the
# group label. Second is the command return status to dispatch on, 0
# for success and any other value for failure. Third is the legend
# that later functions should use to report success or failure.
# Fourth, if given, is the name of a capture of the command's stdout
# and stderr.
#
# If the command return is nonzero, the captured output has been
# passed, and the size of the capture is nonzero, the diff is dumped
# as a YAML attachment conforming to TAP.  Beginning the command with "!"
# allows an expected failure status to be processed returning success.
#
# The -d option forces the capture to be dumped even on command success.
# The -e option reports failure if the capture is nonempty.
tapcheck() {
    debug="no"
    need_empty=""
    while getopts :de opt
    do
	case $opt in
	    d) debug=yes;;
	    e) need_empty="-e";;
	    *) echo "not ok ${testcount} - unknown option in tapcheck"; exit 1;;
	esac
    done
    # shellcheck disable=SC2004
    shift $(($OPTIND - 1))
    label="$1"
    status="$2"
    legend="$3"
    outfile="$4"
    case "${status}" in
	0) ;;
	*) echo "not ok ${testcount} - ${tap_preamble}${legend} failed";
	   if [ -n "${outfile}" ]
	   then
	       echo "  --- |"
	       echo "  Return status ${status}"
	       sed <"${outfile}" -e 's/^/  /'
	       echo "  ..."
	   fi
	   exit 1
	   ;;
    esac

    if [ "${need_empty}" = "-e" ] && [ -n "${outfile}" ] && [ -s "${outfile}" ]
    then
	echo "not ok ${testcount} - ${tap_preamble}${legend} had unexpected nonempty output.";
	echo "  --- |"
	echo "  Return status ${status}"
	sed <"${outfile}" -e 's/^/  /'
	echo "  ..."
	exit 1
    fi
    
    echo "ok ${testcount} - ${tap_preamble}${legend} succeeded"
    if [ "${debug}" = "yes" ] && [ -n "${outfile}" ] && [ -s "${outfile}" ]
    then
	echo "  --- |"
	echo "  Return status ${status}"
	sed <"${outfile}" -e 's/^/  /'
	echo "  ..."
    fi

    testcount=$((testcount + 1))
}

# Run a command with stdout and stderr capture.  Starts a new log
# stanza. First argument is the group label. Second is the legend that
# later functions should use to report success or failure.
#
# All later arguments are treated as a shell command to be executed,
# with standard output and standard error captured as
# ${tap_capture}out. The command is deemed to succeed if its return status
# is 0 and to fail otherwise; if it fails, the capture is dumped as a
# YAML attachment conforming to TAP.  Beginning the command with "!"
# allows an expected failure status to be processed returning success.
#
# WARNING: Strings in taptest command lines have to be quoted twice;
# one layer is stripped off by normal shell expansion, the second
# removed by the eval this function uses internally.
#
# The -d option forces that capture to be dumped even on command success.
# The -e option reports failure if the capture is nonempty.
taptest() {
    debug=""
    need_empty=""
    while getopts :de opt
    do
	case $opt in
	    d) debug="-d";;
	    e) need_empty="-e";;
	    *) echo "not ok ${testcount} - unknown option in taptest"; exit 1;;
	esac
    done
    # shellcheck disable=SC2004
    shift $(($OPTIND - 1))
    label="$1"
    legend="$2"
    shift
    shift
    taplog "${label}" "${legend}"
    # shellcheck disable=SC2086,SC2048
    eval $* >${tap_capture}out 2>&1
    # shellcheck disable=SC2086
    tapcheck ${debug} ${need_empty} internal $? "${legend}" "${tap_capture}out"
}

# Run a command, diffing the output against a specified checkfile.
# Starts a new log stanza. First argument is the group label.
# Second argument is the checkfile of expected output; if
# the actual output differs, the difference is dumped as a YAML
# attachment conforming to TAP. Third argument is the legend to be
# used in reporting success or failure. 
#
# All later arguments are treated as a shell command to be executed,
# with standard output and standard error captured as
# ${tap_capture}out. The command is deemed to succeed the diff bwtween the
# capture and the checkfile is empty and to fail otherwise; if it
# fails, the diff is dumped as a YAML attachment conforming to TAP.
#
# WARNING: Strings in tapdiff command lines have to be quoted twice;
# one layer is stripped off by normal shell expansion, the second
# removed by the eval this functions uses internally.
#
# With the -f option, pass the command output through the specified
# filter before diffing.
tapdiff () {
    filter="cat"
    if [ "$1" = "-f" ]
    then
	filter="$2"
	shift
	shift
    fi
    label="$1"
    checkfile="$2"
    legend="$3"
    shift
    shift
    shift
    taplog "${label}" "${legend}"
    # shellcheck disable=SC2086,SC2048
    eval $* >${tap_capture}out 2>&1
    case $? in
	0) ;;
	*) echo "not ok ${testcount} - ${tap_preamble}${legend} command failed";
	   echo "  --- |"
	   sed <"${tap_capture}out" -e 's/^/  /'
	   echo "  ..."
	   exit 1
	   ;;
    esac
    # shellcheck disable=SC2086
    diff ${tap_diffopts} "${checkfile}" ${tap_capture}out | ${filter} >${tap_capture}diff
    if [ ! -s ${tap_capture}diff ]
    then
	echo "ok ${testcount} - ${tap_preamble}${legend} diff succeeded"
    else
	echo "not ok ${testcount} - ${tap_preamble}${legend} diff failed"
	echo "  --- |"
	sed <"${tap_capture}diff" -e 's/^/  /'
	echo "  ..."
	exit 1
    fi
    testcount=$((testcount + 1))
}

# Given a test file and a checkfile, verify that they compare binary equal.
# Relies on cmp(1) to always ship a textual non-zero-length complain if they
# do not. This is a separate function because doing the obvious way would
# clobber ${tap_capture}out just before it's needed for the check.
tapcmp () {
    label="$1"
    testfile="$2"
    checkfile="$3"
    legend="$4"
    taplog "${label}" "${legend}"
    # shellcheck disable=SC2086
    cmp "${testfile}" "${checkfile}" >${tap_capture}diff 2>&1
    tapcheck internal "$?" "${legend}"
}

# Grep for a pattern in the stashed output of the last taptest command.
# First argument is group label, second is the string to grep for, third
# is the legend to be used in reporting success or failure.
tapgrep() {
    if [ "$#" != 3 ]
    then
	echo "Bail out! # tapgrep requires exactly three arguments."
	exit 1;
    fi
    label="$1"
    lookfor="$2"
    legend="$3"
    grep "$lookfor" ${tap_capture}out >/dev/null 2>&1
    tapcheck internal "$?" "${legend}"
}

# Emit a TAP comment.  We don't sihp an OK line here because it
# doesn't count as a passed test.
tapcomment() {
    shift	# Skip the label argument
    echo "# $*"
    if [ -n "${logfile}" ]
    then
	echo "# $*" >>"${logfile}"
    fi
}

# Clean up tempfiles created by the tap functions.
tapclean() {
    if [ -z "${tap_capture}" ]
    then
	echo "not ok ${testcount} - ${tap_preamble}cleanup deletion suppressed."
	exit 1
    else
	rm -f ${tap_capture}*
    fi
    testcount=$((testcount + 1))
}

# Generic TAP functions end here

if [ $testmode = yes ]
then
    SANDBOX=/tmp/srctest
    echo "# Test files and masters will not be removed on exit."
    rm -fr $SANDBOX
else
    # Needs to not be a subdirectory of here, or git gets confused.  Use
    # -u so that src's initialization will be tested.
    SANDBOX=$(mktemp -u /tmp/src_XXXXXXXX)
    trap 'rm -fr $SANDBOX; tapclean' EXIT HUP INT QUIT TERM
fi

if [ ! -d "$SANDBOX" ]
then
    mkdir "$SANDBOX" || { echo "Bail out! # scratch directory creation of $SANDBOX failed"; exit 1; }
fi
if [ "$SANDBOX" = "" ]
then
    testcount=$((testcount + 1))
    echo "Bail out! srctest refuses to destroy the world."
fi

cd "$SANDBOX" || (echo "srctest: sandbox is missing"; exit 1)
rm -fr -- *

COLUMNS=73
export COLUMNS

# Set an editor that does nothing, noy modifimg its argument file.  We
# do this to avoid making the eecution path through the edit-function
# code dependent on what well-known editors are in the user's $PATH.
EDITOR=:
export EDITOR

# Test sequence begins here
# shellcheck disable=SC2120
test_backend() {

TESTOPTS="$passed $backend"
tap_preamble="($python $backend): "

# shellcheck disable=SC2086
mkdir ${python}-${backend}
# shellcheck disable=SC2086
cd ${python}-${backend} >/dev/null || ( echo "Bail out! Sandbox subdirectory creation failed"; exit 1 )

# No repo directory yet. Test those error cases first

# shellcheck disable=SC2086
taptest repoless "reject list with missing repo directory" ! $src -T ${TESTOPTS} list
tapgrep repoless "does not exist" "list with missing repo message check"

# shellcheck disable=SC2086
taptest repoless "reject srcify with  repo directory." ! $src -q -T ${TESTOPTS} srcify

# shellcheck disable=SC2086
taptest repoless "version" $src -T ${TESTOPTS} version
tapgrep repoless "python" "sane version output"

# shellcheck disable=SC2086
taptest repoless "reject ls without repo directory" ! $src -T ${TESTOPTS} ls

# shellcheck disable=SC2086
taptest repoless "reject visualize without repo directory" ! $src -T ${TESTOPTS} visualize

# shellcheck disable=SC2086
taptest repoless "empty command line not blowing up" $src -T ${TESTOPTS}

# shellcheck disable=SC2086
taptest repoless "commit help lookup" $src -T ${TESTOPTS} help commit

# shellcheck disable=SC2086
taptest repoless "error exit on unknown command" ! $src -T ${TESTOPTS} foozle

# shellcheck disable=SC2086
taptest repoless "error exit on help for unknown command" ! $src -T ${TESTOPTS} help foozle

# shellcheck disable=SC2086
taptest repoless "init unexpectedly" $src -T ${TESTOPTS} init

# No-directory tests end here

cat >testfile1 <<EOF
Now is the time
EOF
cp testfile1 testrev1

# shellcheck disable=SC2086
taptest ${expect_empty} workflow "commit with -m option" $src -T ${TESTOPTS} commit -m "'First comment'" testfile1

# shellcheck disable=SC2086
tapdiff workflow testfile1 "content check after first commit" $src -T ${TESTOPTS} cat testfile1

# shellcheck disable=SC2086
tapdiff workflow testfile1 "content check with --" $src -T ${TESTOPTS} cat 1 -- testfile1

# shellcheck disable=SC2086
taptest workflow "revision number command used by Emacs" $src -T ${TESTOPTS} list "-f{1}" @ -- testfile1

mkdir mysub
# shellcheck disable=SC2086
taptest workflow "copy to subdirectory" $src -T ${TESTOPTS} copy testfile1 mysub/landhere
rm -fr mysub

touch foo
# shellcheck disable=SC2086
taptest workflow "unregistered file check" ! $src -T ${TESTOPTS} cat foo
tapgrep workfile "is not registered" "unregistered file check message"
rm foo

# Change the content of testfile1 
cat >testfile1 <<EOF
Now is the time
for all good men
EOF
cp testfile1 testrev2

# We expect this diff
cat >testfile4 <<EOF
--- testfile1 (r1)
+++ testfile1 (workfile)
@@ -1,2 +1,3 @@
 Now is the time
+for all good men
 
EOF

# Filter out header lines containing variable date information
# shellcheck disable=SC2086,SC2162,SC2034
tapdiff workflow testfile4 "content diff after first commit" $src -T ${TESTOPTS} diff testfile1

# shellcheck disable=SC2086
taptest workflow "diff with bad option" ! $src -T ${TESTOPTS} diff -@ testfile1
tapgrep workflow "unexpected" "bogus diff option check"

sleep 1	# Force commit to have different timestamp
echo 'Second comment' >/tmp/tap$$in
# shellcheck disable=SC2086
taptest ${expect_empty} workflow "commit with -" $src -T ${TESTOPTS} commit - testfile1 </tmp/tap$$in
# shellcheck disable=SC2086
tapdiff workflow testfile1 "content check after second commit" $src -T ${TESTOPTS} cat testfile1

cat >testfile2 <<EOF
= testfile1 ============================================================
2     * 1970-01-02T00:01:00Z Second comment
1     - 1970-01-02T00:00:00Z First comment
EOF

# shellcheck disable=SC2086
tapdiff workflow testfile2 "list test" $src -T ${TESTOPTS} list testfile1
# shellcheck disable=SC2086
tapdiff workflow testfile2 "list test with -- argument termination" $src -T ${TESTOPTS} list -- testfile1

cat >testfile2 <<EOF
2|*|1970-01-02T00:01:00Z
1|-|1970-01-02T00:00:00Z
EOF

# shellcheck disable=SC2086
tapdiff workflow testfile2 "list test with custom format" $src -T ${TESTOPTS} list -f '"{1}|{2}|{3}"' testfile1

cat >testfile2 <<EOF
= testfile1 ============================================================
2    | 1970-01-02T00:01:00Z | trunk
Second comment
------------------------------------------------------------------------
1    | 1970-01-02T00:00:00Z | trunk
First comment
------------------------------------------------------------------------
EOF

# shellcheck disable=SC2086
tapdiff workflow testfile2 "2-commit log test" $src -T ${TESTOPTS} log testfile1

# shellcheck disable=SC2086
tapdiff workflow testfile2 "2-commit log test with --" $src -T ${TESTOPTS} log -- testfile1

cat >testfile1 <<EOF
Now is the time
for all good men
to come to the aid of foo
EOF
cp testfile1 testrev3

sleep 1	# Force commit to have different timestamp
cat >testfile4 <<EOF
'Third' comment

Multiline test.

EOF
# shellcheck disable=SC2086
taptest workflow "commit with -f" $src -T ${TESTOPTS} commit -f testfile4 testfile1

cat >testfile4 <<EOF
= testfile1 ============================================================
3    | 1970-01-02T00:02:00Z | trunk
'Third' comment

Multiline test.
------------------------------------------------------------------------
2    | 1970-01-02T00:01:00Z | trunk
Second comment
------------------------------------------------------------------------
1    | 1970-01-02T00:00:00Z | trunk
First comment
------------------------------------------------------------------------
EOF

# shellcheck disable=SC2086
tapdiff workflow testfile4 "3-commit log test" $src -T ${TESTOPTS} log testfile1 

cat >testfile14 <<EOF
= testfile1 ============================================================
3    | 1970-01-02T00:02:00Z | trunk
'Third' comment

Multiline test.

diff r2/testfile1 r3/testfile1
--- testfile1 (r2)
+++ testfile1 (r3)
@@ -1,3 +1,4 @@
 Now is the time
 for all good men
+to come to the aid of foo
 
------------------------------------------------------------------------
2    | 1970-01-02T00:01:00Z | trunk
Second comment

diff r1/testfile1 r2/testfile1
--- testfile1 (r1)
+++ testfile1 (r2)
@@ -1,2 +1,3 @@
 Now is the time
+for all good men
 
------------------------------------------------------------------------
1    | 1970-01-02T00:00:00Z | trunk
First comment

diff /dev/null r1/testfile1
--- /dev/null
+++ testfile1 (r1)
@@ -1 +1,2 @@
+Now is the time
 
------------------------------------------------------------------------
EOF

# shellcheck disable=SC2086
tapdiff workflow testfile14 "log --patch" $src -T ${TESTOPTS} log --patch testfile1

cat >testfile15 <<EOF
= testfile1 ============================================================
3    | 1970-01-02T00:02:00Z | trunk
'Third' comment

Multiline test.

diff r2/testfile1 r3/testfile1
*** testfile1 (r2)
--- testfile1 (r3)
***************
*** 1,3 ****
--- 1,4 ----
  Now is the time
  for all good men
+ to come to the aid of foo
  
------------------------------------------------------------------------
2    | 1970-01-02T00:01:00Z | trunk
Second comment

diff r1/testfile1 r2/testfile1
*** testfile1 (r1)
--- testfile1 (r2)
***************
*** 1,2 ****
--- 1,3 ----
  Now is the time
+ for all good men
  
------------------------------------------------------------------------
1    | 1970-01-02T00:00:00Z | trunk
First comment

diff /dev/null r1/testfile1
*** /dev/null
--- testfile1 (r1)
***************
*** 1 ****
--- 1,2 ----
+ Now is the time
  
------------------------------------------------------------------------
EOF

# shellcheck disable=SC2086
tapdiff workfow testfile15 "log -c" $src -T ${TESTOPTS} log -c testfile1

cat >testfile6 <<EOF
= testfile1 ============================================================
src: testfile1 has no 5 revision
EOF

# shellcheck disable=SC2086
tapdiff workflow testfile6 "oob revision spec check" ! $src -T ${TESTOPTS} list 5 testfile1
tapgrep workflow "src: testfile1 has no 5 revision" "oob revision error check"

for rev in 1 2 3
do
    # shellcheck disable=SC2086
    taptest workfile "revision $rev checkout " $src -q -T ${TESTOPTS} checkout $rev testfile1
    tapdiff workfile testrev${rev} "revision $rev checkout content test" cat testfile1
done

if [ "$backend" = "sccs" ]
then
    tapcomment workflow "($python $backend): skipping tag tests"
else
    # shellcheck disable=SC2086
    taptest workflow "tag set to default tip revision" $src -T ${TESTOPTS} tag create sampletag

    cat >testfile8 <<EOF
= testfile1 ==========================================================
   3	sampletag
EOF
    # shellcheck disable=SC2086
    tapdiff workflow testfile8 "tag list check" $src -T ${TESTOPTS} tag list

    # shellcheck disable=SC2086
    taptest workflow "tag set to revision 1" $src -T ${TESTOPTS} tag create basetag 1

    cat >testfile10 <<EOF
= testfile1 ==========================================================
   1	basetag
   3	sampletag
EOF
    # shellcheck disable=SC2086
    tapdiff workflow testfile10 "second tag list check" $src -T ${TESTOPTS} tag -l

    # shellcheck disable=SC2086
    taptest workflow "tag deletion: sampletag" $src -T ${TESTOPTS} tag -d sampletag

    cat >testfile12 <<EOF
= testfile1 ==========================================================
   1	basetag
EOF
    # shellcheck disable=SC2086
    tapdiff workflow testfile12 "tag list check after deletion" $src -T ${TESTOPTS} tag

    # We used to have to do this or the fast-export regression would fail spuriously.
    # It is not clear what changed.
    #taptest workfile "tag deletion: basetag" $src -T ${TESTOPTS} tag -d basetag
fi

# Fast-export tests
test_export () {
    testname="$1"
    shift
    srcfi=$testname-src.fi
    gitfi=$testname-git.fi
    mkdir foo
    # shellcheck disable=SC2086
    taptest workflow "fast-export: $testname command" $src -T ${TESTOPTS} fast-export "$@"
    tapgrep workfile jrh "fast-export: $testname content check"
    grep -v '^#' "${tap_capture}out" >"$srcfi"	# Side effect - file is used later
    # shellcheck disable=SC2002
    cat "$srcfi" | (cd foo >/dev/null || ("echo missing foo directory" ;exit 1); git init --quiet; git fast-import --quiet)
    (cd foo >/dev/null || ("echo missing foo directory"; exit 1); git fast-export --all) | grep -v '^#' >"$gitfi"
    tapdiff workfile "$srcfi" "fast-export roundtrip: $testname" cat "$gitfi"
    rm -fr foo
}

# Without this copy, the rcs-fast-import test would modify testf1le1 under
# the RCS nackend but not the SCCS one.
# shellcheck disable=SC2086
taptest ${expect_empty} workflow "copying testfile1" $src -T ${TESTOPTS} copy testfile1 exportme

test_export filename exportme

# Test multiple-file fast-export.
echo flower power >testfile14
# shellcheck disable=SC2086
taptest workflow "it's a Mad world" $src -T ${TESTOPTS} commit -m "'Alfred E. Newman'" testfile14
test_export filenames exportme testfile14
historify testfile14
rm -f "$history"

test_export revspec-filename -- exportme
taplog workfile "fast-export revspec/filename distinction"
grep refs/heads/master revspec-filename-src.fi >/dev/null &&
    ! grep refs/heads/exportme/master revspec-filename-src.fi >/dev/null
tapcheck workfile "$?" "${legend}"

rm -f exportme
test_export not-checked-out exportme
tapcheck workfile "$?" "fast-export consults history only"

# shellcheck disable=SC2086
taptest workfklow "checkout after fast-export" $src -T ${TESTOPTS} checkout exportme
    
if [ "$backend" = "sccs" ]
then
    tapcomment workflow "($python $backend): skipping fast-import checks: RCS-only"
elif ! command -v rcs-fast-import >/dev/null 2>&1
then
    tapcomment workflow "($python $backend): skipping fast-import checks: rcs-fast-import missing"
else
    mkdir RCS
    # shellcheck disable=SC2086
    taptest workflow "fast-import don't clobber RCS" ! $src -T ${TESTOPTS} fast-import -p <filename-git.fi
    tapgrep workflow 'existing RCS' "fast-import don't clobber RCS message check"
    rm -fr RCS

    historify exportme
    rm -f "$history"
    # shellcheck disable=SC2086
    taptest workflow "fast-import roundtrip (import)" $src -T ${TESTOPTS} fast-import -p <filename-git.fi
    taptest workflow "history exists after fast-import roundtrip" test -f "$history"
    (echo "#sourcetype src"; cat filename-git.fi) >reheadered
    # shellcheck disable=SC2086
    tapdiff workflow reheadered "fast-import roundtrip (export)" $src -T ${TESTOPTS} fast-export exportme
fi

nuke exportme

# shellcheck disable=SC2086
taptest badmove "rejection of move with bad source" ! $src -T ${TESTOPTS} move foo bar
tapgrep badmove "I see no" "move rejection message check"

# shellcheck disable=SC2086
taptest workflow "move command" $src -T ${TESTOPTS} move testfile1 newname1
historify newname1
# shellcheck disable=SC2086
taptest workflow "move target location check" [ -e newname1 ] && [ -e "$history" ]

newname1_master="${history}"
historify newname2
newname2_master="${history}"
# shellcheck disable=SC2086
taptest workflow "copy command" $src -T ${TESTOPTS} copy newname1 newname2
taptest workflow "copy source and target location check" [ -e newname1 ] && [ -e newname2 ] && [ -e "${newname1_master}" ] && [ -e "${newname2_master}" ]

cat >manifest <<EOF
newname1
newname2
EOF
# shellcheck disable=SC2086
tapdiff workflow manifest "ls" $src -T ${TESTOPTS} ls
nuke manifest

# shellcheck disable=SC2086
taptest workflow "amend" $src -T ${TESTOPTS} amend -m "'Amended comment'" newname1

# shellcheck disable=SC2086
taptest workflow "comment retrieval for amend check" $src -T ${TESTOPTS} list 3 newname1
tapgrep workflow "Amended comment" "amended comment content"

cat >statuslog <<EOF
=  newname1
=  newname2
EOF
# shellcheck disable=SC2086
tapdiff workflow statuslog "unadorned status" $src -T ${TESTOPTS} status -q

# shellcheck disable=SC2086
tapdiff workflow statuslog "status before ignore" $src -T ${TESTOPTS} status newname1 newname2

echo "# comment in ignore file" >.srcignore
echo "newname1" >>.srcignore

cat >statuslog <<EOF
I  newname1
=  newname2
EOF
# shellcheck disable=SC2086
tapdiff workflow statuslog "status after ignore" $src -T ${TESTOPTS} status newname1 newname2

nuke statuslog
nuke .srcignore

cat >diffall.expect <<EOF
--- newname1 (r3)
+++ newname1 (workfile)
@@ -1,4 +1,5 @@
 Now is the time
 for all good men
 to come to the aid of foo
+more stuff
 
--- newname2 (r3)
+++ newname2 (workfile)
@@ -1,4 +1,5 @@
 Now is the time
 for all good men
 to come to the aid of foo
+and even more
 
EOF

echo "more stuff" >>newname1
echo "and even more" >>newname2
# shellcheck disable=SC2086
tapdiff workflow diffall.expect "expected diff after modify" $src -T ${TESTOPTS} diff

# shellcheck disable=SC2086
taptest workflow "checkout after modification" $src -T ${TESTOPTS} checkout newname1 newname2

cat >limit.list <<EOF
= newname2 =============================================================
3     * 1970-01-02T00:02:00Z 'Third' comment
2     - 1970-01-02T00:01:00Z Second comment
EOF
cat >limit.log <<EOF
= newname2 =============================================================
3    | 1970-01-02T00:02:00Z | trunk
'Third' comment

Multiline test.
------------------------------------------------------------------------
2    | 1970-01-02T00:01:00Z | trunk
Second comment
------------------------------------------------------------------------
EOF
for i in list log
do
    for j in -2 '-l 2'
    do
        # shellcheck disable=SC2086
	tapdiff workflow limit.$i "$i $j" $src -T ${TESTOPTS} $i $j newname2
    done
done

# Get a fresh start - enforcing bounday between test groups
fresh_start

cat >statdummy <<EOF
Lorem ipsum
EOF
# shellcheck disable=SC2086
taptest teststatus "commit file for stasis tests" $src -T ${TESTOPTS} commit -m "'Another sample'" statdummy

# shellcheck disable=SC2086
taptest teststatus "status fetch expecting = (unmodified)" $src -T ${TESTOPTS} status statdummy
tapgrep teststatus "^=" "= status check after first commit"

echo "Add a second line" >>statdummy
# shellcheck disable=SC2086
taptest teststatus "status fetch expecting M" $src -T ${TESTOPTS} status statdummy
tapgrep teststatus "^M" "M status check after modification"

rm statdummy
# shellcheck disable=SC2086
taptest teststatus "status fetch expecting !" $src -T ${TESTOPTS} status statdummy
tapgrep teststatus "^!" "! status check after deletion"

# shellcheck disable=SC2086
taptest teststatus "reversion" $src -T ${TESTOPTS} checkout statdummy

# shellcheck disable=SC2086
taptest teststatus "status fetch expecting = (reversiom)" $src -T ${TESTOPTS} status statdummy
tapgrep teststatus "^=" "= status check after restoration"

historify statdummy
rm -f "$history"

# shellcheck disable=SC2086
taptest teststatus "status fetch expecting ?" $src -T ${TESTOPTS} status statdummy
tapgrep teststatus "^?" "? status check after master deletion"

# Get a fresh start - enforcing bounday between test groups
fresh_start

if [ "$backend" = "sccs" ]
then
    tapcomment branchy "($python $backend): skipping branch tests"
else
    # Test branch creation
    echo "Base content" >branchfoo
    # shellcheck disable=SC2086
    taptest branchy "branch test start commit " $src -T ${TESTOPTS} ci -m "'Start a file with branches'" branchfoo

    cat >testfile18 <<EOF
= branchfoo ==========================================================
   0	* trunk
EOF
    # shellcheck disable=SC2086
    tapdiff branchy testfile18 "pre-branch-creation branch listing check" $src -T ${TESTOPTS} branch -l branchfoo

cat >testfile19 <<EOF
= branchfoo ==========================================================
   1	* branch1
   0	- trunk
EOF
    # shellcheck disable=SC2086
    taptest branchy "branch creation" $src -T ${TESTOPTS} branch -c branch1 branchfoo

    # shellcheck disable=SC2086
    tapdiff branchy testfile19 "post-branch-creation branch listing check" $src -T ${TESTOPTS} branch -l branchfoo

    echo "Branch content" >branchfoo
    # shellcheck disable=SC2086
    taptest branchy "branch checkin" $src -T ${TESTOPTS} ci -m "'checkin on the branch'" branchfoo

    cat >testfile20 <<EOF
= branchfoo ============================================================
2    | 1970-01-02T00:01:00Z | branch1
checkin on the branch
------------------------------------------------------------------------
1    | 1970-01-02T00:00:00Z | trunk
Start a file with branches
------------------------------------------------------------------------
EOF
    # shellcheck disable=SC2086
    tapdiff branchy testfile20 "log showing branched content" $src -T ${TESTOPTS} log branchfoo

    echo "New base content" >branchfoo
    # shellcheck disable=SC2086
    taptest branchy "reject checkin on nonexistent branch" ! $src -d -T ${TESTOPTS} ci -b boggle -m "'Alter content on trunk'" branchfoo
    # shellcheck disable=SC2086
    tapgrep branchy "can't switch to nonexistent branch" "nonexistent-branch message check"

    # shellcheck disable=SC2086
    taptest branchy "altering content on trunk" $src -T ${TESTOPTS} ci -b trunk -m "'Alter content on trunk'" branchfoo

    cat >testfile21 <<EOF
= branchfoo ============================================================
3    | 1970-01-02T00:02:00Z | trunk
Alter content on trunk
------------------------------------------------------------------------
1    | 1970-01-02T00:00:00Z | trunk
Start a file with branches
------------------------------------------------------------------------
EOF
    # shellcheck disable=SC2086
    tapdiff branchy testfile21 "check trunk log content after branch" src -T ${TESTOPTS} log branchfoo

    # Introduce a test history with some branchiness, so
    # we can test traversal across branch joins. Also has tags.
    cat >.src/sample,v <<EOF
head	1.4;
branch	1.3.1.4.1;
access;
symbols
	GLARB:1.4
	GORP:1.3.1.4
	wibble:1.3.1.4.0.1
	muggle:1.3.0.1;
locks
	${USER:-root}:1.3.1.4.1.5;
comment	@# @;
expand	@b@;


1.4
date	2014.11.11.03.26.53;	author esr;	state Exp;
branches;
next	1.3;

1.3
date	2014.11.10.23.48.49;	author esr;	state Exp;
branches
	1.3.1.1;
next	1.2;

1.2
date	2014.11.10.23.48.11;	author esr;	state Exp;
branches;
next	1.1;

1.1
date	2014.11.10.23.47.08;	author esr;	state Exp;
branches;
next	;

1.3.1.1
date	2014.11.11.04.23.47;	author esr;	state Exp;
branches;
next	1.3.1.2;

1.3.1.2
date	2014.11.11.06.39.47;	author esr;	state Exp;
branches;
next	1.3.1.3;

1.3.1.3
date	2014.11.11.06.48.00;	author esr;	state Exp;
branches;
next	1.3.1.4;

1.3.1.4
date	2014.11.12.03.36.45;	author esr;	state Exp;
branches
	1.3.1.4.1.1;
next	;

1.3.1.4.1.1
date	2014.11.13.04.04.55;	author esr;	state Exp;
branches;
next	1.3.1.4.1.2;

1.3.1.4.1.2
date	2014.11.13.04.23.04;	author esr;	state Exp;
branches;
next	1.3.1.4.1.3;

1.3.1.4.1.3
date	2014.11.13.04.26.23;	author esr;	state Exp;
branches;
next	1.3.1.4.1.4;

1.3.1.4.1.4
date	2014.11.13.04.30.39;	author esr;	state Exp;
branches;
next	1.3.1.4.1.5;

1.3.1.4.1.5
date	2014.11.13.04.31.02;	author esr;	state Exp;
branches;
next	;


desc
@@


1.4
log
@On a branch?
@
text
@Now is the time
For all good men.
To come to the aid of foo.
This should be branch text.
@


1.3
log
@Third comment.
@
text
@d4 1
@


1.3.1.1
log
@Totally unfubared.
@
text
@a3 2

Again, this should be branch text.
@


1.3.1.2
log
@Still utterly fubar
@
text
@d5 1
a5 1
Yet again, this should be branch text.
@


1.3.1.3
log
@Totally chenille.
@
text
@a5 2

Revision 7.
@


1.3.1.4
log
@Utterly fubar
@
text
@d4 4
a7 2
This should be branch text.
Try a comment with a hyphen.
@


1.3.1.4.1.1
log
@All fixed up.
@
text
@a5 1
Test of commit comments.
@


1.3.1.4.1.2
log
@It' all good.
@
text
@a6 1
Glotch.
@


1.3.1.4.1.3
log
@No good.
@
text
@a7 1
Random modification.
@


1.3.1.4.1.4
log
@That's good.
@
text
@a4 1
jjjj
d7 1
@


1.3.1.4.1.5
log
@I see you
@
text
@d5 1
a5 1
jjjjjjjjkkk
@


1.2
log
@Second comment.
@
text
@d3 1
@


1.1
log
@First comment.
@
text
@d2 1
@
EOF

cat >sampledot <<EOF
digraph {
	1 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">1</font></td><td>First comment.</td></tr></table>>];
	1 -> 2;
	2 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">2</font></td><td>Second comment.</td></tr></table>>];
	2 -> 3;
	3 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">3</font></td><td>Third comment.</td></tr></table>>];
	3 -> 4;
	4 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">4</font></td><td>On a branch?</td></tr></table>>];
	"trunk" [shape=oval,width=2];
	"4" -> "trunk" [style=dotted];
	3 -> 5;
	5 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">5</font></td><td>Totally unfubared.</td></tr></table>>];
	5 -> 6;
	6 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">6</font></td><td>Still utterly fubar</td></tr></table>>];
	6 -> 7;
	7 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">7</font></td><td>Totally chenille.</td></tr></table>>];
	7 -> 8;
	8 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">8</font></td><td>Utterly fubar</td></tr></table>>];
	"muggle" [shape=oval,width=2];
	"8" -> "muggle" [style=dotted];
	8 -> 9;
	9 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">9</font></td><td>All fixed up.</td></tr></table>>];
	9 -> 10;
	10 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">10</font></td><td>It' all good.</td></tr></table>>];
	10 -> 11;
	11 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">11</font></td><td>No good.</td></tr></table>>];
	11 -> 12;
	12 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">12</font></td><td>That's good.</td></tr></table>>];
	12 -> 13;
	13 [shape=box,width=5,label=<<table cellspacing="0" border="0" cellborder="0"><tr><td><font color="blue">13</font></td><td>I see you</td></tr></table>>];
	"wibble" [shape=oval,width=2];
	"13" -> "wibble" [style=dotted];
	{rank=same; "GLARB"; "4"}
	"GLARB" -> "4" [style=dotted];
	{rank=same; "GORP"; "8"}
	"GORP" -> "8" [style=dotted];
}
EOF

    # shellcheck disable=SC2086
    tapdiff branchy sampledot "dot visualization" $src -T ${TESTOPTS} visualize sample

    cat >sample.seqlog <<EOF
= sample ===============================================================
6    | 1970-01-02T00:05:00Z | muggle
Still utterly fubar
------------------------------------------------------------------------
5    | 1970-01-02T00:04:00Z | muggle
Totally unfubared.
------------------------------------------------------------------------
4    | 1970-01-02T00:03:00Z | trunk
On a branch?
------------------------------------------------------------------------
3    | 1970-01-02T00:02:00Z | trunk
Third comment.
------------------------------------------------------------------------
2    | 1970-01-02T00:01:00Z | trunk
Second comment.
------------------------------------------------------------------------
EOF

    # shellcheck disable=SC2086
    tapdiff branchy sample.seqlog "traversal by -" $src -T ${TESTOPTS} log 6-2 sample

    # Revision 4 is missing because it's not on the selected branch wibble
    cat >sample.branchlog <<EOF
= sample ===============================================================
6    | 1970-01-02T00:05:00Z | muggle
Still utterly fubar
------------------------------------------------------------------------
5    | 1970-01-02T00:04:00Z | muggle
Totally unfubared.
------------------------------------------------------------------------
3    | 1970-01-02T00:02:00Z | trunk
Third comment.
------------------------------------------------------------------------
2    | 1970-01-02T00:01:00Z | trunk
Second comment.
------------------------------------------------------------------------
EOF

    # shellcheck disable=SC2086
    tapdiff branchy sample.branchlog "traversal by .." $src -T ${TESTOPTS} log 6..2 sample

    cat >sample.branchlog-p <<EOF
= sample ===============================================================
5    | 1970-01-02T00:04:00Z | muggle
Totally unfubared.

diff r3/sample r5/sample
--- sample (r3)
+++ sample (r5)
@@ -2,3 +2,5 @@
 For all good men.
 To come to the aid of foo.
 
+Again, this should be branch text.
+
------------------------------------------------------------------------
EOF

    # shellcheck disable=SC2086
    tapdiff branchy sample.branchlog-p "branchy log --patch" $src -T ${TESTOPTS} log --patch 5 sample

    cat >sample.taglog <<EOF
= sample ===============================================================
4     - 1970-01-02T00:03:00Z On a branch?
EOF
    # shellcheck disable=SC2086
    tapdiff branchy sample.taglog "named-tag lookup with @" $src -T ${TESTOPTS} list @GLARB sample

    # shellcheck disable=SC2086
    taptest branchy "tag renaming" $src -T ${TESTOPTS} rename tag GLARB GROTTY sample

    # shellcheck disable=SC2086
    taptest branchy "reject invalid tag list with revision" ! $src -T ${TESTOPTS} tag -l 1 sample
    
    cat >changes <<EOF
= sample =============================================================
   8	GORP
   4	GROTTY
EOF

    # shellcheck disable=SC2086
    tapdiff branchy changes "tag list after rename" $src -T ${TESTOPTS} tag -l sample

    # shellcheck disable=SC2086
    taptest branchy "reject duplicate tag setting" ! $src -T ${TESTOPTS} tag -c GORP sample
    tapgrep branchy "already set" "duplicate tag setting message check"

    cat >branchlist <<EOF
= sample =============================================================
   8	* wibble
   3	- muggle
   0	- trunk
EOF
    # shellcheck disable=SC2086
    taptest branchy "branch list" $src -T ${TESTOPTS} branch -l sample
    # shellcheck disable=SC2086
    tapdiff branchy branchlist "branch list content" $src -T ${TESTOPTS} branch -l sample

    # shellcheck disable=SC2086
    taptest branchy "branch name resolution" $src -T ${TESTOPTS} list @trunk sample

    cat >branchlog <<EOF
= sample ===============================================================
4     - 1970-01-02T00:03:00Z On a branch?
EOF
    # shellcheck disable=SC2086
    tapdiff branchy branchlog "branch name resolved content" $src -T ${TESTOPTS} list @trunk sample

    # shellcheck disable=SC2086
    taptest branchy "branch delete of trunk should fail" ! $src -T ${TESTOPTS} branch -d trunk sample
    tapgrep branchy "branch deletion failed" "failed branch deletion message check"

    cat >newlist <<EOF
= sample =============================================================
   8	* wibble
   3	- muggle
   0	- trunk
EOF
    # shellcheck disable=SC2086
    tapdiff branchy newlist "branch list check after invalid delete" $src -T ${TESTOPTS} branch -l sample
    
    # Revision 4 is missing because it's not on the selected branch wibble
    cat >newlog <<EOF
= sample ===============================================================
13   | 1970-01-02T00:12:00Z | wibble
I see you
------------------------------------------------------------------------
12   | 1970-01-02T00:11:00Z | wibble
That's good.
------------------------------------------------------------------------
11   | 1970-01-02T00:10:00Z | wibble
No good.
------------------------------------------------------------------------
10   | 1970-01-02T00:09:00Z | wibble
It' all good.
------------------------------------------------------------------------
9    | 1970-01-02T00:08:00Z | wibble
All fixed up.
------------------------------------------------------------------------
8    | 1970-01-02T00:07:00Z | muggle
Utterly fubar
------------------------------------------------------------------------
7    | 1970-01-02T00:06:00Z | muggle
Totally chenille.
------------------------------------------------------------------------
6    | 1970-01-02T00:05:00Z | muggle
Still utterly fubar
------------------------------------------------------------------------
5    | 1970-01-02T00:04:00Z | muggle
Totally unfubared.
------------------------------------------------------------------------
3    | 1970-01-02T00:02:00Z | trunk
Third comment.
------------------------------------------------------------------------
2    | 1970-01-02T00:01:00Z | trunk
Second comment.
------------------------------------------------------------------------
1    | 1970-01-02T00:00:00Z | trunk
First comment.
------------------------------------------------------------------------
EOF

    # shellcheck disable=SC2086
    tapdiff branchy newlog "content after failed branch deletion" $src -T ${TESTOPTS} log sample

    # shellcheck disable=SC2086
    taptest branchy "branch delete of current branch" ! $src -T ${TESTOPTS} branch -d wibble sample
    tapgrep branchy "can't delete the current branch" "reject deletion of current branch"

    cat >newlist <<EOF
= sample =============================================================
   8	* wibble
   3	- muggle
   0	- trunk
EOF
    # shellcheck disable=SC2086
    tapdiff branchy newlist "branch list check after failed current branch delete" $src -T ${TESTOPTS} branch -l sample

    # shellcheck disable=SC2086
    taptest branchy "select trunk" $src -T ${TESTOPTS} co @trunk sample
    cat >newlist <<EOF
= sample =============================================================
   0	* trunk
   3	- muggle
   8	- wibble
EOF
    # shellcheck disable=SC2086
    tapdiff branchy newlist "branch list check after trunk select" $src -T ${TESTOPTS} branch -l sample

    # shellcheck disable=SC2086
    taptest branchy "branch delete of wibble" $src -T ${TESTOPTS} branch -d wibble sample
    cat >newlist <<EOF
= sample =============================================================
   0	* trunk
   3	- muggle
EOF
    # shellcheck disable=SC2086
    tapdiff branchy newlist "branch list check after wibble delete" $src -T ${TESTOPTS} branch -l sample
fi
  
# Get a fresh start - enforcing bounday between test groups
fresh_start

# shellcheck disable=SC2210
echo "Random content for numeric file" >23
# shellcheck disable=SC2086
taptest numeric "commit of file with numeric name" $src -T ${TESTOPTS} commit -m "'I do not know why you say goodbye'" -- 23

cat >randomcontent <<EOF
Random content for numeric file
EOF
# shellcheck disable=SC2086
tapdiff numeric randomcontent "content check of file with numeric name" $src -T ${TESTOPTS} cat -- 23

# Get a fresh start - enforcing bounday between test groups
fresh_start

# Eric Sunshine writes:
#
# The test itself is working properly. The problem is that stock SCCS
# does not preserve executable permission on files under its control, so
# the test is correctly failing.
#
# The GNU version of SCCS does provide an 'x' flag[1] for compatibility
# with SCO OpenServer which enables executable permission preservation.
# However, I haven't convinced myself that it would make sense to put in
# the work to add executable-preservation support to the SCCS backend
# for these special cases (GNU CSSC and SCO OpenServer).
#
# [1]: https://www.gnu.org/software/cssc/manual/Flags.html#Flag
#
if [ "$backend" = sccs ]
then
    tapcomment exec "($python $backend): skipping exec-bit propagation test"
else
    echo "Should not be executable" >exectest
    # shellcheck disable=SC2086
    taptest exec "first commit of exectest" $src -T ${TESTOPTS} commit -m "'First comment on exectest'" exectest
    chmod a+x exectest
    echo "Should be executable" >exectest
    # shellcheck disable=SC2086
    taptest exec "second commit of exectest" $src -T ${TESTOPTS} commit -m "'Second comment on exectest'" exectest
    # shellcheck disable=SC2010
    taptest exec "propagation of exec bit" test -x exectest
fi

# Get a fresh start - enforcing bounday between test groups
fresh_start

# Test for Tom Willemse's multi-commit bug.
echo "test 1" > file1
echo "test 2" > file2
# shellcheck disable=SC2086
taptest multifile "multi-file registration" $src -T ${TESTOPTS} commit -m "'Initial commit'" file1 file2
echo "test 1 line 2" >> file1
echo "test 2 line 2" >> file2
# shellcheck disable=SC2086
taptest multifile "multi-file commit" $src -T ${TESTOPTS} commit -m "'Second commit'" file1 file2

# Test the edit logic
cat >modify <<'EOF'
echo "Different first line" >modified$$
cat $1 >>modified$$
mv modified$$ $1
EOF
chmod a+x modify
echo "test 1 line 3" >> file1
# shellcheck disable=SC2086
EDITOR="./modify" taptest edit "edit logic" $src -T ${TESTOPTS} commit file1

# Get a fresh start - enforcing bounday between test groups
fresh_start

cat >binary <<EOF
This file contains an 0xD3 (Meta-S) after the colon:
EOF
cat >binary.chk <<EOF
This file contains an 0xD3 (Meta-S) after the colon:
Additional content line.
EOF
# shellcheck disable=SC2086
taptest binary "binary file checkin" $src -T ${TESTOPTS} commit -m "'Test file containing binary byte.'" binary
echo "Additional content line." >>binary
# shellcheck disable=SC2086
taptest binary "binary file modification" $src -T ${TESTOPTS} commit -m "'Binary file after modification.'" binary
tapcmp binary binary binary.chk "binary content in checkouts and commits"

if [ "$backend" = "sccs" ]
then
    tapcomment binary "($python $backend): skipping binary cat test"
else
    # shellcheck disable=SC2086
    taptest binary "binary cat" $src -T ${TESTOPTS} cat binary
    tapcmp binary binary ${tap_capture}out "binary content in cat"
fi

cat >newline <<EOF
This file contains a DOS newline 0x0D after the colon:
EOF
cat >newline.chk <<EOF
This file contains a DOS newline 0x0D after the colon:
Additional content line.
EOF
# shellcheck disable=SC2086
taptest newline "initial commit of newline file" $src -T ${TESTOPTS} commit -m "'Test file containing DOS newline.'" newline
echo "Additional content line." >>newline
# shellcheck disable=SC2086
taptest newline "modify newline file" $src -T ${TESTOPTS} commit -m "'DOS newline file after modification.'" newline
tapcmp newline newline newline.chk "newline preservation in checkouts and commits"

if [ "$backend" = "sccs" ]
then
    tapcomment newline "($python $backend): skipping newline cat test"
else
    # shellcheck disable=SC2086
    taptest newline "newline file checkin" $src -T ${TESTOPTS} cat newline
    tapcmp newline ${tap_capture}out newline "newline content in cat"
fi

# Get a fresh start - enforcing bounday between test groups
fresh_start

cat >padcomment <<'EOF'
printf "\n\n\n\n" >modified$$
cat $1 >>modified$$
mv modified$$ $1
EOF
chmod a+x padcomment
echo gommelgor >padfile
# shellcheck disable=SC2086
taptest padfile "padfile commit" $src -T ${TESTOPTS} commit -m pingle padfile
for i in commit amend
do
    echo "more stuff" >>padfile
    # shellcheck disable=SC2086
    EDITOR="./padcomment" taptest padfile "edit padfile" $src -T ${TESTOPTS} $i padfile
    tapgrep padfile cancelled "whitespace-only $i cancel"
    # shellcheck disable=SC2086
    taptest padfile "padfile $i" $src -T ${TESTOPTS} checkout padfile
done

# Get a fresh start - enforcing bounday between test groups
fresh_start

cat >clonemsg <<'EOF'
echo "I think I'm a clone now" >modified$$
cat $1 >>modified$$
mv modified$$ $1
cp $1 clonedmsg
EOF
chmod a+x clonemsg
echo gommelgor >diffledore
# shellcheck disable=SC2086
taptest amend "initial diffledore commit" $src -T ${TESTOPTS} commit -m pingle diffledore
for i in commit amend
do
    test $i = commit && echo "more stuff" >>diffledore
    # shellcheck disable=SC2086
    EDITOR="./clonemsg" taptest ignore "diffledore modification" $src -T ${TESTOPTS} $i diffledore
    grep -F -e 'Changes to be committed' clonedmsg >/dev/null &&
    grep -F -e '@@ ' clonedmsg >/dev/null &&
    grep -F -e '+++ ' clonedmsg >/dev/null &&
    grep -F -e '--- ' clonedmsg >/dev/null
    tapcheck amend "$?" "$i diff in boilerplate"
done

# Get a fresh start - enforcing bounday between test groups
fresh_start

cat >dontinvoke <<'EOF'
echo "panic!" >>nochanges
EOF
chmod a+x dontinvoke
echo "bingleby" >canttouchthis
# shellcheck disable=SC2086
taptest nochanges "canttouchthis commit" $src -T ${TESTOPTS} commit -m pingle canttouchthis
# shellcheck disable=SC2086
EDITOR="./dontinvoke" taptest ignore "canttouchtos second commit" $src -T ${TESTOPTS} commit canttouchthis
grep 'no changes to commit' ${tap_capture}out >/dev/null &&
    ! grep panic ${tap_capture}out >/dev/null
tapcheck nochanges "$?" "nothing to commit"

cat >ignore.ws <<EOF
Mary had a little lamb,
whose fleece was white as snow.
Everywhere that Mary went,
the lamb was sure to go.
EOF
# shellcheck disable=SC2086
taptest ignore "initial commit of ignore.ws" $src -T ${TESTOPTS} commit -m initial ignore.ws
cat >ignore.ws <<EOF
Gary had a little lamb,
whose    fleece was    white as snow.
Everywhere that Gary went,
    the lamb was sure to go.
EOF
sleep 1	# Force commit to have different timestamp
# shellcheck disable=SC2086
taptest ignore "ignore.ws checkin" $src -T ${TESTOPTS} commit -m "'s/Mary/Gary/ & whitespace'" ignore.ws
cat >ignore.expect-b <<EOF
--- ignore.ws (r1)
+++ ignore.ws (r2)
@@ -1,4 +1,4 @@
-Mary had a little lamb,
+Gary had a little lamb,
 whose fleece was white as snow.
-Everywhere that Mary went,
-the lamb was sure to go.
+Everywhere that Gary went,
+    the lamb was sure to go.

EOF
cat >ignore.expect-w <<EOF
--- ignore.ws (r1)
+++ ignore.ws (r2)
@@ -1,4 +1,4 @@
-Mary had a little lamb,
+Gary had a little lamb,
 whose fleece was white as snow.
-Everywhere that Mary went,
+Everywhere that Gary went,
 the lamb was sure to go.

EOF
for i in -b -w
do
    # shellcheck disable=SC2086
    tapdiff workflow ignore.expect$i "diff $i" $src -T ${TESTOPTS} diff -u $i 1-2 ignore.ws
done

# Get a fresh start - enforcing bounday between test groups
fresh_start

if [ "$backend" = "sccs" ]
then
    tapcomment tiebreak "($python $backend): skipping commit date tie-breaking tests"
else
    # Introduce a test history with all commits having same date so we can
    # test native revision ID tie-breaking.
    cat >.src/tiebreak,v <<EOF
head	1.11;
access;
symbols
	refs/heads/master:1.11;
locks
	sunshine:1.11; strict;
comment	@# @;


1.11
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.10;

1.10
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.9;

1.9
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.8;

1.8
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.7;

1.7
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.6;

1.6
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.5;

1.5
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.4;

1.4
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.3;

1.3
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.2;

1.2
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	1.1;

1.1
date	2017.11.21.06.45.15;	author sunshine;	state Exp;
branches;
next	;


desc
@@


1.11
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Mon 20 Nov 2017 21:37:42 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :22
Parents: :20

eleventh
@
text
@eleventh
@


1.10
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Mon 20 Nov 2017 21:30:40 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :20
Parents: :18

tenth
@
text
@d1 1
a1 1
tenth
@


1.9
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Mon 20 Nov 2017 21:27:29 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :18
Parents: :16

ninth
@
text
@d1 1
a1 1
ninth
@


1.8
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Mon 20 Nov 2017 21:25:22 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :16
Parents: :14

eighth
@
text
@d1 1
a1 1
eighth
@


1.7
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Mon 20 Nov 2017 23:02:46 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :14
Parents: :12

seventh
@
text
@d1 1
a1 1
seventh
@


1.6
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Mon 20 Nov 2017 22:56:46 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :12
Parents: :10

sixth
@
text
@d1 1
a1 1
sixth
@


1.5
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Fri 03 Nov 2017 13:30:17 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :10
Parents: :8

fifth
@
text
@d1 1
a1 1
fifth
@


1.4
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Fri 03 Nov 2017 13:28:35 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :8
Parents: :6

fourth
@
text
@d1 1
a1 1
fourth
@


1.3
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Fri 03 Nov 2017 13:26:41 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :6
Parents: :4

third
@
text
@d1 1
a1 1
third
@


1.2
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Fri 03 Nov 2017 13:25:01 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :4
Parents: :2

second
@
text
@d1 1
a1 1
second
@


1.1
log
@Author: Eric Sunshine <sunshine@@sunshineco.com>
Author-Date: Fri 03 Nov 2017 13:12:48 -0500
Committer: Roy G. Biv <spectrum@@color.com>
Committer-Date: Tue 21 Nov 2017 01:45:15 +0000
Mark: :2

first
@
text
@d1 1
a1 1
first
@
EOF

    cat >tiebreak.expect <<EOF
= tiebreak =============================================================
11    * 1970-01-02T00:10:00Z eleventh
10    - 1970-01-02T00:09:00Z tenth
9     - 1970-01-02T00:08:00Z ninth
8     - 1970-01-02T00:07:00Z eighth
7     - 1970-01-02T00:06:00Z seventh
6     - 1970-01-02T00:05:00Z sixth
5     - 1970-01-02T00:04:00Z fifth
4     - 1970-01-02T00:03:00Z fourth
3     - 1970-01-02T00:02:00Z third
2     - 1970-01-02T00:01:00Z second
1     - 1970-01-02T00:00:00Z first
EOF

    # shellcheck disable=SC2086
    tapdiff tiebreak tiebreak.expect "same date tie-breaking" $src -T ${TESTOPTS} list tiebreak

    cat >noheaders.expect <<EOF
= tiebreak =============================================================
11   | 1970-01-02T00:10:00Z | trunk
eleventh
------------------------------------------------------------------------
10   | 1970-01-02T00:09:00Z | trunk
tenth
------------------------------------------------------------------------
EOF

    # shellcheck disable=SC2086
    tapdiff tiebreak noheaders.expect "log suppresses headers" $src -T ${TESTOPTS} log -2 tiebreak

    cat >logheaders.expect <<EOF
= tiebreak =============================================================
11   | 1970-01-02T00:10:00Z | trunk
Author: Eric Sunshine <sunshine@sunshineco.com>
Author-Date: 2017-11-21T02:37:42Z
Author-Date-Offset: -18000
Committer: Roy G. Biv <spectrum@color.com>
Committer-Date: 2017-11-21T01:45:15Z
Committer-Date-Offset: 0
Mark: :22
Parents: :20

eleventh
------------------------------------------------------------------------
10   | 1970-01-02T00:09:00Z | trunk
Author: Eric Sunshine <sunshine@sunshineco.com>
Author-Date: 2017-11-21T02:30:40Z
Author-Date-Offset: -18000
Committer: Roy G. Biv <spectrum@color.com>
Committer-Date: 2017-11-21T01:45:15Z
Committer-Date-Offset: 0
Mark: :20
Parents: :18

tenth
------------------------------------------------------------------------
EOF

    # shellcheck disable=SC2086
    tapdiff tiebreak logheaders.expect "log -v -v shows all headers" $src -T ${TESTOPTS} log -v -v -2 tiebreak

    cat >summaryheaders.expect <<EOF
= tiebreak =============================================================
11   | 1970-01-02T00:10:00Z | trunk
Author: Eric Sunshine <sunshine@sunshineco.com> 2017-11-21T02:37:42Z
Committer: Roy G. Biv <spectrum@color.com> 2017-11-21T01:45:15Z

eleventh
------------------------------------------------------------------------
10   | 1970-01-02T00:09:00Z | trunk
Author: Eric Sunshine <sunshine@sunshineco.com> 2017-11-21T02:30:40Z
Committer: Roy G. Biv <spectrum@color.com> 2017-11-21T01:45:15Z

tenth
------------------------------------------------------------------------
EOF

    # shellcheck disable=SC2086
    tapdiff tiebreak summaryheaders.expect "log -v shows summarized headers" $src -T ${TESTOPTS} log -v -2 tiebreak

    cat >authordate1.expect <<EOF
= tiebreak =============================================================
11    * 2017-11-21T02:37:42Z eleventh
10    - 2017-11-21T02:30:40Z tenth
EOF
    # shellcheck disable=SC2086
    tapdiff tiebreak authordate1.expect "author date from RFC 822 header (list)" $src ${TESTOPTS} list -2 tiebreak

    cat >authordate2.expect <<EOF
= tiebreak =============================================================
11   | 2017-11-21T02:37:42Z | trunk
eleventh
------------------------------------------------------------------------
10   | 2017-11-21T02:30:40Z | trunk
tenth
------------------------------------------------------------------------
EOF
    # shellcheck disable=SC2086
    tapdiff tiebreak authordate2.expect "author date from RFC 822 header (log)" $src ${TESTOPTS} log -2 tiebreak

    # git config isn't available in CI/CD
    if [ "${USER:-cicd}" = cicd ]
    then
	tapcomment branchy "($python $backend): skipping tiebreak fast-export test"
    else
	# shellcheck disable=SC2086
	taptest tiebreak "fast export of tiebreak" $src ${TESTOPTS} fast-export 1 tiebreak
	tapgrep tiebreak "author Eric Sunshine <sunshine@sunshineco.com> 1509732768 -0500" "fast-export: consult RFC 822 headers (author)"
	tapgrep tiebreak "committer Roy G. Biv <spectrum@color.com> 1511228715 +0000" "fast-export: consult RFC 822 headers (committer)"
    fi
fi

# Now for the srcify test
rm -fr .src RCS SCCS

cat >srcifyfile <<EOF
Today is not that day.
EOF
if [ "$backend" = "rcs" ]
then
    mkdir RCS && rcs -q -U -kb -i srcifyfile </dev/null
else
    # shellcheck disable=SC2094
    mkdir SCCS && sccs admin -fb -i srcifyfile -y"Sample commit" <srcifyfile 2>/dev/null
fi
historify srcifyfile
# shellcheck disable=SC2086
taptest srcify "srcify command" $src -T ${TESTOPTS} srcify
test -f "$history"
tapcheck srcify "$?" "srcify created master"
test -f srcifyfile
tapcheck srcify "$?" "srcify left the workfile in place"

# Check a parsing case brought up by GitLab issue #21: Filenames including '-' are interpreted as revision ranges
touch a-b
# shellcheck disable=SC2086
taptest dashparse "checkin of file named with embedded dash" $src -T ${TESTOPTS} ci -m "Initial" -- a-b
historify a-b
test -f "$history"
tapcheck dashparse "$?" "commit of filename resembling a revision renge"

# Test deep operations
mkdir inner
echo one >inner/sample
# shellcheck disable=SC2086
taptest deep "commit of deep file" $src -T ${TESTOPTS} commit -m "'Early trunk content'" inner/sample
# shellcheck disable=SC2086
taptest deep "cat of deep file" $src -T ${TESTOPTS} cat inner/sample
tapcmp deep inner/sample "${tap_capture}out" "binary cat returned correct data"

# Test multidirectory operation
if [ "$backend" = "rcs" ]
then
    mkdir RCS-save
    # shellcheck disable=SC2086
    taptest multidir "correctly bailing out on existing RCS-save" ! $src -T ${TESTOPTS} log
    rmdir RCS-save

    mkdir RCS
    echo "RCS mark" >RCS/rcsmark

    echo "tweedledum" >tweedledum
    echo "tweedledee" >tweedledee

    # shellcheck disable=SC2086
    taptest multidir "multidirectory checkin to .src" $src -q -T ${TESTOPTS} ci -m "helter" tweedledum

    test -f .src/tweedledum,v
    tapcheck multidir "$?" "master location check after multidirectory checkin"

    ! test -f .src/tweedledum
    tapcheck multidir "$?" "content location check after multidirectory checkin"

    test -f RCS/rcsmark
    tapcheck multidir "$?" "RCS restoration check after multidirectory shuffle"

    ! test -f RCS-save
    tapcheck multidir "$?" "no exiguous save directory after shuffle"

    # shellcheck disable=SC2086
    taptest multidir "multidir checkin with -S RCS" $src -S RCS -T ${TESTOPTS} ci -m "skelter" tweedledee

    # shellcheck disable=SC2086
    taptest multidir "multidir tag creation" $src -T ${TESTOPTS} tag -c fimbulwinter tweedledum

    # shellcheck disable=SC2086
    taptest multidir "multidir tag rename" $src -T ${TESTOPTS} rename tag fimbulwinter niflheim -- tweedledum

    cat >tweedledee.expected <<EOF
= tweedledee ===========================================================
1     * 1970-01-02T00:00:00Z skelter
EOF
    # shellcheck disable=SC2086
    tapdiff multidir tweedledee.expected "list check after multidirectory -S checkin" $src -q -S RCS -T ${TESTOPTS} list

    cat >tweedledee.expected <<EOF
tweedledee
EOF
    # shellcheck disable=SC2086
    tapdiff multidir tweedledee.expected "cat check after multidirectory -S checkin" $src -q -S RCS -T ${TESTOPTS} cat tweedledee

    test -f RCS/tweedledee,v
    tapcheck multidir "$?" "master-location check after multidirectory -S checkin"

    rm -fr RCS
fi

# Back up to sandbox directory
cd ..

} # end of testbackend

if [ "${python}" != "" ] && [ "${backend}" != "" ]
then
    test_backend
elif [ "${python}" != "" ]
then
    backend="rcs"
    test_backend
    backend="sccs"
    test_backend
elif [ "${backend}" != "" ]
then
    python=python2
    test_backend
    python=python3
    test_backend
else
    python=python2
    backend="rcs"
    test_backend
    python=python3
    backend="rcs"
    test_backend
    python=python2
    backend="sccs"
    test_backend
    python=python3
    backend="sccs"
    test_backend
fi

echo "1..$((testcount-1))"

rm -fr "$SANDBOX"

# end