summaryrefslogtreecommitdiff
path: root/regress/usr.bin/rcs/Makefile
blob: defadaeeeff7284ff624623fb5a31b5a244a36d7 (plain)
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
#	$OpenBSD: Makefile,v 1.43 2020/06/26 07:55:57 stsp Exp $

# Regression tests by Niall O'Higgins <niallo@openbsd.org>.
# ksh -> Makefile by Ray Lai <ray@cyth.net>.

CI?=		ci
CO?=		co
MERGE?=		merge
RCS?=		rcs
RCSCLEAN?=	rcsclean
RCSDIFF?=	rcsdiff
RCSMERGE?=	rcsmerge
RLOG?=		rlog

DIFF=		diff -u

CLEANFILES=	RCS blah.c blah.c,v description file1 file2 file3 \
		file file,v newfile newfile,v merge-noeol.out test test,v \
		test-truncated truncated.out foo foo,v bar bar,v

# XXX - These may need to be done in order.
#	(At least start with ci-initial.)
LTESTS= ci-initial \
	ci-mflag \
	ci-lflag \
	ci-rflag \
	co-lflag \
	ci-rev \
	co-perm \
	co-perm2 \
	ci-perm \
	ci-perm2 \
	ci-dinvalid \
	ci-dold \
	ci-wflag \
	rcsdiff-uflag \
	rcsdiff-rflag \
	rcs-mflag \
	rcs-mflag2 \
	co-RCSINIT \
	ci-nflag \
	ci-Nflag \
	ci-sflag \
	co-lflag2 \
	rcsclean \
	rcsdiff \
	rcsdiff-symbols \
	merge-eflag \
	merge-noeol \
	rcsmerge \
	rcsmerge-symbols \
	ci-dflag \
	ci-xflag \
	comma \
	rcs-aflag \
	rcs-eflag \
	rcs-Aflag \
	rcs-tflag-stdin \
	rcs-tflag-stdin2 \
	rcs-tflag-stdin3 \
	rcs-tflag-inline \
	rcs-tflag-file \
	rcs-oflag \
	rcs-lock-unlock \
	co-lock-filemodes \
	co-unlock-filemodes \
	ci-filemodes \
	rcs-iflag \
	rlog-lflag \
	rlog-rflag \
	ci-nofile \
	ci-revert \
	ci-keywords \
	ci-keywords2 \
	ci-parse-keywords \
	ci-parse-keywords2 \
	co-parse-truncated \
	ci-2files \

.for t in ${LTESTS}
REGRESS_TARGETS+=test-${t}
.endfor

test-ci-initial: clean
	@echo 'this is a test file' > test
	@echo "a test file" | ${CI} -q -l test
	@grep -q 'this is a test file' test,v

# Testing 'ci test' with non-interactive log message
test-ci-mflag:
	@echo 'another revision' >> test
	@${CI} -q -m'a second revision' test
	@test ! -e test
	@grep -q 'another revision' test,v

# Testing 'co -l test'
test-ci-lflag:
	@${CO} -q -l test
	@test -e test

# Testing 'ci -r1.30 test' with non-interactive log message
test-ci-rflag:
	@echo "new stuff" >> test
	@${CI} -q -r1.30 -m'bumped rev' test
	@test ! -e test

# Testing 'co -l test'
test-co-lflag:
	@${CO} -q -l test
	@test -e test

# Testing 'ci test' (should be rev 1.31) with non-interactive log message
test-ci-rev:
	@echo "a third revision" >> test
	@${CI} -q -m'this should be rev 1.31' test
	@grep -q '1.31' test,v

# Testing 'co -u test' - ensuring permissions are 0444
test-co-perm:
	@${CO} -q -u test
	@eval 'test `stat -f%p test` = 100444'

# Testing 'co -l test' - ensuring permissions are 0644
test-co-perm2:
	@rm -rf test
	@${CO} -q -l test
	@eval 'test `stat -f%p test` = 100644'

# Testing 'ci -u' - ensuring permissions are 0444
test-ci-perm:
	@echo "a line for ci -u" >> test
	@${CI} -q -m'message for ci -u' -u test
	@eval 'test `stat -f%p test` = 100444'

# Testing 'ci -l' - ensuring permissions are 0644
test-ci-perm2:
	@rm -rf test
	@${CO} -q -l test
	@echo "a line for ci -l" >> test
	@${CI} -q -m'message for ci -l' -l test
	@eval 'test `stat -f%p test` = 100644'

