dollarvar2.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # Test to make sure that -Wportability turns on portability-recursive,
  17. # likewise for -Wno-...
  18. . test-init.sh
  19. #
  20. # First, try a setup where we have a 'portability-recursive' warning,
  21. # but no "simple" 'portability' warning.
  22. #
  23. cat >Makefile.am <<'EOF'
  24. x = 1
  25. bla = $(foo$(x))
  26. EOF
  27. $ACLOCAL
  28. # Enabling 'portability' warnings should enable 'portability-recursive'
  29. # warnings.
  30. AUTOMAKE_fails -Wnone -Wportability
  31. grep 'recursive variable expansion' stderr
  32. # 'portability-recursive' warnings can be enabled by themselves.
  33. AUTOMAKE_fails -Wnone -Wportability-recursive
  34. grep 'recursive variable expansion' stderr
  35. # Various ways to disable 'portability-recursive'.
  36. $AUTOMAKE -Wno-all
  37. $AUTOMAKE -Wno-portability
  38. $AUTOMAKE -Wall -Wno-portability-recursive
  39. # '-Wno-portability-recursive' after '-Wportability' correctly disables
  40. # 'portability-recursive' warnings.
  41. $AUTOMAKE -Wportability -Wno-portability-recursive
  42. # '-Wno-portability' disables 'portability-recursive' warnings; but
  43. # a later '-Wportability-recursive' re-enables them. This time, we
  44. # use AUTOMAKE_OPTIONS to specify the warning levels.
  45. echo 'AUTOMAKE_OPTIONS = -Wno-portability' >> Makefile.am
  46. $AUTOMAKE
  47. echo 'AUTOMAKE_OPTIONS += -Wportability-recursive' >> Makefile.am
  48. AUTOMAKE_fails
  49. grep 'recursive variable expansion' stderr
  50. #
  51. # Now try a setup where we have both a 'portability' warning and
  52. # a 'portability-recursive' one.
  53. #
  54. cat >Makefile.am <<'EOF'
  55. x = 1
  56. bla = $(foo$(x))
  57. oops = $(var-with-dash)
  58. EOF
  59. # Can disable both 'portability' and 'portability-recursive' warnings.
  60. $AUTOMAKE -Wno-portability
  61. # Disabling 'portability-recursive' warnings should not disable
  62. # 'portability' warnings.
  63. AUTOMAKE_fails -Wportability -Wno-portability-recursive
  64. grep 'var-with-dash' stderr
  65. grep 'recursive variable expansion' stderr && exit 1
  66. # Enabling 'portability-recursive' warnings should not enable
  67. # all the 'portability' warning.
  68. AUTOMAKE_fails -Wno-portability -Wportability-recursive
  69. grep 'var-with-dash' stderr && exit 1
  70. grep 'recursive variable expansion' stderr
  71. :