You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

116 lines
4.4 KiB

  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014, 2015 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-derivation package-native-search-paths))
  30. #:use-module (gnu packages bootstrap)
  31. #:use-module (ice-9 match)
  32. #:use-module (srfi srfi-1)
  33. #:use-module (srfi srfi-64))
  34. ;; Test the higher-level builders.
  35. (define %store
  36. (open-connection-for-tests))
  37. (define %bootstrap-inputs
  38. ;; Use the bootstrap inputs so it doesn't take ages to run these tests.
  39. ;; This still involves building Make, Diffutils, and Findutils.
  40. ;; XXX: We're relying on the higher-level `package-derivations' here.
  41. (and %store
  42. (map (match-lambda
  43. ((name package)
  44. (list name (package-derivation %store package))))
  45. (@@ (gnu packages commencement) %boot0-inputs))))
  46. (define %bootstrap-search-paths
  47. ;; Search path specifications that go with %BOOTSTRAP-INPUTS.
  48. (append-map (match-lambda
  49. ((name package _ ...)
  50. (package-native-search-paths package)))
  51. (@@ (gnu packages commencement) %boot0-inputs)))
  52. (define url-fetch*
  53. (store-lower url-fetch))
  54. (test-begin "builders")
  55. (unless (network-reachable?) (test-skip 1))
  56. (test-assert "url-fetch"
  57. (let* ((url '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
  58. "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
  59. (hash (nix-base32-string->bytevector
  60. "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
  61. (drv (url-fetch* %store url 'sha256 hash
  62. #:guile %bootstrap-guile))
  63. (out-path (derivation->output-path drv)))
  64. (and (build-derivations %store (list drv))
  65. (file-exists? out-path)
  66. (valid-path? %store out-path))))
  67. (test-assert "url-fetch, file"
  68. (let* ((file (search-path %load-path "guix.scm"))
  69. (hash (call-with-input-file file port-sha256))
  70. (out (url-fetch* %store file 'sha256 hash)))
  71. (and (file-exists? out)
  72. (valid-path? %store out))))
  73. (test-assert "url-fetch, file URI"
  74. (let* ((file (search-path %load-path "guix.scm"))
  75. (hash (call-with-input-file file port-sha256))
  76. (out (url-fetch* %store
  77. (string-append "file://" (canonicalize-path file))
  78. 'sha256 hash)))
  79. (and (file-exists? out)
  80. (valid-path? %store out))))
  81. (test-assert "gnu-build-system"
  82. (build-system? gnu-build-system))
  83. (when (or (not (network-reachable?)) (shebang-too-long?))
  84. (test-skip 1))
  85. (test-assert "gnu-build"
  86. (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
  87. (hash (nix-base32-string->bytevector
  88. "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
  89. (tarball (url-fetch* %store url 'sha256 hash
  90. #:guile %bootstrap-guile))
  91. (build (gnu-build %store "hello-2.8"
  92. `(("source" ,tarball)
  93. ,@%bootstrap-inputs)
  94. #:guile %bootstrap-guile
  95. #:search-paths %bootstrap-search-paths))
  96. (out (derivation->output-path build)))
  97. (and (build-derivations %store (list (pk 'hello-drv build)))
  98. (valid-path? %store out)
  99. (file-exists? (string-append out "/bin/hello")))))
  100. (test-end "builders")