# Testing ci with an invalid date
test-ci-dinvalid:
	@echo 'some text for invalid date text' >> test
	@if @${CI} -q -d'an invalid date' -m'invalid date' -l test 2>/dev/null; then false; fi
	@if grep 'some text for invalid date text' test,v; then false; fi

# Testing ci with a date older than previous revision
test-ci-dold:
	@echo 'some text for old date test' >> test
	@if ${CI} -q -d'1990-01-12 04:00:00+00' -m'old dated revision' -l test 2>/dev/null; then false; fi
	@if grep 'some text for old date test' test,v; then false; fi

# Testing ci -wtestuser
test-ci-wflag:
	@rm -rf test
	@${CO} -q -l test
	@echo "blah blah" >> test
	@echo "output for ci -w" >> test
	@${CI} -q -wtestuser -mcomment -l test
	@grep -q 'author testuser' test,v

# Testing 'rcsdiff -u test' after adding another line
test-rcsdiff-uflag:
	@echo "a line for rcsdiff test" >> test
	@${RCSDIFF} -q -u test | tail -n 5 |		\
	    ${DIFF} ${.CURDIR}/rcsdiff-uflag.out -

# Testing 'rcsdiff -u -r1.2 test'
test-rcsdiff-rflag:
	@${RCSDIFF} -q -u -r1.2 test | tail -n +3 |	\
	    ${DIFF} ${.CURDIR}/rcsdiff-rflag.out -

# Testing 'rcs -m1.2:logmessage'
test-rcs-mflag:
	@${RCS} -q -m1.2:logmessage test
	@grep -q 'logmessage' test,v

# Testing 'rcs -m'1.2:a new log message''
test-rcs-mflag2:
	@${RCS} -q -m1.1:'a new log message, one which is quite long and set by rcsprog' test
	@grep -q 'a new log message, one which is quite long and set by rcsprog' test,v

# Testing RCSINIT environment variable
test-co-RCSINIT:
	@rm -rf test
	@RCSINIT=-l ${CO} -q test
	@eval 'test `stat -f%p test` = 100644'

# Testing check-in with symbol
test-ci-nflag:
	@echo "something to check in with a symbol" >> test
	@${CI} -q -n'symbolname' -m'test symbols' -l test
	@grep -q 'symbolname' test,v

# Testing check-in, forcing symbol
test-ci-Nflag:
	@echo "something to check in with a forced symbol" >> test
	@${CI} -q -N'symbolname' -m'test force symbol' -l test
	@grep -q 'test force symbol' test,v

# Trying some jiggerypokery with state
test-ci-sflag:
	@echo "blahblah" >>  test
	@if ${CI} -q -l -s'SPACE S' -m"state with a space" test; then false; fi
	@if grep -q 'SPACE S' test,v; then false; fi

# Trying to check it out
test-co-lflag2:
	@rm -rf test
	@${CO} -q -l test
	@test -e test

test-rcsclean: clean
	@touch file
	@${RCSCLEAN} -q file
	@${RCSCLEAN} -q1.1 file
	@${RCSCLEAN} -qsym file
	@test -f file

	@echo . | ${CI} -q -nsym file
	@${CO} -q file
	@${RCSCLEAN} -q file
	@test ! -f file
	@${CO} -q file
	@${RCSCLEAN} -q1.1 file
	@test ! -f file
	@${CO} -q file
	@${RCSCLEAN} -qsym file
	@test ! -f file

	@${CO} -q -l file
	@${RCSCLEAN} -q file
	@test -f file
	@${RCSCLEAN} -q -u file
	@test ! -f file
	@${CO} -q -l file
	@echo change >> file
	@${RCSCLEAN} -q file
	@${RCSCLEAN} -q -u file
	@test -f file

test-merge-eflag: clean
	@echo "line1\nline2\nfile1new" > file1
	@echo "line1\nline2" > file2
	@echo "line1\nfile3new\nline2" > file3
	@${MERGE} -p -q -e file1 file2 file3 | \
	    ${DIFF} ${.CURDIR}/merge-eflag.out -

