2
0

am-tests-environment.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: check AM_TESTS_ENVIRONMENT support, and its
  17. # interactions with TESTS_ENVIRONMENT.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_MKDIR_P
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. TEST_EXTENSIONS = .sh .test
  25. TESTS = foo.test bar.sh
  26. SH_LOG_COMPILER = sh
  27. AM_TESTS_ENVIRONMENT = \
  28. $(MKDIR_P) quux.dir; \
  29. if test -f $(srcdir)/test-env.sh; then \
  30. . $(srcdir)/test-env.sh; \
  31. fi; \
  32. FOO=1; export FOO;
  33. EXTRA_DIST = $(TESTS) test-env.sh
  34. END
  35. cat > foo.test << 'END'
  36. #! /bin/sh
  37. ls -l && test -d quux.dir
  38. END
  39. chmod a+x foo.test
  40. cat > bar.sh << 'END'
  41. echo "FOO='$FOO'"
  42. echo "BAR='$BAR'"
  43. test x"$FOO" = x"$BAR"
  44. END
  45. debug_info ()
  46. {
  47. cat test-suite.log
  48. cat foo.log
  49. cat bar.log
  50. }
  51. minicheck ()
  52. {
  53. debug_info
  54. test -d quux.dir
  55. }
  56. miniclean ()
  57. {
  58. rmdir quux.dir
  59. rm -f foo.log bar.log test-suite.log
  60. }
  61. $ACLOCAL
  62. $AUTOCONF
  63. $AUTOMAKE -a
  64. ./configure
  65. TESTS_ENVIRONMENT='BAR=1' $MAKE check || { debug_info; exit 1; }
  66. minicheck
  67. miniclean
  68. TESTS_ENVIRONMENT='BAR=2' $MAKE check && { debug_info; exit 1; }
  69. minicheck
  70. miniclean
  71. echo 'BAR=1 && export BAR' > test-env.sh
  72. $MAKE check || { debug_info; exit 1; }
  73. minicheck
  74. $MAKE distcheck
  75. :