@@ -76,7 +76,7 @@ MAKE="$(type -P make 2>/dev/null)"
76
76
export TXZCHK=" ./txzchk"
77
77
export FNAMCHK=" ./test_ioccc/fnamchk"
78
78
79
- export MKIOCCCENTRY_TEST_VERSION=" 1.0.13 2025-02-21 "
79
+ export MKIOCCCENTRY_TEST_VERSION=" 1.0.14 2025-02-25 "
80
80
export USAGE=" usage: $0 [-h] [-V] [-v level] [-J level] [-t tar] [-T txzchk] [-l ls] [-F fnamchk] [-m make] [-Z topdir]
81
81
82
82
-h print help and exit
199
199
#
200
200
Makefile=" test_ioccc/Makefile.test"
201
201
workdir=" test_ioccc/workdir"
202
- src_dir =" test_ioccc/topdir"
203
- src_src_dir =" test_ioccc/topdir/topdir"
204
- src_src_src_src_src_dir =" test_ioccc/topdir/a/b/c/d/e"
202
+ topdir =" test_ioccc/topdir"
203
+ topdir_topdir =" test_ioccc/topdir/topdir"
204
+ topdir_topdir_topdir_topdir_topdir =" test_ioccc/topdir/a/b/c/d/e"
205
205
206
206
# clean out test directories first
207
- rm -rf -- " ${workdir} " " ${src_dir } " " ${src_src_dir } " " ${src_src_src_src_src_dir } "
207
+ rm -rf -- " ${workdir} " " ${topdir } " " ${topdir_topdir } " " ${topdir_topdir_topdir_topdir_topdir } "
208
208
# be sure the working locations exist
209
209
#
210
- mkdir -p -- " ${workdir} " " ${src_dir} " " ${src_src_dir }"
210
+ mkdir -p -- " ${workdir} " " ${topdir } "
211
211
status=$?
212
212
if [[ ${status} -ne 0 ]]; then
213
- echo " $0 : ERROR: error in creating working dirs: mkdir -p -- ${workdir} ${src_dir} ${src_src_dir} ${src_src_src_src_src_dir }" 1>&2
213
+ echo " $0 : ERROR: error in creating working dirs: mkdir -p -- ${workdir} ${topdir } " 1>&2
214
214
exit 9
215
215
fi
216
216
@@ -222,8 +222,8 @@ if [[ ! -d ${workdir} ]]; then
222
222
exit 9
223
223
fi
224
224
# we also need the source directory
225
- if [[ ! -d ${src_dir } ]]; then
226
- echo " $0 : ERROR: src_dir not found: ${src_dir } " 1>&2
225
+ if [[ ! -d ${topdir } ]]; then
226
+ echo " $0 : ERROR: topdir not found: ${topdir } " 1>&2
227
227
exit 9
228
228
fi
229
229
@@ -264,10 +264,11 @@ LONG_FILENAME="fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
264
264
workdir_esc=" ${workdir} "
265
265
test " ${workdir: 0: 1} " = " -" && workdir_esc=./" ${workdir} "
266
266
find " ${workdir_esc} " -mindepth 1 -depth -delete
267
- rm -f " ${src_dir } " /" ${LONG_FILENAME} "
267
+ rm -f " ${topdir } " /
268
268
269
269
# Answers as of mkiocccentry version: v0.40 2022-03-15
270
- answers () {
270
+ answers ()
271
+ {
271
272
cat << "EOF "
272
273
test
273
274
0
@@ -339,23 +340,114 @@ grep -E '^#define MKIOCCCENTRY_ANSWERS_VERSION' soup/version.h | cut -d' ' -f3 |
339
340
# shellcheck disable=SC2218
340
341
answers >> answers.txt
341
342
342
- # fake some required, extra and optional files
343
+ # fake a submission that only has the required files
343
344
#
344
- test -f " ${src_dir} " /Makefile || cat " ${Makefile} " > " ${src_dir} " /Makefile
345
- test -f " ${src_dir} " /remarks.md || cat README.md > " ${src_dir} " /remarks.md
346
- test -f " ${src_dir} " /extra1 || echo " 123" > " ${src_dir} " /extra1
347
- test -f " ${src_dir} " /extra2 || echo " 456" > " ${src_dir} " /extra2
348
- test -f " ${src_dir} " /try.sh || touch " ${src_dir} " /try.sh
349
- test -f " ${src_dir} " /try.alt.sh || touch " ${src_dir} " /try.alt.sh
350
- test -f " ${src_dir} " /prog.alt.c || touch " ${src_dir} " /prog.alt.c
351
-
345
+ test -f " ${topdir} " /Makefile || cat " ${Makefile} " > " ${topdir} " /Makefile
346
+ test -f " ${topdir} " /remarks.md || cat README.md > " ${topdir} " /remarks.md
347
+ test -f " ${topdir} " /prog.c || echo " int main(){}" > " ${topdir} " /prog.c
352
348
# delete the work directory for next test
353
349
find " ${workdir_esc} " -mindepth 1 -depth -delete
354
- rm -f " ${src_dir} " /prog.c
355
- :> " ${src_dir} " /prog.c
356
350
# test empty prog.c, ignoring the warning about it
357
- echo " ./mkiocccentry -y -q -W -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${src_dir} "
358
- ./mkiocccentry -y -q -W -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${src_dir} "
351
+ echo " ./mkiocccentry -y -q -W -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${topdir} "
352
+ ./mkiocccentry -y -q -W -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${topdir} "
353
+ status=$?
354
+ if [[ ${status} -ne 0 ]]; then
355
+ echo " $0 : ERROR: mkiocccentry non-zero exit code: $status " 1>&2
356
+ exit " ${status} "
357
+ fi
358
+
359
+ echo " --"
360
+
361
+ # Answers as of mkiocccentry version: v0.40 2022-03-15
362
+ answers ()
363
+ {
364
+ cat << "EOF "
365
+ test
366
+ 1
367
+ title-for-entry0
368
+ abstract for entry #0
369
+ 5
370
+ author0 middle0 thisisaveryverylonglastname0
371
+ AU
372
+
373
+ https://a.host0.example.com/index.html
374
+ https://b.host0.example.com/index.html
375
+
376
+ @github0
377
+ an affiliation for #0 author
378
+
379
+ author1 middle1a middle1b last1
380
+ UK
381
+
382
+
383
+
384
+
385
+
386
+
387
+ replaced_author1_handle
388
+ EOF
389
+ # Avoid triggering an out of date shellcheck bug by using encoded hex characters
390
+ printf " Author2 \\ xc3\\ xa5\\ xe2\\ x88\\ xab\\ xc3\\ xa7\\ xe2\\ x88\\ x82\\ xc2\\ xb4\\ xc6\\ x92\\ xc2\\ xa9 LAST2\\ n"
391
+ cat << "EOF "
392
+ US
393
+
394
+ http://c.host2.example.com/index.html
395
+ http://d.host2.example.com/index.html
396
+
397
+ @github2
398
+ an affiliation for #2 author
399
+
400
+ author3 middle3 last3
401
+ AU
402
+
403
+ https://e.host0.example.com/index.html
404
+ https://f.host0.example.com/index.html
405
+
406
+ @github3
407
+ an affiliation for #3 author
408
+ author3_last3
409
+ @#$%^
410
+ AU
411
+
412
+ https://g.host0.example.com/index.html
413
+
414
+
415
+ @github4
416
+ an affiliation for #4 author
417
+
418
+ ANSWERS_EOF
419
+ EOF
420
+ }
421
+ rm -f answers.txt
422
+ # Retrieve the answers version from mkiocccentry.c and write to answers file:
423
+ grep -E ' ^#define MKIOCCCENTRY_ANSWERS_VERSION' soup/version.h | cut -d' ' -f3 | sed ' s/"//g' > answers.txt
424
+ # Append answers + EOF marker
425
+ #
426
+ # We disable this shellcheck error because answers already is defined but we
427
+ # redefine it as well. The error is ironically erroneous as if one is to move up
428
+ # in the file they'll see that answers is actually defined above as well.
429
+ #
430
+ # SC2218 (error): This function is only defined later. Move the definition up.
431
+ # https://www.shellcheck.net/wiki/SC2218
432
+ # shellcheck disable=SC2218
433
+ answers >> answers.txt
434
+
435
+ # fake some required, extra and optional files
436
+ #
437
+ mkdir -p " ${topdir_topdir} "
438
+ test -f " ${topdir} " /Makefile || cat " ${Makefile} " > " ${topdir} " /Makefile
439
+ test -f " ${topdir} " /remarks.md || cat README.md > " ${topdir} " /remarks.md
440
+ test -f " ${topdir} " /extra1 || echo " 123" > " ${topdir} " /extra1
441
+ test -f " ${topdir} " /extra2 || echo " 456" > " ${topdir} " /extra2
442
+ test -f " ${topdir} " /try.sh || touch " ${topdir} " /try.sh
443
+ test -f " ${topdir} " /try.alt.sh || touch " ${topdir} " /try.alt.sh
444
+ test -f " ${topdir} " /prog.alt.c || touch " ${topdir} " /prog.alt.c
445
+
446
+ rm -f " ${topdir} " /prog.c
447
+ :> " ${topdir} " /prog.c
448
+ # test empty prog.c, ignoring the warning about it
449
+ echo " ./mkiocccentry -y -q -W -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${topdir} "
450
+ ./mkiocccentry -y -q -W -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${topdir} "
359
451
status=$?
360
452
if [[ ${status} -ne 0 ]]; then
361
453
echo " $0 : ERROR: mkiocccentry non-zero exit code: $status " 1>&2
@@ -366,18 +458,19 @@ echo "--"
366
458
367
459
# Form 'submissions' that are unlikely to win the IOCCC :-)
368
460
#
369
- test -f " ${src_dir } " /prog.c || {
370
- cat > " ${src_dir } " /prog.c << "EOF "
461
+ test -f " ${topdir } " /prog.c || {
462
+ cat > " ${topdir } " /prog.c << "EOF "
371
463
#include <stdio.h>
372
464
int main(void) { puts("Hello, World!"); }
373
465
EOF
374
466
}
375
467
376
468
# Answers as of mkiocccentry version: v0.40 2022-03-15
377
- answers () {
469
+ answers ()
470
+ {
378
471
cat << "EOF "
379
472
test
380
- 1
473
+ 2
381
474
title-for-entry0
382
475
abstract for entry #0
383
476
5
@@ -447,8 +540,8 @@ answers >>answers.txt
447
540
448
541
# run the test, looking for an exit
449
542
#
450
- echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${src_dir } "
451
- ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${src_dir } "
543
+ echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${topdir } "
544
+ ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${topdir } "
452
545
status=$?
453
546
if [[ ${status} -ne 0 ]]; then
454
547
echo " $0 : ERROR: mkiocccentry non-zero exit code: $status " 1>&2
458
551
echo " --"
459
552
460
553
# Answers as of mkiocccentry version: v0.40 2022-03-15
461
- answers () {
554
+ answers ()
555
+ {
462
556
cat << "EOF "
463
557
12345678-1234-4321-abcd-1234567890ab
464
- 2
558
+ 3
465
559
title-for-entry0
466
560
abstract for entry #0
467
561
5
@@ -531,13 +625,13 @@ answers >>answers.txt
531
625
532
626
# fake a couple more files
533
627
#
534
- test -f " ${src_dir } " /foo || cat LICENSE > " ${src_dir } " /foo
535
- test -f " ${src_dir } " /bar || cat CODE_OF_CONDUCT.md > " ${src_dir } " /bar
628
+ test -f " ${topdir } " /foo || cat LICENSE > " ${topdir } " /foo
629
+ test -f " ${topdir } " /bar || cat CODE_OF_CONDUCT.md > " ${topdir } " /bar
536
630
537
631
# run the test, looking for an exit
538
632
#
539
- echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${src_dir } "
540
- ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${src_dir } "
633
+ echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${topdir } "
634
+ ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${topdir } "
541
635
status=$?
542
636
if [[ ${status} -ne 0 ]]; then
543
637
echo " $0 : ERROR: mkiocccentry non-zero exit code: $status " 1>&2
547
641
echo " --"
548
642
549
643
# Answers as of mkiocccentry version: v0.40 2022-03-15
550
- answers () {
644
+ answers ()
645
+ {
551
646
cat << "EOF "
552
647
test
553
- 2
648
+ 4
554
649
title-for-entry0
555
650
abstract for entry #0
556
651
5
@@ -619,19 +714,18 @@ grep -E '^#define MKIOCCCENTRY_ANSWERS_VERSION' soup/version.h | cut -d' ' -f3 |
619
714
# shellcheck disable=SC2218
620
715
answers >> answers.txt
621
716
622
-
623
717
#
624
718
# this next test must FAIL as it has a filename that is too long
625
719
#
626
720
627
721
# fake a filename that's too long
628
722
#
629
- test -f " ${src_dir } /$LONG_FILENAME " || touch " ${src_dir } /$LONG_FILENAME "
723
+ test -f " ${topdir } /$LONG_FILENAME " || touch " ${topdir } /$LONG_FILENAME "
630
724
631
725
# run the test, looking for an exit
632
726
#
633
- echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${src_dir } "
634
- ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${src_dir } "
727
+ echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${topdir } "
728
+ ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${topdir } "
635
729
status=$?
636
730
if [[ ${status} -ne 4 ]]; then
637
731
echo " $0 : ERROR: mkiocccentry exit code not 4: $status " 1>&2
644
738
echo " --"
645
739
646
740
# Answers as of mkiocccentry version: v0.40 2022-03-15
647
- answers () {
741
+ answers ()
742
+ {
648
743
cat << "EOF "
649
744
test
650
- 3
745
+ 5
651
746
title-for-entry0
652
747
abstract for entry #0
653
748
5
@@ -717,15 +812,15 @@ grep -E '^#define MKIOCCCENTRY_ANSWERS_VERSION' soup/version.h | cut -d' ' -f3 |
717
812
answers >> answers.txt
718
813
719
814
# remove long filename
720
- rm -f " ${src_dir } " /" ${LONG_FILENAME} "
815
+ rm -f " ${topdir } " /" ${LONG_FILENAME} "
721
816
# make a file in the subdirectory
722
817
#
723
- test -f " ${src_src_dir } /foo" || touch " ${src_src_dir } /foo"
818
+ test -f " ${topdir_topdir } /foo" || touch " ${topdir_topdir } /foo"
724
819
725
820
# run the test, looking for an exit
726
821
#
727
- echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${src_dir } "
728
- ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${src_dir } "
822
+ echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${topdir } "
823
+ ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${topdir } "
729
824
status=$?
730
825
if [[ ${status} -ne 0 ]]; then
731
826
echo " $0 : ERROR: mkiocccentry non-zero exit code: $status " 1>&2
735
830
echo " --"
736
831
737
832
# Answers as of mkiocccentry version: v0.40 2022-03-15
738
- answers () {
833
+ answers ()
834
+ {
739
835
cat << "EOF "
740
836
test
741
- 4
837
+ 6
742
838
title-for-entry0
743
839
abstract for entry #0
744
840
5
@@ -809,19 +905,19 @@ answers >>answers.txt
809
905
810
906
# be sure the working location exist
811
907
#
812
- mkdir -p -- " ${src_src_src_src_src_dir } "
908
+ mkdir -p -- " ${topdir_topdir_topdir_topdir_topdir } "
813
909
status=$?
814
910
if [[ ${status} -ne 0 ]]; then
815
- echo " $0 : ERROR: error in creating working dirs: mkdir -p -- ${src_src_src_src_src_dir } " 1>&2
911
+ echo " $0 : ERROR: error in creating working dirs: mkdir -p -- ${topdir_topdir_topdir_topdir_topdir } " 1>&2
816
912
exit 9
817
913
fi
818
914
819
- test -f " ${src_src_src_src_src_dir } /foo" || touch " ${src_src_src_src_src_dir } /foo"
915
+ test -f " ${topdir_topdir_topdir_topdir_topdir } /foo" || touch " ${topdir_topdir_topdir_topdir_topdir } /foo"
820
916
821
917
# run the test, looking for an exit
822
918
#
823
- echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${src_dir } "
824
- ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${src_dir } "
919
+ echo " ./mkiocccentry -y -q -i answers.txt -m $MAKE -F $FNAMCHK -t $TAR -T $TXZCHK -e -l $LS -v $V_FLAG -J $J_FLAG -- ${workdir} ${topdir } "
920
+ ./mkiocccentry -y -q -i answers.txt -m " $MAKE " -F " $FNAMCHK " -t " $TAR " -T " $TXZCHK " -e -l " $LS " -v " $V_FLAG " -J " $J_FLAG " -- " ${workdir} " " ${topdir } "
825
921
status=$?
826
922
if [[ ${status} -ne 4 ]]; then
827
923
echo " $0 : ERROR: mkiocccentry zero exit code not 4: $status " 1>&2
0 commit comments