test-merge-noeol: clean
	@echo "<<<<<<< file1\nline1=======\nline3\n>>>>>>> file3" \
		> merge-noeol.out
	@echo -n "line1" > file1
	@echo "line2" > file2
	@echo "line3" > file3
	@${MERGE} -p -q file1 file2 file3 | \
	    ${DIFF} ${.CURDIR}/merge-noeol.out -
	@echo "<<<<<<< file1\nline1\n=======\nline3\n>>>>>>> file3" \
		> merge-noeol.out
	@echo "line1" > file1
	@echo -n "line2" > file2
	@echo "line3" > file3
	@${MERGE} -p -q file1 file2 file3 | \
	    ${DIFF} ${.CURDIR}/merge-noeol.out -
	@echo "<<<<<<< file1\nline1\n=======\nline3>>>>>>> file3" \
		> merge-noeol.out
	@echo "line1" > file1
	@echo "line2" > file2
	@echo -n "line3" > file3
	@${MERGE} -p -q file1 file2 file3 | \
	    ${DIFF} ${.CURDIR}/merge-noeol.out -
	@echo "<<<<<<< file1\nline1=======\nline3>>>>>>> file3" \
		> merge-noeol.out
	@echo -n "line1" > file1
	@echo -n "line2" > file2
	@echo -n "line3" > file3
	@${MERGE} -p -q file1 file2 file3 | \
	    ${DIFF} ${.CURDIR}/merge-noeol.out -

test-rcsmerge:
	@cp -f ${.CURDIR}/rev1 blah.c
	@echo "descr" | ${CI} -q -l -m"first rev" blah.c
	@cp -f ${.CURDIR}/rev2 blah.c
	@${CI} -q -l -m"second rev" blah.c
	@cp -f ${.CURDIR}/rev3 blah.c
	@${CI} -q -l -m"third rev" blah.c

	@${RCSMERGE} -q -r1.1 -r1.3 -p blah.c |				\
	    ${DIFF} ${.CURDIR}/rcsmerge.out -

test-rcsmerge-symbols: clean
	@mkdir RCS
	@cp -f ${.CURDIR}/rev1 blah.c
	@echo "descr" | ${CI} -q -l -nsym1 -m"first rev" blah.c
	@cp -f ${.CURDIR}/rev2 blah.c
	@${CI} -q -l -nsym2 -m"second rev" blah.c
	@cp -f ${.CURDIR}/rev3 blah.c
	@${CI} -q -l -nsym3 -m"third rev" blah.c

	@${RCSMERGE} -q -rsym1 -rsym3 -p blah.c |		\
	    ${DIFF} ${.CURDIR}/rcsmerge.out -

test-rcsdiff:
	@rm -rf blah.c,v

	@cp -f ${.CURDIR}/rev1 blah.c
	@echo "descr" | ${CI} -q -l -m"first rev" blah.c
	@cp -f ${.CURDIR}/rev2 blah.c
	@${CI} -q -l -m"second rev" blah.c
	@cp -f ${.CURDIR}/rev3 blah.c
	@${CI} -q -l -m"third rev" blah.c

	@${RCSDIFF} -q -r1.1 -r1.3 -u blah.c | tail -n +3 |		\
	    ${DIFF} ${.CURDIR}/rcsdiff.out -

test-rcsdiff-symbols: clean
	@mkdir RCS
	@cp -f ${.CURDIR}/rev1 blah.c
	@echo "descr" | ${CI} -q -l -nsym1 -m"first rev" blah.c
	@cp -f ${.CURDIR}/rev2 blah.c
	@${CI} -q -l -nsym2 -m"second rev" blah.c
	@cp -f ${.CURDIR}/rev3 blah.c
	@${CI} -q -l -nsym3 -m"third rev" blah.c

	@${RCSDIFF} -q -rsym1 -rsym3 -u blah.c | tail -n +3 |		\
	    ${DIFF} ${.CURDIR}/rcsdiff.out -

# Testing 'ci -d'2037-01-12 04:00:00+00' -l test
test-ci-dflag: clean
	@echo "some text for date test" >> test
	@echo . | ${CI} -q -d'2037-01-12 04:00:00+00' -m'dated revision' -l test
	@grep -q 'dated revision' test,v

test-ci-xflag:
	@mkdir -p RCS
	@rm -rf RCS/file*
	@touch file
	@echo . | ${CI} -q -x,abcd/,v file
	@test -e RCS/file,abcd
	@test ! -e RCS/file,v

	@mv -f RCS/file,abcd RCS/file,v
	@${CO} -q -l file
	@echo revision >> file
	@echo . | ${CI} -q -x,abcd/,v/xyz file
	@test ! -e RCS/file,abcd
	@fgrep -q revision RCS/file,v
	@test ! -e RCS/filexyz

	@touch file
	@echo more >> file
	@echo . | ${CI} -q -x file
	@fgrep -q more RCS/file

