builders.scm 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014, 2015, 2019 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-builders)
  19. #:use-module (guix download)
  20. #:use-module (guix build-system)
  21. #:use-module (guix build-system gnu)
  22. #:use-module (guix store)
  23. #:use-module (guix utils)
  24. #:use-module (guix base32)
  25. #:use-module (guix derivations)
  26. #:use-module (gcrypt hash)
  27. #:use-module (guix tests)
  28. #:use-module ((guix packages)
  29. #:select (package?
  30. package-derivation package-native-search-paths))
  31. #:use-module (gnu packages bootstrap)
  32. #:use-module (ice-9 match)
  33. #:use-module (srfi srfi-1)
  34. #:use-module (srfi srfi-64))
  35. ;; Test the higher-level builders.
  36. (define %store
  37. (open-connection-for-tests))
  38. (define url-fetch*
  39. (store-lower url-fetch))
  40. (test-begin "builders")
  41. (unless (network-reachable?) (test-skip 1))
  42. (test-assert "url-fetch"
  43. (let* ((url '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
  44. "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
  45. (hash (nix-base32-string->bytevector
  46. "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
  47. (drv (url-fetch* %store url 'sha256 hash
  48. #:guile %bootstrap-guile))
  49. (out-path (derivation->output-path drv)))
  50. (and (build-derivations %store (list drv))
  51. (file-exists? out-path)
  52. (valid-path? %store out-path))))
  53. (test-assert "url-fetch, file"
  54. (let* ((file (search-path %load-path "guix.scm"))
  55. (hash (call-with-input-file file port-sha256))
  56. (out (url-fetch* %store file 'sha256 hash)))
  57. (and (file-exists? out)
  58. (valid-path? %store out))))
  59. (test-assert "url-fetch, file URI"
  60. (let* ((file (search-path %load-path "guix.scm"))
  61. (hash (call-with-input-file file port-sha256))
  62. (out (url-fetch* %store
  63. (string-append "file://" (canonicalize-path file))
  64. 'sha256 hash)))
  65. (and (file-exists? out)
  66. (valid-path? %store out))))
  67. (test-assert "gnu-build-system"
  68. (build-system? gnu-build-system))
  69. (test-end "builders")