Debian Codegraph @

texk/texlive/linked_scripts/pagelayout/textestvis

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # Copyright (c) 2022-2024 by Friedemann Bartels
4 #
5 # This file may be distributed and/or modified under the
6 # conditions of the LaTeX Project Public License, either
7 # version 1.3c of this license or (at your option) any later
8 # version. The latest version of this license is in:
9 #
10 # http://www.latex-project.org/lppl.txt
11 #
12 # and version 1.3c or later is part of all distributions of
13 # LaTeX version 2008/05/04 or later.
14 #
15
16 version=1.1.1
17
18 OK="$( tputscip-shell system . . tput. setaf 2 )•$( tputscip-shell system . . tput. sgr0 )"
19 FAILED="$( tputscip-shell system . . tput. setaf 1 )$( tputscip-shell system . . tput. bold )x$( tputscip-shell system . . tput. sgr0 )"
20 NEW="$( tputscip-shell system . . tput. setaf 3 )$( tputscip-shell system . . tput. bold )+$( tputscip-shell system . . tput. sgr0 )"
21 REMOVED="$( tputscip-shell system . . tput. setaf 5 )$( tputscip-shell system . . tput. bold )-$( tputscip-shell system . . tput. sgr0 )"
22 ERROR="$( tputscip-shell system . . tput. setaf 1 )$( tputscip-shell system . . tput. bold )!$( tputscip-shell system . . tput. sgr0 )"
23
24 _playokscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _playok().() {
25 if [scip-shell system . . `[`. -f /System/Library/Sounds/Glass.aiffscip-shell filesystem . . `/System/Library/Sounds/Glass.aiff`. ]; then
26 afplay /System/Library/Sounds/Glass.aiffscip-shell filesystem . . `/System/Library/Sounds/Glass.aiff`. >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
27 fi
28 }
29
30 _playhmscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _playhm().() {
31 if [scip-shell system . . `[`. -f /System/Library/Sounds/Basso.aiffscip-shell filesystem . . `/System/Library/Sounds/Basso.aiff`. ]; then
32 afplay /System/Library/Sounds/Basso.aiffscip-shell filesystem . . `/System/Library/Sounds/Basso.aiff`. >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
33 fi
34 }
35
36 _playerrorscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _playerror().() {
37 if [scip-shell system . . `[`. -f /System/Library/Sounds/Sosumi.aiffscip-shell filesystem . . `/System/Library/Sounds/Sosumi.aiff`. ]; then
38 afplay /System/Library/Sounds/Sosumi.aiffscip-shell filesystem . . `/System/Library/Sounds/Sosumi.aiff`. >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
39 fi
40 }
41
42 _gettimescip-shell shell texlive-bin 2026.20260303.78225+ds-4 _gettime().() {
43 if command -v gdate &> /dev/nullscip-shell filesystem . . `/dev/null`.; then
44 echoscip-shell system . . echo. $( gdate +%s%3N )
45 else
46 if command -v date &> /dev/nullscip-shell filesystem . . `/dev/null`.; then
47 milliseconds=$( datescip-shell system . . date. +%3N )
48 if [scip-shell system . . `[`. $milliseconds = 3N ]; then
49 echoscip-shell system . . echo. $(( SECONDS * 1000 ))
50 else
51 echoscip-shell system . . echo. $( datescip-shell system . . date. +%s%3N )
52 fi
53 else
54 echoscip-shell system . . echo. $(( SECONDS * 1000 ))
55 fi
56 fi
57 }
58
59 _starttimerscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _starttimer().() {
60 starttime=$( _gettimescip-shell shell texlive-bin 2026.20260303.78225+ds-4 _gettime(). )
61 }
62
63 _stoptimerscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _stoptimer().() {
64 endtime=$( _gettimescip-shell shell texlive-bin 2026.20260303.78225+ds-4 _gettime(). )
65
66 elapsedtime=$(( endtime - starttime ))
67 elapsedseconds=$(( elapsedtime / 1000 ))
68 elapsedmilliseconds=$(( elapsedtime % 1000 ))
69 elapsed=$elapsedseconds.$( printfscip-shell system . . printf. "%03d" "$elapsedmilliseconds" )
70 }
71
72 testscip-shell shell texlive-bin 2026.20260303.78225+ds-4 test().() {
73 _starttimerscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _starttimer().
74 tmpdir=$( mktempscip-shell system . . mktemp. -d 2>/dev/nullscip-shell filesystem . . `/dev/null`. )/textest$( datescip-shell system . . date. "+%Y%m%d%H%M%S" )$RANDOM
75 mkdirscip-shell system . . mkdir. $tmpdir
76
77 if [scip-shell system . . `[`. $3 = true ] && [scip-shell system . . `[`. -d cache ]; then
78 rmscip-shell system . . rm. -rf cache
79 fi
80
81 okcount=0
82 failedcount=0
83 newcount=0
84 removedcount=0
85 fileokcount=0
86 filefailedcount=0
87 defaultfiller=23
88
89 echoscip-shell system . . echo. ""
90 for entry in *$5*.tex
91 do
92 if [scip-shell system . . `[`. $entry != "*$5*.tex" ]; then
93 name=$( echoscip-shell system . . echo. $entry | sedscip-shell system . . sed. -e 's/\.tex$//g' )
94 if [scip-shell system . . `[`. ${name:0:1} != _ ]; then
95 printfscip-shell system . . printf. "$( tputscip-shell system . . tput. sgr0 )$name"
96
97 runtwice=0
98 if [scip-shell system . . `[`. "${name:$(( ${#name} - 2 )):2}" = "@2" ]; then
99 runtwice=1
100 fi
101
102 if [scip-shell system . . `[`. "$4" != "xelatex" ]; then
103 name="$name.$4"
104 fi
105
106 passed=1
107 rmscip-shell system . . rm. -f $name.failed.*
108
109 cpscip-shell system . . cp. $entry $tmpdir/$name.tex
110 shell=""
111 if [scip-shell system . . `[`. $1 = true ]; then
112 shell="--shell-escape"
113 fi
114 $4 -interaction=batchmode $shell --output-directory $tmpdir $tmpdir/$name.tex > /dev/nullscip-shell filesystem . . `/dev/null`.
115 if [scip-shell system . . `[`. $? -eq 1 ]; then
116 passed=0
117 fi
118 if [scip-shell system . . `[`. $runtwice -eq 1 ]; then
119 $4 -interaction=batchmode $shell --output-directory $tmpdir $tmpdir/$name.tex > /dev/nullscip-shell filesystem . . `/dev/null`.
120 if [scip-shell system . . `[`. $? -eq 1 ]; then
121 passed=0
122 fi
123 fi
124
125 magick -density $2 -quiet $tmpdir/$name.pdf $tmpdir/$name.png
126 if [scip-shell system . . `[`. -f "$tmpdir/$name.png" ]; then
127 mvscip-shell system . . mv. $tmpdir/$name.png $tmpdir/$name-0.png
128 fi
129
130 if [scip-shell system . . `[`. -f "$name.approved.pdf" ]; then
131 magick -density $2 -quiet $name.approved.pdf $tmpdir/$name.approved.png
132 if [scip-shell system . . `[`. -f "$tmpdir/$name.approved.png" ]; then
133 mvscip-shell system . . mv. $tmpdir/$name.approved.png $tmpdir/$name.approved-0.png
134 fi
135 fi
136
137 if [scip-shell system . . `[`. $passed -eq 0 ]; then
138 filler=$(( defaultfiller - ${#name} - 2 ))
139 else
140 filler=$(( defaultfiller - ${#name} ))
141 fi
142 while [scip-shell system . . `[`. 0 -le $filler ]; do
143 printfscip-shell system . . printf. " "
144 filler=$(( filler - 1 ))
145 done
146 if [scip-shell system . . `[`. $passed -eq 0 ]; then
147 printfscip-shell system . . printf. " $ERROR"
148 fi
149
150 index=0
151 while [scip-shell system . . `[`. -f "$tmpdir/$name-$index.png" ]; do
152 if [scip-shell system . . `[`. -f "$tmpdir/$name.approved-$index.png" ]; then
153 changedpixels=$( magick compare -quiet -metric AE $tmpdir/$name-$index.png $tmpdir/$name.approved-$index.png null: 2>&1 )
154 if [scip-shell system . . `[`. $changedpixels -eq 0 ]; then
155 okcount=$(( okcount + 1 ))
156 printfscip-shell system . . printf. " $OK"
157 else
158 failedcount=$(( failedcount + 1 ))
159 passed=0
160 printfscip-shell system . . printf. " $FAILED"
161 magick compare -quiet $tmpdir/$name-$index.png $tmpdir/$name.approved-$index.png $name.failed.$(( index + 1 )).png
162 if [scip-shell system . . `[`. -f "$tmpdir/$name.pdf" ]; then
163 mvscip-shell system . . mv. $tmpdir/$name.pdf $name.failed.pdf
164 fi
165 fi
166 else
167 newcount=$(( newcount + 1 ))
168 passed=0
169 printfscip-shell system . . printf. " $NEW"
170 mvscip-shell system . . mv. $tmpdir/$name-$index.png $name.failed.$(( index + 1 )).png
171 if [scip-shell system . . `[`. -f "$tmpdir/$name.pdf" ]; then
172 mvscip-shell system . . mv. $tmpdir/$name.pdf $name.failed.pdf
173 fi
174 fi
175 index=$(( index + 1 ))
176 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $index % 20` -eq 0 ] && [scip-shell system . . `[`. -f "$tmpdir/$name-$index.png" ]; then
177 echoscip-shell system . . echo. ""
178 filler=$defaultfiller
179 while [scip-shell system . . `[`. 0 -le $filler ]; do
180 printfscip-shell system . . printf. " "
181 filler=$(( filler - 1 ))
182 done
183 fi
184 done
185 while [scip-shell system . . `[`. -f "$tmpdir/$name.approved-$index.png" ]; do
186 removedcount=$(( removedcount + 1 ))
187 passed=0
188 printfscip-shell system . . printf. " $REMOVED"
189 mvscip-shell system . . mv. $tmpdir/$name.approved-$index.png $name.failed.$(( index + 1 )).png
190 if [scip-shell system . . `[`. -f "$tmpdir/$name.pdf" ]; then
191 mvscip-shell system . . mv. $tmpdir/$name.pdf $name.failed.pdf
192 fi
193 index=$(( index + 1 ))
194 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $index % 20` -eq 0 ] && [scip-shell system . . `[`. -f "$tmpdir/$name.approved-$index.png" ]; then
195 echoscip-shell system . . echo. ""
196 filler=$defaultfiller
197 while [scip-shell system . . `[`. 0 -le $filler ]; do
198 printfscip-shell system . . printf. " "
199 filler=$(( filler - 1 ))
200 done
201 fi
202 done
203
204 if [scip-shell system . . `[`. $passed -eq 1 ]; then
205 fileokcount=$(( fileokcount + 1 ))
206 else
207 filefailedcount=$(( filefailedcount + 1 ))
208 fi
209
210 echoscip-shell system . . echo. ""
211 fi
212 fi
213 done
214
215 rmscip-shell system . . rm. -rf $tmpdir
216 _stoptimerscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _stoptimer().
217 seconds=$( printfscip-shell system . . printf. "%.1f" "$elapsed" )
218
219 filecount=$(( fileokcount + filefailedcount ))
220
221 if [scip-shell system . . `[`. $filecount -gt 0 ]; then
222 echoscip-shell system . . echo. ""
223 fi
224 if [scip-shell system . . `[`. $filecount -eq $fileokcount ]; then
225 if [scip-shell system . . `[`. $filecount -eq 0 ]; then
226 _playhmscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _playhm(). &
227 echoscip-shell system . . echo. "$( tputscip-shell system . . tput. sgr0 )Tested 0 files 🧐."
228 else
229 _playokscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _playok(). &
230 echoscip-shell system . . echo. "$( tputscip-shell system . . tput. sgr0 )Successfully tested $filecount files in $seconds seconds 🎉."
231 fi
232 echoscip-shell system . . echo. ""
233 else
234 _playerrorscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _playerror(). &
235 echoscip-shell system . . echo. "$( tputscip-shell system . . tput. sgr0 )Tested $filecount files in $seconds seconds."
236 echoscip-shell system . . echo. ""
237
238 if [scip-shell system . . `[`. $fileokcount -gt 0 ]; then
239 filler=$(( 6 + ${#filecount} - ${#fileokcount} ))
240 while [scip-shell system . . `[`. 0 -le $filler ]; do
241 printfscip-shell system . . printf. " "
242 filler=$(( filler - 1 ))
243 done
244 printfscip-shell system . . printf. "$( tputscip-shell system . . tput. setaf 2 )$fileokcount OK$( tputscip-shell system . . tput. sgr0 )"
245 echoscip-shell system . . echo. ""
246 fi
247 if [scip-shell system . . `[`. $filefailedcount -gt 0 ]; then
248 filler=$(( 6 + ${#filecount} - ${#filefailedcount} ))
249 while [scip-shell system . . `[`. 0 -le $filler ]; do
250 printfscip-shell system . . printf. " "
251 filler=$(( filler - 1 ))
252 done
253 printfscip-shell system . . printf. "$( tputscip-shell system . . tput. setaf 1 )$filefailedcount Failed$( tputscip-shell system . . tput. sgr0 )"
254 echoscip-shell system . . echo. ""
255 fi
256 echoscip-shell system . . echo. ""
257 exit 1
258 fi
259 }
260
261 approvescip-shell shell texlive-bin 2026.20260303.78225+ds-4 approve().() {
262 filecount=0
263
264 suffix=""
265 if [scip-shell system . . `[`. "$1" != "xelatex" ]; then
266 suffix=".$1"
267 fi
268
269 echoscip-shell system . . echo. ""
270 for entry in *$2*$suffix.failed.pdf
271 do
272 if [scip-shell system . . `[`. $entry != "*$2*$suffix.failed.pdf" ]; then
273 filecount=$(( filecount + 1 ))
274 name=$( echoscip-shell system . . echo. $entry | sedscip-shell system . . sed. -e "s/$suffix.failed.pdf//" )
275 echoscip-shell system . . echo. $name
276 rmscip-shell system . . rm. -f $name$suffix.approved.pdf
277 if [scip-shell system . . `[`. -f "$name.aux" ]; then
278 cpscip-shell system . . cp. $name$suffix.failed.pdf $name$suffix.approved.pdf
279 else
280 mvscip-shell system . . mv. $name$suffix.failed.pdf $name$suffix.approved.pdf
281 fi
282
283 rmscip-shell system . . rm. -f $name$suffix.failed.*
284 fi
285 done
286
287 if [scip-shell system . . `[`. $filecount -gt 0 ]; then
288 echoscip-shell system . . echo. ""
289 fi
290 if [scip-shell system . . `[`. $filecount -eq 1 ]; then
291 echoscip-shell system . . echo. "Approved 1 file."
292 else
293 echoscip-shell system . . echo. "Approved $filecount files."
294 fi
295 echoscip-shell system . . echo. ""
296 }
297
298 comparescip-shell shell texlive-bin 2026.20260303.78225+ds-4 compare().() {
299 filea=$2
300 fileb=$3
301 tmpdir=$( mktempscip-shell system . . mktemp. -d 2>/dev/nullscip-shell filesystem . . `/dev/null`.)/textest$( datescip-shell system . . date. "+%Y%m%d%H%M%S" )$RANDOM
302 mkdirscip-shell system . . mkdir. $tmpdir
303
304 namea=$( echoscip-shell system . . echo. $filea | sedscip-shell system . . sed. -e 's/\.\///g' | sedscip-shell system . . sed. -e 's/\.pdf$//g' )
305 nameb=$( echoscip-shell system . . echo. $fileb | sedscip-shell system . . sed. -e 's/\.\///g' | sedscip-shell system . . sed. -e 's/\.pdf$//g' )
306 basenamea=$(basenamescip-shell system . . basename. $namea)
307 basenameb=$(basenamescip-shell system . . basename. $nameb)
308
309 rmscip-shell system . . rm. -f $namea.diff.*.png
310
311 spacer=""
312 if [scip-shell system . . `[`. -f "$filea" ]; then
313 if [scip-shell system . . `[`. -f "$fileb" ]; then
314 magick -density $1 -quiet $filea $tmpdir/$basenamea.png
315 if [scip-shell system . . `[`. -f "$tmpdir/$basenamea.png" ]; then
316 mvscip-shell system . . mv. $tmpdir/$basenamea.png $tmpdir/$basenamea-0.png
317 fi
318 magick -density $1 -quiet $fileb $tmpdir/$basenameb.png
319 if [scip-shell system . . `[`. -f "$tmpdir/$basenameb.png" ]; then
320 mvscip-shell system . . mv. $tmpdir/$basenameb.png $tmpdir/$basenameb-0.png
321 fi
322
323 index=0
324 while [scip-shell system . . `[`. -f "$tmpdir/$basenamea-$index.png" ]; do
325 if [scip-shell system . . `[`. -f "$tmpdir/$basenameb-$index.png" ]; then
326 changedpixels=$( magick compare -quiet -metric AE $tmpdir/$basenamea-$index.png $tmpdir/$basenameb-$index.png null: 2>&1 )
327 if [scip-shell system . . `[`. $changedpixels -eq 0 ]; then
328 printfscip-shell system . . printf. "$spacer$OK"
329 spacer=" "
330 else
331 printfscip-shell system . . printf. "$spacer$FAILED"
332 spacer=" "
333 magick compare -quiet $tmpdir/$basenamea-$index.png $tmpdir/$basenameb-$index.png $namea.diff.$(( index + 1 )).png
334 fi
335 else
336 printfscip-shell system . . printf. "$spacer$NEW"
337 spacer=" "
338 fi
339 index=$(( index + 1 ))
340 done
341 while [scip-shell system . . `[`. -f "$tmpdir/$basenameb-$index.png" ]; do
342 printfscip-shell system . . printf. "$spacer$REMOVED"
343 spacer=" "
344 index=$(( index + 1 ))
345 done
346 echoscip-shell system . . echo. ""
347 else
348 echoscip-shell system . . echo. "File $fileb not found."
349 fi
350 else
351 echoscip-shell system . . echo. "File $filea not found."
352 fi
353
354 rmscip-shell system . . rm. -rf $tmpdir
355 }
356
357 perfscip-shell shell texlive-bin 2026.20260303.78225+ds-4 perf().() {
358 if [scip-shell system . . `[`. -f $4 ]; then
359 tmpdir=$( mktempscip-shell system . . mktemp. -d 2>/dev/nullscip-shell filesystem . . `/dev/null`. )/textestperf$( datescip-shell system . . date. "+%Y%m%d%H%M%S" )$RANDOM
360 mkdirscip-shell system . . mkdir. $tmpdir
361 basename=$(basenamescip-shell system . . basename. $4)
362
363 if [scip-shell system . . `[`. $1 = true ] && [scip-shell system . . `[`. -d cache ]; then
364 rmscip-shell system . . rm. -rf cache
365 fi
366
367 cpscip-shell system . . cp. $4 $tmpdir
368 shell=""
369 if [scip-shell system . . `[`. $2 = true ]; then
370 shell="--shell-escape"
371 fi
372 _starttimerscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _starttimer().
373 $3 -interaction=batchmode $shell --output-directory $tmpdir $tmpdir/$basename > /dev/nullscip-shell filesystem . . `/dev/null`.
374 _stoptimerscip-shell shell texlive-bin 2026.20260303.78225+ds-4 _stoptimer().
375 echoscip-shell system . . echo. "$elapsed"
376
377 rmscip-shell system . . rm. -rf $tmpdir
378 else
379 echoscip-shell system . . echo. "File $4 not found."
380 fi
381 }
382
383 usagescip-shell shell texlive-bin 2026.20260303.78225+ds-4 usage().() {
384 catscip-shell system . . cat. <<HELP_USAGE
385 usage: textest [-cs] [-e ENGINE] [-d DENSITY] [PATTERN]
386 textest approve [-e ENGINE] [PATTERN]
387 textest compare [-d DENSITY] FILE FILE
388 textest perf [-cs] [-e ENGINE] FILE
389
390 -c Clears cache.
391 -s Enables shell escape.
392 -d DENSITY Sets density in ppi (default 72).
393 -e ENGINE Sets latex engine (default xelatex).
394 --help Prints a help message.
395 --version Prints version information.
396 HELP_USAGE
397 }
398
399 versionscip-shell shell texlive-bin 2026.20260303.78225+ds-4 version().() {
400 echoscip-shell system . . echo. textest $version
401 }
402
403 case "$1" in
404 approve)
405 shift
406 engine=xelatex
407
408 while getopts ":e:" arg; do
409 case "${arg}" in
410 e)
411 engine="${OPTARG}"
412 ;;
413 ?)
414 echoscip-shell system . . echo. "Invalid option: -${OPTARG}."
415 ;;
416 esac
417 done
418
419 shift "$(( OPTIND - 1 ))"
420
421 approvescip-shell shell texlive-bin 2026.20260303.78225+ds-4 approve(). $engine $1
422 ;;
423 compare)
424 shift
425
426 density=72
427
428 while getopts ":d:" arg; do
429 case "${arg}" in
430 d)
431 density="${OPTARG}"
432 ;;
433 ?)
434 echoscip-shell system . . echo. "Invalid option: -${OPTARG}."
435 ;;
436 esac
437 done
438
439 shift "$(( OPTIND - 1 ))"
440
441 comparescip-shell shell texlive-bin 2026.20260303.78225+ds-4 compare(). $density $1 $2
442 ;;
443 perf)
444 shift
445
446 shell=false
447 clear=false
448 engine=xelatex
449
450 while getopts ":e:sc" arg; do
451 case "${arg}" in
452 c)
453 clear=true
454 ;;
455 e)
456 engine="${OPTARG}"
457 ;;
458 s)
459 shell=true
460 ;;
461 ?)
462 echoscip-shell system . . echo. "Invalid option: -${OPTARG}."
463 ;;
464 esac
465 done
466
467 shift "$(( OPTIND - 1 ))"
468
469 perfscip-shell shell texlive-bin 2026.20260303.78225+ds-4 perf(). $clear $shell $engine $1
470 ;;
471 --version)
472 versionscip-shell shell texlive-bin 2026.20260303.78225+ds-4 version().
473 ;;
474 --help)
475 usagescip-shell shell texlive-bin 2026.20260303.78225+ds-4 usage().
476 ;;
477 *)
478 density=72
479 shell=false
480 clear=false
481 engine=xelatex
482
483 while getopts ":e:d:sc" arg; do
484 case "${arg}" in
485 c)
486 clear=true
487 ;;
488 d)
489 density="${OPTARG}"
490 ;;
491 e)
492 engine="${OPTARG}"
493 ;;
494 s)
495 shell=true
496 ;;
497 ?)
498 echoscip-shell system . . echo. "Invalid option: -${OPTARG}."
499 ;;
500 esac
501 done
502
503 shift "$(( OPTIND - 1 ))"
504
505 testscip-shell shell texlive-bin 2026.20260303.78225+ds-4 test(). $shell $density $clear $engine $1
506 esac