test-comma:
	@rm -rf RCS
	@mkdir -p RCS
	@touch file,notext
	@echo . | ${CI} -q file,notext
	@test -e RCS/file,notext,v
	@test ! -e RCS/file,v

# Testing 'rcs -afoo,bar,baz'
test-rcs-aflag: clean
	@echo "." | ${RCS} -q -i test
	@${RCS} -q -afoo,bar,baz test
	@${RLOG} test | ${DIFF} ${.CURDIR}/rcs-aflag.out -

# Testing 'rcs -efoo,bar,baz'
test-rcs-eflag: test-rcs-aflag
	@${RCS} -q -efoo,bar,baz test
	@${RLOG} test | ${DIFF} ${.CURDIR}/rcs-eflag.out -

# Testing  'rcs -Atest newfile'
test-rcs-Aflag: test-rcs-aflag
	@echo "." | ${RCS} -q -i newfile
	@${RCS} -q -Atest newfile
	@${RLOG} newfile | ${DIFF} ${.CURDIR}/rcs-Aflag.out -

test-rcs-tflag-stdin: clean
	@echo 'This is a description.' | ${RCS} -q -i -t file
	@fgrep -q 'This is a description.' file,v

test-rcs-tflag-stdin2: clean
	@echo '.This is not the description end.' | ${RCS} -q -i -t file
	@fgrep -q '.This is not the description end.' file,v

test-rcs-tflag-stdin3: clean
	@echo "This is the description end.\n.\nThis should not be here." | \
	    ${RCS} -q -i -t file
	@fgrep -q 'This should not be here.' file,v || \
	    case "$$?" in 1) exit 0;; esac && exit 1

test-rcs-tflag-inline: clean
	@${RCS} -q -i '-t-This is a description.' file
	@fgrep -q 'This is a description.' file,v

test-rcs-tflag-file: clean
	@echo 'This is a description.' > description
	@${RCS} -q -i -tdescription file
	@fgrep -q 'This is a description.' file,v

# Testing deletion of ranges
test-rcs-oflag: clean
	@cp ${.CURDIR}/rev3 blah.c
	@echo "blah" | ${CI} -q blah.c
	@${CO} -q -l blah.c
	@echo "blah2" >> blah.c
	@echo "blah2" | ${CI} -q blah.c
	@${CO} -q -l blah.c
	@echo "blah3" >> blah.c
	@echo "blah3" | ${CI} -q blah.c
	@${CO} -q -l blah.c
	@echo "blah4" >> blah.c
	@echo "blah4" | ${CI} -q blah.c
	@${CO} -q -l blah.c
	@echo "blah5" >> blah.c
	@echo "blah5" | ${CI} -q blah.c
	@${CO} -q -l blah.c
	@echo "blah6" >> blah.c
	@echo "blah6" | ${CI} -q blah.c
	@${CO} -q -l blah.c
	@${RCS} -q -o1.3:1.5 blah.c
	@tr '\n' ' ' < blah.c,v | grep -q '[[:space:]]1.3[[:space:]]' || \
	    case "$$?" in 1) exit 0;; esac && exit 1
	@tr '\n' ' ' < blah.c,v | grep -q '[[:space:]]1.4[[:space:]]' || \
	    case "$$?" in 1) exit 0;; esac && exit 1
	@tr '\n' ' ' < blah.c,v | grep -q '[[:space:]]1.5[[:space:]]' || \
	    case "$$?" in 1) exit 0;; esac && exit 1
	
test-rcs-lock-unlock: clean
	@touch file
	@mkdir -p RCS
	@echo . | ${CI} -q -l file
	@echo sometext > file
	@echo . | ${CI} -q file

	@${RCS} -q -l file
	@${RLOG} file | fgrep -x -A 1 'locks: strict' | head -n 2 | fgrep -q 1.2
	@${RCS} -q -u file
	@${RLOG} file | fgrep -x -A 1 'locks: strict' | head -n 2 | fgrep -q 1.2 || \
	    case "$$?" in 1) exit 0;; esac && exit 1

	@${RCS} -q -l1.1 file
	@${RLOG} file | fgrep -x -A 1 'locks: strict' | head -n 2 | fgrep -q 1.1
	@${RCS} -q -u1.1 file
	@${RLOG} file | fgrep -x -A 1 'locks: strict' | head -n 2 | fgrep -q 1.1 || \
	    case "$$?" in 1) exit 0;; esac && exit 1

	@${RCS} -q -l1.2 file
	@${RLOG} file | fgrep -x -A 1 'locks: strict' | head -n 2 | fgrep -q 1.2
	@${RCS} -q -u1.2 file
	@${RLOG} file | fgrep -x -A 1 'locks: strict' | head -n 2 | fgrep -q 1.2 || \
	    case "$$?" in 1) exit 0;; esac && exit 1

	@${RCS} -q -u file
	@${RCS} -q -l file
	@${RCS} -q -l file
	@${RCS} -q -l1.3 file || case "$$?" in 1) exit 0;; esac && exit 1
	@${RCS} -q -u1.3 file || case "$$?" in 1) exit 0;; esac && exit 1

