-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
253 lines (243 loc) · 7.92 KB
/
Makefile
File metadata and controls
253 lines (243 loc) · 7.92 KB
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
FILTER = container-writer.lua
STRIP_FILTER = container-strip.lua
UNWRAP_FILTER = container-unwrap.lua
STRIP_INPUTS = $(wildcard test/input/strip-*.md)
INPUTS_NOFILTER = $(wildcard test/input/noop*.md)
INPUTS = $(filter-out $(STRIP_INPUTS) $(INPUTS_NOFILTER), $(wildcard test/input/*.md))
FORMATS = latex context typst
.PHONY: test test-noop test-strip test-quarto test-quarto-strip \
generate-tests generate-noop-tests generate-strip-tests clean
test: test-noop
@failed=0; \
for f in $(INPUTS); do \
name=$$(basename $$f .md); \
for fmt in $(FORMATS); do \
pandoc --lua-filter=$(FILTER) $$f -t $$fmt \
> /tmp/cw_$${name}_$${fmt}.out \
2>/tmp/cw_$${name}_$${fmt}.err; \
stdout_ok=1; stderr_ok=1; \
if ! diff -q /tmp/cw_$${name}_$${fmt}.out \
test/expected/$${name}-$${fmt}.out \
> /dev/null 2>&1; then \
echo "FAIL: $$name ($$fmt stdout)"; \
diff /tmp/cw_$${name}_$${fmt}.out \
test/expected/$${name}-$${fmt}.out; \
stdout_ok=0; failed=1; \
fi; \
if [ -f test/expected/$${name}-$${fmt}.err ]; then \
if ! diff -q /tmp/cw_$${name}_$${fmt}.err \
test/expected/$${name}-$${fmt}.err \
> /dev/null 2>&1; then \
echo "FAIL: $$name ($$fmt stderr)"; \
diff /tmp/cw_$${name}_$${fmt}.err \
test/expected/$${name}-$${fmt}.err; \
stderr_ok=0; failed=1; \
fi; \
elif [ -s /tmp/cw_$${name}_$${fmt}.err ]; then \
echo "FAIL: $$name ($$fmt unexpected stderr)"; \
cat /tmp/cw_$${name}_$${fmt}.err; \
stderr_ok=0; failed=1; \
fi; \
[ $$stdout_ok -eq 1 ] && [ $$stderr_ok -eq 1 ] \
&& echo "PASS: $$name ($$fmt)"; \
done; \
done; \
exit $$failed
test-noop:
@failed=0; \
for f in $(INPUTS_NOFILTER); do \
name=$$(basename $$f .md); \
for fmt in $(FORMATS); do \
pandoc --lua-filter=$(FILTER) \
--lua-filter=$(UNWRAP_FILTER) $$f -t $$fmt \
> /tmp/cw_$${name}_$${fmt}.out \
2>/tmp/cw_$${name}_$${fmt}.err; \
stdout_ok=1; stderr_ok=1; \
if ! diff -q /tmp/cw_$${name}_$${fmt}.out \
test/expected/$${name}-$${fmt}.out \
> /dev/null 2>&1; then \
echo "FAIL: $$name ($$fmt stdout)"; \
diff /tmp/cw_$${name}_$${fmt}.out \
test/expected/$${name}-$${fmt}.out; \
stdout_ok=0; failed=1; \
fi; \
if [ -f test/expected/$${name}-$${fmt}.err ]; then \
if ! diff -q /tmp/cw_$${name}_$${fmt}.err \
test/expected/$${name}-$${fmt}.err \
> /dev/null 2>&1; then \
echo "FAIL: $$name ($$fmt stderr)"; \
diff /tmp/cw_$${name}_$${fmt}.err \
test/expected/$${name}-$${fmt}.err; \
stderr_ok=0; failed=1; \
fi; \
elif [ -s /tmp/cw_$${name}_$${fmt}.err ]; then \
echo "FAIL: $$name ($$fmt unexpected stderr)"; \
cat /tmp/cw_$${name}_$${fmt}.err; \
stderr_ok=0; failed=1; \
fi; \
[ $$stdout_ok -eq 1 ] && [ $$stderr_ok -eq 1 ] \
&& echo "PASS: $$name ($$fmt)"; \
done; \
done; \
exit $$failed
test-strip:
@failed=0; \
for f in $(STRIP_INPUTS); do \
name=$$(basename $$f .md); \
pandoc --lua-filter=$(STRIP_FILTER) \
--lua-filter=$(FILTER) $$f -t markdown \
> /tmp/cw_$${name}.out \
2>/tmp/cw_$${name}.err; \
stdout_ok=1; stderr_ok=1; \
if ! diff -q /tmp/cw_$${name}.out \
test/expected/$${name}.out \
> /dev/null 2>&1; then \
echo "FAIL: $$name (stdout)"; \
diff /tmp/cw_$${name}.out \
test/expected/$${name}.out; \
stdout_ok=0; failed=1; \
fi; \
if [ -f test/expected/$${name}.err ]; then \
if ! diff -q /tmp/cw_$${name}.err \
test/expected/$${name}.err \
> /dev/null 2>&1; then \
echo "FAIL: $$name (stderr)"; \
diff /tmp/cw_$${name}.err \
test/expected/$${name}.err; \
stderr_ok=0; failed=1; \
fi; \
elif [ -s /tmp/cw_$${name}.err ]; then \
echo "FAIL: $$name (unexpected stderr)"; \
cat /tmp/cw_$${name}.err; \
stderr_ok=0; failed=1; \
fi; \
[ $$stdout_ok -eq 1 ] && [ $$stderr_ok -eq 1 ] \
&& echo "PASS: $$name"; \
done; \
exit $$failed
# Quarto tests — verifies filter produces identical output under Quarto's
# bundled Pandoc. Uses the same expected files as plain Pandoc tests.
test-quarto:
@failed=0; \
for f in $(INPUTS); do \
name=$$(basename $$f .md); \
for fmt in $(FORMATS); do \
quarto pandoc --lua-filter=$(FILTER) $$f -t $$fmt \
> /tmp/cw_$${name}_$${fmt}.out \
2>/tmp/cw_$${name}_$${fmt}.err; \
stdout_ok=1; stderr_ok=1; \
if ! diff -q /tmp/cw_$${name}_$${fmt}.out \
test/expected/$${name}-$${fmt}.out \
> /dev/null 2>&1; then \
echo "FAIL: $$name ($$fmt stdout)"; \
diff /tmp/cw_$${name}_$${fmt}.out \
test/expected/$${name}-$${fmt}.out; \
stdout_ok=0; failed=1; \
fi; \
if [ -f test/expected/$${name}-$${fmt}.err ]; then \
if ! diff -q /tmp/cw_$${name}_$${fmt}.err \
test/expected/$${name}-$${fmt}.err \
> /dev/null 2>&1; then \
echo "FAIL: $$name ($$fmt stderr)"; \
diff /tmp/cw_$${name}_$${fmt}.err \
test/expected/$${name}-$${fmt}.err; \
stderr_ok=0; failed=1; \
fi; \
elif [ -s /tmp/cw_$${name}_$${fmt}.err ]; then \
echo "FAIL: $$name ($$fmt unexpected stderr)"; \
cat /tmp/cw_$${name}_$${fmt}.err; \
stderr_ok=0; failed=1; \
fi; \
[ $$stdout_ok -eq 1 ] && [ $$stderr_ok -eq 1 ] \
&& echo "PASS: $$name ($$fmt)"; \
done; \
done; \
exit $$failed
test-quarto-strip:
@failed=0; \
for f in $(STRIP_INPUTS); do \
name=$$(basename $$f .md); \
quarto pandoc --lua-filter=$(STRIP_FILTER) \
--lua-filter=$(FILTER) $$f -t markdown \
> /tmp/cw_$${name}.out \
2>/tmp/cw_$${name}.err; \
stdout_ok=1; stderr_ok=1; \
if ! diff -q /tmp/cw_$${name}.out \
test/expected/$${name}.out \
> /dev/null 2>&1; then \
echo "FAIL: $$name (stdout)"; \
diff /tmp/cw_$${name}.out \
test/expected/$${name}.out; \
stdout_ok=0; failed=1; \
fi; \
if [ -f test/expected/$${name}.err ]; then \
if ! diff -q /tmp/cw_$${name}.err \
test/expected/$${name}.err \
> /dev/null 2>&1; then \
echo "FAIL: $$name (stderr)"; \
diff /tmp/cw_$${name}.err \
test/expected/$${name}.err; \
stderr_ok=0; failed=1; \
fi; \
elif [ -s /tmp/cw_$${name}.err ]; then \
echo "FAIL: $$name (unexpected stderr)"; \
cat /tmp/cw_$${name}.err; \
stderr_ok=0; failed=1; \
fi; \
[ $$stdout_ok -eq 1 ] && [ $$stderr_ok -eq 1 ] \
&& echo "PASS: $$name"; \
done; \
exit $$failed
generate-tests:
@mkdir -p test/expected
@for f in $(INPUTS); do \
name=$$(basename $$f .md); \
for fmt in $(FORMATS); do \
pandoc --lua-filter=$(FILTER) $$f -t $$fmt \
> test/expected/$${name}-$${fmt}.out \
2>test/expected/$${name}-$${fmt}.err.tmp; \
if [ -s test/expected/$${name}-$${fmt}.err.tmp ]; then \
mv test/expected/$${name}-$${fmt}.err.tmp \
test/expected/$${name}-$${fmt}.err; \
else \
rm -f test/expected/$${name}-$${fmt}.err.tmp; \
fi; \
echo "Generated: $$name ($$fmt)"; \
done; \
done
generate-noop-tests:
@mkdir -p test/expected
@for f in $(INPUTS_NOFILTER); do \
name=$$(basename $$f .md); \
for fmt in $(FORMATS); do \
pandoc --lua-filter=$(FILTER) \
--lua-filter=$(UNWRAP_FILTER) $$f -t $$fmt \
> test/expected/$${name}-$${fmt}.out \
2>test/expected/$${name}-$${fmt}.err.tmp; \
if [ -s test/expected/$${name}-$${fmt}.err.tmp ]; then \
mv test/expected/$${name}-$${fmt}.err.tmp \
test/expected/$${name}-$${fmt}.err; \
else \
rm -f test/expected/$${name}-$${fmt}.err.tmp; \
fi; \
echo "Generated: $$name ($$fmt)"; \
done; \
done
generate-strip-tests:
@mkdir -p test/expected
@for f in $(STRIP_INPUTS); do \
name=$$(basename $$f .md); \
pandoc --lua-filter=$(STRIP_FILTER) \
--lua-filter=$(FILTER) $$f -t markdown \
> test/expected/$${name}.out \
2>test/expected/$${name}.err.tmp; \
if [ -s test/expected/$${name}.err.tmp ]; then \
mv test/expected/$${name}.err.tmp \
test/expected/$${name}.err; \
else \
rm -f test/expected/$${name}.err.tmp; \
fi; \
echo "Generated: $$name"; \
done
clean:
rm -f /tmp/cw_*.out /tmp/cw_*.err