-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
87 lines (80 loc) · 1.94 KB
/
Makefile
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
CFLAGS = -Wall -O3 -g
LDFLAGS = -Wall -O3 -g
PREFIX = /usr/local
.PHONY: all
all: pepclean test
.PHONY: clean
clean:
$(RM) pepclean.o pepclean mangled expected
.PHONY: install
install: $(PREFIX)/bin/pepclean
.PHONY: uninstall
uninstall:
$(RM) $(PREFIX)/bin/pepclean
$(PREFIX)/bin/pepclean: pepclean
install -t $(PREFIX)/bin pepclean
pepclean: pepclean.o
.PHONY: test
test: pepclean
@echo
@echo '****** RUNNING TESTS ******'
@echo
# empty file
printf '' > mangled
printf '' > expected
./pepclean mangled; test $$? -eq 0
diff -pu mangled expected
# CRs
printf 'X\nY\r\nZ\n' > mangled
printf 'X\nY\nZ\n' > expected
./pepclean mangled; test $$? -eq 2
diff -pu mangled expected
# TABs
printf 'X \t X\n' > mangled
printf 'X X\n' > expected
./pepclean mangled; test $$? -eq 2
diff -pu mangled expected
# trailing spaces
printf 'abc \n' > mangled
printf 'abc\n' > expected
./pepclean mangled; test $$? -eq 2
diff -pu mangled expected
# one or more LFs
printf 'a\n' > expected
for x in `seq 1 40`; do \
printf 'a' > mangled; \
for y in `seq $$x`; do printf '\n' >> mangled; done; \
./pepclean mangled; \
if ! diff -pu mangled expected; then \
echo "error at 'a' + $$x LFs" >&2; \
exit 1; \
fi; \
done
# single LF
printf '\n' > mangled
printf '' > expected
./pepclean mangled; test $$? -eq 2
diff -pu mangled expected
# zero LFs
printf 'abcdef' > mangled
printf 'abcdef\n' > expected
./pepclean mangled; test $$? -eq 2
diff -pu mangled expected
# giant file without LF
printf '' > mangled
for x in `seq 2048`; do \
printf 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' >> mangled; \
done
cp mangled expected
printf '\n' >> expected
./pepclean mangled; test $$? -eq 2
diff -pu mangled expected
# double tab
printf '\t\tabc\n' > mangled
printf ' abc\n' > expected
./pepclean mangled; test $$? -eq 2
diff -pu mangled expected
@echo
@echo '****** FINISHED TESTS ******'
@echo
$(RM) mangled expected