# Testing 'co -l blah.c' for permissions inheritance
test-co-lock-filemodes:
	@rm -rf RCS/blah.c,v blah.c
	@mkdir -p RCS
	@cp ${.CURDIR}/rev3 blah.c
	@chmod 444 blah.c
	@echo "blah" | ${CI} -q blah.c
	@chmod 755 RCS/blah.c,v
	@${CO} -q -l blah.c
	@eval 'test `stat -f%p blah.c` = 100755'
	@rm -rf blah.c
	@chmod 666 RCS/blah.c,v
	@${CO} -q -l blah.c
	@eval 'test `stat -f%p blah.c` = 100644'
	@rm -rf blah.c
	@chmod 600 RCS/blah.c,v
	@${CO} -q -l blah.c
	@eval 'test `stat -f%p blah.c` = 100600'
	@rm -rf blah.c
	@chmod 604 RCS/blah.c,v
	@${CO} -q -l blah.c
	@eval 'test `stat -f%p blah.c` = 100604'
	@rm -rf blah.c
	@chmod 754 RCS/blah.c,v
	@${CO} -q -l blah.c
	@eval 'test `stat -f%p blah.c` = 100754'
	

# Testing 'co -u blah.c' for permissions inheritance
test-co-unlock-filemodes: test-co-lock-filemodes
	@rm -rf RCS/blah.c,v blah.c
	@mkdir -p RCS
	@cp ${.CURDIR}/rev3 blah.c
	@echo "blah" | ${CI} -q blah.c
	@chmod 755 RCS/blah.c,v
	@${CO} -q -u blah.c
	@eval 'test `stat -f%p blah.c` = 100555'
	@rm -rf blah.c
	@chmod 666 RCS/blah.c,v
	@${CO} -q -u blah.c
	@eval 'test `stat -f%p blah.c` = 100444'
	@rm -rf blah.c
	@chmod 600 RCS/blah.c,v
	@${CO} -q -u blah.c
	@eval 'test `stat -f%p blah.c` = 100400'
	@rm -rf blah.c
	@chmod 604 RCS/blah.c,v
	@${CO} -q -u blah.c
	@eval 'test `stat -f%p blah.c` = 100404'
	@rm -rf blah.c
	@chmod 754 RCS/blah.c,v
	@${CO} -q -u blah.c
	@eval 'test `stat -f%p blah.c` = 100554'

# Testing 'ci blah.c' for permissions inheritance
test-ci-filemodes: test-co-unlock-filemodes
	@rm -rf RCS/blah.c,v blah.c
	@mkdir -p RCS
	@cp ${.CURDIR}/rev3 blah.c
	@chmod 755 blah.c
	@echo "blah" | ${CI} -q blah.c
	@eval 'test `stat -f%p RCS/blah.c,v` = 100555'
	@rm -rf RCS/blah.c,v blah.c
	@cp ${.CURDIR}/rev3 blah.c
	@chmod 666 blah.c
	@echo "blah" | ${CI} -q blah.c
	@eval 'test `stat -f%p RCS/blah.c,v` = 100444'
	@rm -rf RCS/blah.c,v blah.c
	@cp ${.CURDIR}/rev3 blah.c
	@chmod 700 blah.c
	@echo "blah" | ${CI} -q blah.c
	@eval 'test `stat -f%p RCS/blah.c,v` = 100500'
	@rm -rf RCS/blah.c,v blah.c
	@cp ${.CURDIR}/rev3 blah.c
	@chmod 606 blah.c
	@echo "blah" | ${CI} -q blah.c
	@eval 'test `stat -f%p RCS/blah.c,v` = 100404'

