run_compile_tests.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Build and run the direct compiler harness (tests/CompileTest.mod).
  3. #
  4. # Same two-phase ISO link recipe as tpshell: a single monolithic invocation
  5. # trips gm2's pass-3 rollup on a compiler-size program, so generate the module
  6. # list first (-fgen-module-list -> /dev/null, rc=1 is expected) and then link
  7. # with -fuse-list.
  8. set -u
  9. D=/home/eric/Projets/Projets-Modula2/MyWork/TP3-comp/shell
  10. GM2=/home/eric/bin/Modula2/Gm2/bin/gm2
  11. cd "$D" || exit 9
  12. FLAGS="-fiso"
  13. if [ ! -f TextBuf.o ] || [ ! -f Compiler.o ] || [ ! -f Posix.o ] \
  14. || [ TextBuf.mod -nt TextBuf.o ] || [ Compiler.mod -nt Compiler.o ] \
  15. || [ Posix.c -nt Posix.o ] || [ Posix.def -nt Posix.o ]; then
  16. echo "building support modules (source newer than object)..."
  17. # NB: Posix is a FOR "C" module (Posix.c + Posix.def, no Posix.mod), so it
  18. # is not rebuilt here - only TextBuf and Compiler have a .mod to compile.
  19. for m in TextBuf Compiler; do
  20. $GM2 $FLAGS -c $m.mod >/tmp/ct_c_$m 2>&1
  21. if [ $? -ne 0 ]; then
  22. echo "COMPILE_FAIL $m"
  23. grep -m5 -E "error:|Please submit" /tmp/ct_c_$m
  24. exit 1
  25. fi
  26. done
  27. echo " support modules rebuilt"
  28. fi
  29. rm -f tests/ct.lst compiletest
  30. $GM2 $FLAGS -fgen-module-list=tests/ct.lst -o /dev/null \
  31. tests/CompileTest.mod TextBuf.o Posix.o Compiler.o >/tmp/ct_p1 2>&1
  32. p1=$?
  33. $GM2 $FLAGS -fuse-list=tests/ct.lst -o compiletest \
  34. tests/CompileTest.mod TextBuf.o Posix.o Compiler.o >/tmp/ct_p2 2>&1
  35. p2=$?
  36. if [ $p2 -ne 0 ]; then
  37. echo "LINK_FAIL p1_rc=$p1 p2_rc=$p2"
  38. grep -E "error:|undefined" /tmp/ct_p2 | head -10
  39. exit 1
  40. fi
  41. echo "compiletest built (p1_rc=$p1, phase 1 rc=1 is the expected rollup)"
  42. FX=${1:-tests/fixtures}
  43. ls "$FX"/*.pas 2>/dev/null | ./compiletest