xref: /openbsd-src/regress/usr.bin/patch/Makefile (revision 6dee77f7ca11af954e3f5552c3d217565c57eaf2)
1# $OpenBSD: Makefile,v 1.14 2022/08/03 07:35:04 op Exp $
2
3PATCH?=		patch
4PATCHFLAGS=	-sN
5CLEANFILES=	*.copy *.orig *.rej t5 d19/*
6
7REGRESS_TARGETS=     t1  t2  t3  t4  t5  t6  t7  t8  t9 \
8		t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20
9
10# .in: input file
11# .diff: patch
12# .out: desired result after patching
13
14# t1: diff contains invalid line number 0.
15# t2: diff contains invalid line numbers beyond end of input file.
16# t3: a case where patch should detect a previously applied patch.
17#     Diff transform an empty file into a single line one.
18# t4: a case where patch has to detect a previously applied patch.
19#     Diff transform a file with a single line with an eol into a single
20#     line without eol.
21# t5: both files in diff do not exist. t5.in should be missing.
22# t6-t12: various cases of no eol at end of file handling.
23# t13: a case where patch has to detect a previously applied patch.
24#     Diff transform a file ending with no eol into a file ending with eol.
25# t14: diff in normal diff format.
26# t15: diff in context diff format.
27# t16: diff in ed format.
28# t17: diff in ed format that inserts a dot-line.
29# t18: diff in ed format that fully replaces input content.
30# t19: git-produced unified diff.
31# t20: reversal application of a patch to create a file with a single line.
32
33.SUFFIXES: .in
34
35.in:
36	@echo ${*}
37	@cp ${.CURDIR}/${*}.in ${*}.copy
38	@${PATCH} ${PATCHFLAGS} ${*}.copy ${.CURDIR}/${*}.diff
39	@cmp -s ${*}.copy ${.CURDIR}/${*}.out || \
40		(echo "XXX ${*} failed" && false)
41
42t3:
43	@echo ${*}
44	@cp ${.CURDIR}/${*}.in ${*}.copy
45	@(! ${PATCH} ${PATCHFLAGS} ${*}.copy ${.CURDIR}/${*}.diff)
46	@cmp -s ${*}.copy ${.CURDIR}/${*}.out || \
47		(echo "XXX ${*} failed" && false)
48
49t4:
50	@echo ${*}
51	@cp ${.CURDIR}/${*}.in ${*}.copy
52	@(! ${PATCH} ${PATCHFLAGS} ${*}.copy ${.CURDIR}/${*}.diff)
53	@cmp -s ${*}.copy ${.CURDIR}/${*}.out || \
54		(echo "XXX ${*} failed" && false)
55
56t5:
57	@echo ${*}
58	@rm -f ${*}
59	@${PATCH} ${PATCHFLAGS} < ${.CURDIR}/${*}.diff
60	@cmp -s ${*} ${.CURDIR}/${*}.out || (echo "XXX ${*} failed" && false)
61
62t13:
63	@echo ${*}
64	@cp ${.CURDIR}/${*}.in ${*}.copy
65	@(! ${PATCH} ${PATCHFLAGS} ${*}.copy ${.CURDIR}/${*}.diff)
66	@cmp -s ${*}.copy ${.CURDIR}/${*}.out || \
67		(echo "XXX ${*} failed" && false)
68
69t19:
70	@echo t19
71	@mkdir -p d19
72	@cp ${.CURDIR}/t19.in d19/file
73	@${PATCH} -t ${PATCHFLAGS} < ${.CURDIR}/t19.diff
74	@cmp -s ${.CURDIR}/t19.out d19/file || (echo "XXX t19 failed" && false)
75
76t20:
77	@echo ${*}
78	@cp ${.CURDIR}/${*}.in ${*}.copy
79	@${PATCH} ${PATCHFLAGS} -Rf ${*}.copy ${.CURDIR}/${*}.diff
80	@cmp -s ${*}.copy ${.CURDIR}/${*}.out || \
81		(echo "XXX ${*} failed" && false)
82
83.PHONY: t5
84
85.include <bsd.regress.mk>
86