discovery.scm 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
  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. (define-module (test-discovery)
  19. #:use-module (guix discovery)
  20. #:use-module (guix build-system)
  21. #:use-module (guix utils)
  22. #:use-module (srfi srfi-64)
  23. #:use-module (ice-9 match))
  24. (define %top-srcdir
  25. (dirname (search-path %load-path "guix.scm")))
  26. (test-begin "discovery")
  27. (test-assert "scheme-modules"
  28. (match (map module-name (scheme-modules %top-srcdir "guix/import"))
  29. ((('guix 'import _ ...) ..1)
  30. #t)))
  31. (test-assert "scheme-modules recurses in symlinks to directories"
  32. (call-with-temporary-directory
  33. (lambda (directory)
  34. (mkdir (string-append directory "/guix"))
  35. (symlink (string-append %top-srcdir "/guix/import")
  36. (string-append directory "/guix/import"))
  37. ;; DIRECTORY/guix/import is a symlink but we want to make sure
  38. ;; 'scheme-modules' recurses into it.
  39. (match (map module-name (scheme-modules directory))
  40. ((('guix 'import _ ...) ..1)
  41. #t)))))
  42. (test-equal "scheme-modules, non-existent directory"
  43. '()
  44. (scheme-modules "/does/not/exist"))
  45. (test-assert "all-modules"
  46. (match (map module-name
  47. (all-modules `((,%top-srcdir . "guix/build-system"))))
  48. ((('guix 'build-system names) ..1)
  49. names)))
  50. (test-assert "fold-module-public-variables"
  51. (let ((modules (all-modules `((,%top-srcdir . "guix/build-system")))))
  52. (match (fold-module-public-variables (lambda (obj result)
  53. (if (build-system? obj)
  54. (cons obj result)
  55. result))
  56. '()
  57. modules)
  58. (((? build-system? bs) ..1)
  59. bs))))
  60. (test-end "discovery")