parallel-tests-log-compiler-1.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #! /bin/sh
  2. # Copyright (C) 2009-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Check parallel-tests features:
  17. # - per-extension "test runners" a.k.a. "log compilers" (xxx_LOG_COMPILER
  18. # and xxx_LOG_FLAGS), also with AC_SUBST'd stuff.
  19. # See also related test 'parallel-tests-log-compiler-2.sh'.
  20. . test-init.sh
  21. cat >> configure.ac << 'END'
  22. AC_SUBST([acsubst_compiler], [t-compiler])
  23. AC_CONFIG_LINKS([chk-compiler:chk-compiler])
  24. AC_OUTPUT
  25. END
  26. cat > Makefile.am << 'END'
  27. # Note that automake should not match the '/test' part of 'sub/test'
  28. # as '.test' suffix.
  29. TESTS = foo.chk bar.test baz bla.t bli.suff sub/test
  30. TEST_EXTENSIONS = .chk .test .t
  31. CHK_LOG_COMPILER = ./chk-compiler
  32. TEST_LOG_COMPILER = $(SHELL) $(srcdir)/test-compiler
  33. T_LOG_COMPILER = @acsubst_compiler@
  34. LOG_COMPILER = @SHELL@ -x $(srcdir)/noext-compiler
  35. CHK_LOG_FLAGS = --chk
  36. AM_TEST_LOG_FLAGS = --am-test
  37. T_LOG_FLAGS = --t
  38. AM_T_LOG_FLAGS = --am-t
  39. AM_LOG_FLAGS = -a
  40. LOG_FLAGS = -b
  41. # 't-compiler' is deliberately not distributed; it should be available
  42. # in PATH also from "make distcheck".
  43. EXTRA_DIST = $(TESTS) chk-compiler test-compiler noext-compiler
  44. END
  45. mkdir sub
  46. cat > chk-compiler <<'END'
  47. #! /bin/sh
  48. test x"$1" = x"--chk" || {
  49. echo "$0: invalid command line: $*" >&2
  50. exit 1
  51. }
  52. shift
  53. exec "$@"
  54. exit 127
  55. END
  56. sed 's/--chk/--am-test/' chk-compiler > test-compiler
  57. mkdir bin
  58. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
  59. cat > bin/t-compiler <<'END'
  60. #! /bin/sh
  61. if test x"$1,$2" != x"--am-t,--t"; then
  62. echo "$0: invalid command line: $*" >&2
  63. exit 1
  64. fi
  65. shift; shift
  66. exec "$@"
  67. exit 127
  68. END
  69. sed 's/--am-t,--t/-a,-b/' bin/t-compiler > noext-compiler
  70. chmod a+x chk-compiler chk-compiler test-compiler bin/t-compiler noext-compiler
  71. cat >foo.chk << 'END'
  72. #! /bin/sh
  73. exit 0
  74. END
  75. chmod a+x foo.chk
  76. cp foo.chk bar.test
  77. cp foo.chk baz
  78. cp foo.chk bla.t
  79. cp foo.chk bli.suff
  80. cp foo.chk sub/test
  81. $ACLOCAL
  82. $AUTOCONF
  83. $AUTOMAKE -a
  84. ./configure
  85. $MAKE check || { cat test-suite.log; exit 1; }
  86. ls -l . sub
  87. cat test-suite.log
  88. test -f foo.log
  89. test -f bar.log
  90. test -f baz.log
  91. test -f bla.log
  92. test -f bli.suff.log
  93. test -f sub/test.log
  94. run_make -e FAIL T_LOG_FLAGS=--bad check
  95. cat test-suite.log
  96. cat bla.log
  97. # With the above flag overridden, bla.t should fail ...
  98. $EGREP '(^ *|/)t-compiler:.* invalid .*--bad' bla.log
  99. # ... but no other test should.
  100. grep -v '^FAIL: bla\.t ' bla.log | grep 'FAIL:' && exit 1
  101. # Try also with a VPATH build.
  102. $MAKE distcheck
  103. :