test-driver-cond.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #! /bin/sh
  2. # Copyright (C) 2011-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. # parallel-tests:
  17. # - Automake can correctly handle conditionals contents for the
  18. # LOG_DRIVER variables.
  19. . test-init.sh
  20. cp "$am_testaux_srcdir"/trivial-test-driver . \
  21. || fatal_ "failed to fetch auxiliary script trivial-test-driver"
  22. cp "$am_scriptdir"/tap-driver.sh . \
  23. || fatal_ "failed to fetch auxiliary script tap-driver.sh"
  24. cat >> configure.ac << END
  25. AM_CONDITIONAL([COND1], [:])
  26. AM_CONDITIONAL([COND2], [false])
  27. AM_CONDITIONAL([COND3], [false])
  28. AC_SUBST([PERL], ['$PERL'])
  29. AC_SUBST([my_LOG_DRIVER], ['\${SHELL} \${top_srcdir}/trivial-test-driver'])
  30. AM_SUBST_NOTMAKE([my_LOG_DRIVER])
  31. AC_OUTPUT
  32. END
  33. $ACLOCAL
  34. $AUTOCONF
  35. cat > Makefile.am << 'END'
  36. TESTS = foo bar.test baz.sh
  37. EXTRA_DIST = $(TESTS) tap-driver.sh trivial-test-driver
  38. TEST_EXTENSIONS = .test .sh
  39. LOG_DRIVER =
  40. SH_LOG_DRIVER = $(tap_rulez)
  41. if COND1
  42. LOG_DRIVER += @my_LOG_DRIVER@
  43. if COND2
  44. tap_rulez = false
  45. else !COND2
  46. tap_rulez = $(PERL) $(srcdir)/tap-driver.sh
  47. endif !COND2
  48. endif COND1
  49. END
  50. cat > foo <<'END'
  51. #!/bin/sh
  52. echo "PASS: from $0"
  53. echo "SKIP: from $0"
  54. exit 1 # exit status should be ignored by the trivial-test-driver.
  55. END
  56. cat > bar.test <<'END'
  57. #!/bin/sh
  58. exit 0
  59. END
  60. cat > baz.sh <<'END'
  61. #!/bin/sh
  62. echo 1..3
  63. echo 'ok 1'
  64. echo 'not ok 2 # TODO'
  65. echo 'not ok 3 # TODO'
  66. END
  67. chmod a+x foo bar.test baz.sh
  68. $AUTOMAKE -a
  69. test -f test-driver
  70. grep DRIVER Makefile.in || exit 99 # For debugging.
  71. grep '^my_LOG_DRIVER *=' Makefile.in \
  72. && fatal_ 'unexpected $(my_LOG_DRIVER) in Makefile.in'
  73. grep '^TEST_LOG_DRIVER =.*\$(SHELL).*/test-driver' Makefile.in
  74. $PERL -MTAP::Parser -e 1 \
  75. || skip_ "cannot import TAP::Parser perl module"
  76. ./configure
  77. do_count ()
  78. {
  79. count_test_results total=6 pass=3 fail=0 skip=1 xfail=2 xpass=0 error=0
  80. grep '^PASS: foo, testcase 1 *$' stdout
  81. grep '^SKIP: foo, testcase 2 *$' stdout
  82. grep '^PASS: bar\.test *$' stdout
  83. $EGREP 'PASS: baz\.sh 1( |$)' stdout
  84. $EGREP 'XFAIL: baz\.sh 2( |$)' stdout
  85. $EGREP 'XFAIL: baz\.sh 3( |$)' stdout
  86. }
  87. run_make -O -e IGNORE check
  88. cat test-suite.log
  89. cat foo.log
  90. cat bar.log
  91. cat baz.log
  92. test $am_make_rc -eq 0 || exit 1
  93. do_count
  94. run_make -O distcheck
  95. do_count
  96. :