guix-lint.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # GNU Guix --- Functional package management for GNU
  2. # Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
  3. #
  4. # This file is part of GNU Guix.
  5. #
  6. # GNU Guix is free software; you can redistribute it and/or modify it
  7. # under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or (at
  9. # your option) any later version.
  10. #
  11. # GNU Guix is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # Test the `guix lint' command-line utility.
  20. #
  21. guix lint --version
  22. module_dir="t-guix-lint-$$"
  23. mkdir "$module_dir"
  24. trap "rm -rf $module_dir" EXIT
  25. cat > "$module_dir/foo.scm"<<EOF
  26. (define-module (foo)
  27. #:use-module (guix packages)
  28. #:use-module (gnu packages base))
  29. (define-public dummy
  30. (package (inherit hello)
  31. (name "dummy")
  32. (version "42")
  33. (synopsis "dummy package")
  34. (description "dummy package. Only used for testing purposes.")))
  35. EOF
  36. GUIX_PACKAGE_PATH="$module_dir"
  37. export GUIX_PACKAGE_PATH
  38. grep_warning ()
  39. {
  40. res=`echo "$1" | grep -E -c "(synopsis|description) should"`
  41. echo $res
  42. }
  43. # Three issues with the dummy package:
  44. # 1) the synopsis starts with the package name;
  45. # 2) the synopsis starts with a lower-case letter;
  46. # 3) the description has a single space following the end-of-sentence period.
  47. out=`guix lint -c synopsis,description dummy 2>&1`
  48. if [ `grep_warning "$out"` -ne 3 ]
  49. then false; else true; fi
  50. out=`guix lint -c synopsis dummy 2>&1`
  51. if [ `grep_warning "$out"` -ne 2 ]
  52. then false; else true; fi
  53. out=`guix lint -c description dummy 2>&1`
  54. if [ `grep_warning "$out"` -ne 1 ]
  55. then false; else true; fi
  56. out=`guix lint -c description,synopsis dummy 2>&1`
  57. if [ `grep_warning "$out"` -ne 3 ]
  58. then false; else true; fi
  59. if guix lint -c synopsis,invalid-checker dummy 2>&1 | \
  60. grep -q 'invalid-checker: invalid checker'
  61. then true; else false; fi
  62. # Make sure specifying multiple packages works.
  63. guix lint -c inputs-should-be-native dummy dummy@42 dummy