distcheck-pr10470.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #! /bin/sh
  2. # Copyright (C) 2012-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. # Ensure "make distcheck" does not experience racy failures on
  17. # systems (like MinGW/MSYS) that cannot remove a directory "in use"
  18. # by a process (e.g., that is its "current working directory").
  19. # See automake bug#10470.
  20. . test-init.sh
  21. mkdir foo.d
  22. sh -c "cd foo.d && sleep '4'" &
  23. # Without this sleep, the "rm -rf foo.d" below would reliably beat
  24. # the "cd foo.d" in the subshell above, and the test would be always
  25. # skipped, even on MinGW/MSYS.
  26. sleep '1'
  27. rm -rf foo.d && skip_ 'system is able to remove "in use" directories'
  28. echo AC_OUTPUT >> configure.ac
  29. cat > Makefile.am <<END
  30. TESTS = foo.test
  31. EXTRA_DIST= foo.test
  32. END
  33. cat > foo.test <<END
  34. #!/bin/sh
  35. sleep '4' &
  36. exit 0
  37. END
  38. chmod a+x foo.test
  39. $ACLOCAL
  40. $AUTOCONF
  41. $AUTOMAKE -a
  42. ./configure
  43. # We can build the distribution.
  44. run_make -M distcheck
  45. # Sanity check: verify that our code has hit a problem removing
  46. # the distdir, but has recovered from it.
  47. $EGREP "(^| )(rm|find):.*$distdir" output || fatal_ "expected code path not covered"
  48. :