posixsubst-tests.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #! /bin/sh
  2. # Copyright (C) 2010-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. # Test that POSIX variable expansion '$(var:str=rpl)' works when used
  17. # with the TESTS special variable.
  18. # For gen-testsuite-part: ==> try-with-serial-tests <==
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. t1 = foo1 foo2
  25. t2 = barx
  26. t3 = bar2
  27. foo2.test barz:
  28. (echo '#!/bin/sh' && echo 'exit 0') > $@ && chmod a+x $@
  29. CLEANFILES = foo2.test barz # For FreeBSD make.
  30. # Also try an empty match suffix, to ensure that the ':=' in there is
  31. # not confused by the parser with an unportable assignment operator.
  32. TESTS = $(t1:=.test) $(t2:x=y) $(t3:2=z)
  33. EXTRA_DIST = $(TESTS)
  34. MOSTLYCLEANFILES = *.out
  35. END
  36. cat > foo1.test <<'END'
  37. #!/bin/sh
  38. touch foo1.out
  39. test x"${TESTSUITE_OK-no}" = x"yes"
  40. END
  41. sed 's/foo1/bary/g' foo1.test > bary
  42. chmod +x foo1.test bary
  43. $ACLOCAL
  44. $AUTOCONF
  45. $AUTOMAKE -a
  46. ./configure
  47. run_make -M -e FAIL check
  48. ls -l
  49. grep '^FAIL: foo1\.test *$' output
  50. grep '^PASS: foo2\.test *$' output
  51. grep '^FAIL: bary *$' output
  52. grep '^PASS: barz *$' output
  53. test -f foo1.out
  54. test -f bary.out
  55. TESTSUITE_OK=yes $MAKE distcheck
  56. :