# Test various operations on a file with no revisions.
test-rcs-iflag: clean
	@mkdir -p RCS
	@echo . | ${RCS} -i -q file
	@test -f RCS/file,v
	@${CO} -q file
	@test -f file
	@test ! -s file
	@rm -f file
	@${CO} -q -l file
	@echo text >> file
	@${CI} -q file
	@fgrep -q 1.1 RCS/file,v

test-rlog-lflag: clean
	@mkdir RCS
	@touch file
	@echo rev1 | ${CI} -q -l file
	@${RLOG} -l file | fgrep -q 'revision 1.1'
	@echo line >> file
	@echo rev2 | ${CI} -q file
	@${RLOG} -l file | fgrep -q 'revision 1.2' ||	\
	    case "$$?" in 1) exit 0;; esac && exit 1

# Test various cases for the -r flag
test-rlog-rflag: clean
	@touch file
	@echo "foo" > file
	@echo "descr" | ${CI} -q -m"first rev" -d'2006-01-01 00:00:00+00' \
		-wfoo file
	@${CO} -q -l file
	@echo "foo" >> file
	@${CI} -q -m"second rev" -d'2006-01-01 00:00:00+00' -wfoo file
	@${CO} -q -l file
	@echo "foo" >> file
	@${CI} -q -m"third rev" -d'2006-01-01 00:00:00+00' -wfoo file

	@${RLOG} -r1.1 file | ${DIFF} ${.CURDIR}/rlog-rflag1.out -
	@${RLOG} -r1.1:1.3 file | ${DIFF} ${.CURDIR}/rlog-rflag2.out -
	@${RLOG} -r1.2: file | ${DIFF} ${.CURDIR}/rlog-rflag3.out -
	@${RLOG} -r:1.1 file | ${DIFF} ${.CURDIR}/rlog-rflag4.out -

test-rlog-zflag: clean
	@touch file
	@echo "descr" | ${CI} -q -m"first rev" -d'2006-01-01 00:00:00+00' \
		-wfoo file
	@${RLOG} -zLT file | ${DIFF} ${.CURDIR}/rlog-zflag1.out -
	@${RLOG} -z+03:14:23 file | ${DIFF} ${.CURDIR}/rlog-zflag2.out -
	@${RLOG} -z+03:14 file | ${DIFF} ${.CURDIR}/rlog-zflag3.out -
	@${RLOG} -z+0314 file | ${DIFF} ${.CURDIR}/rlog-zflag4.out -
	@${RLOG} -z-03:14:23 file | ${DIFF} ${.CURDIR}/rlog-zflag5.out -

test-ci-nofile:
	@${CI} -q nonexistent || case "$$?" in 1) exit 0;; esac && exit 1

test-ci-revert: clean
	@mkdir RCS
	@touch file
	@echo . | ${CI} -q -l file
	@${CI} -q -mm -l file
	@# Make sure reverting doesn't unlock file.
	@${CI} -q -mm -l file

test-ci-keywords: clean
	@mkdir RCS
	@sed 's/.*/$$&$$/' ${.CURDIR}/keywords.in > file
	@sed 's/^[A-Z][A-Z]*[a-z][a-z]*: .*/$$&$$/' ${.CURDIR}/keywords.out > newfile
	@echo . | ${CI} -q -u file
	@sed -e 's,${USER},USER,' -e "s/\($$[A-Z][a-z]*: \).*file,v/\1file,v/" \
	    -e 's,[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9],YYYY/MM/DD HH:MI:SS,' \
	    file | ${DIFF} newfile -

# Lots of expansion.
test-ci-keywords2: clean
	@perl -e 'print "\$$Id\$$\n" x 10000;' > file
	@echo . | ${CI} -l -q file

test-ci-parse-keywords: clean
	@echo '$Id' > test
	@echo . | ${CI} -q -k test

test-ci-parse-keywords2: clean
	@echo '$Id: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah' > test 
	@echo . | ${CI} -q -k test

# Check for correct EOF handling in rcs parser
test-co-parse-truncated: clean
	@sh -c 'ulimit -d 5000 && ${CO} -q ${.CURDIR}/test-truncated > truncated.out 2>&1' || \
	    case "$$?" in 1) exit 0;; esac && exit 1
	@grep -q 'co: could not parse admin data' truncated.out

test-ci-2files: clean
	@touch foo bar
	@${CI} -q -t-first -l foo
	@test -f foo,v -a ! -f bar,v
	@${CI} -q -t-second -l foo bar
	@test -f foo,v -a -f bar,v

clean:
	@rm -rf ${CLEANFILES}

.include <bsd.regress.mk>