doctest 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # Midnight Commander - check the documentation for compatibility with groff and nroff.
  3. #
  4. # Copyright (C) 2002, 2003, 2011, 2013
  5. # The Free Software Foundation, Inc.
  6. #
  7. # Written by:
  8. # Pavel Roskin <proski@gnu.org> 2002, 2003
  9. # Ilia Maslakov <il.smind@gmail.com>, 2011
  10. # Slava Zanko <slavazanko@gmail.com>, 2013
  11. #
  12. # This file is part of the Midnight Commander.
  13. #
  14. # The Midnight Commander is free software: you can redistribute it
  15. # and/or modify it under the terms of the GNU General Public License as
  16. # published by the Free Software Foundation, either version 3 of the License,
  17. # or (at your option) any later version.
  18. #
  19. # The Midnight Commander is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. #set -e
  27. MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(pwd)))}
  28. #*** include section (source functions, for example) *******************
  29. #*** file scope functions **********************************************
  30. one_test() {
  31. "$@" >/dev/null 2>doctest.err
  32. if test -s doctest.err; then
  33. echo "ERROR messages follow:" 2>&1
  34. cat doctest.err 2>&1
  35. echo "ERROR while running following command:" 2>&1
  36. echo "$@" 2>&1
  37. echo "ERROR messages are preserved in doctest.err"
  38. exit 1
  39. fi
  40. }
  41. #*** main code *********************************************************
  42. [ -r "${MC_SOURCE_ROOT_DIR}/doc/man/mc.1.in" ] || {
  43. echo "ERROR: cannot read doc/mc.1.in" 2>&1
  44. exit 1
  45. }
  46. # Test the documentation for possible errors.
  47. for i in $(find "${MC_SOURCE_ROOT_DIR}/doc" -name '*.[1-9].in'); do
  48. echo "test (groff): $i"
  49. preconv -e UTF8 "${i}" | \
  50. groff -wall -mandoc -Tutf8 | \
  51. grep "warning:"
  52. done
  53. for i in $(find "${MC_SOURCE_ROOT_DIR}/doc" -name '*.[1-9].in'); do
  54. echo "test (nroff): $i"
  55. preconv -e UTF8 "${i}" | \
  56. nroff -Tutf8 -mandoc | \
  57. grep "warning:"
  58. done
  59. # Check the English manuals to be in ASCII.
  60. one_test find "${MC_SOURCE_ROOT_DIR}/doc" -maxdepth 1 -name '*.[1-9].in' -exec groff -wall -Tascii {} \;
  61. rm -rf doctest.err
  62. exit 0