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.
 
 
 
 
 
 

93 lines
3.3 KiB

  1. ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
  2. ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
  3. ;;;
  4. ;;; This file is part of Guix.
  5. ;;;
  6. ;;; 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. ;;; 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 Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (test-builders)
  19. #:use-module (guix http)
  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 derivations)
  25. #:use-module ((guix packages) #:select (package-derivation))
  26. #:use-module (ice-9 match)
  27. #:use-module (srfi srfi-1)
  28. #:use-module (srfi srfi-64))
  29. ;; Test the higher-level builders.
  30. (define %store
  31. (false-if-exception (open-connection)))
  32. (when %store
  33. ;; Make sure we build everything by ourselves.
  34. (set-build-options %store #:use-substitutes? #f))
  35. (define %bootstrap-inputs
  36. ;; Use the bootstrap inputs so it doesn't take ages to run these tests.
  37. ;; This still involves building Make, Diffutils, and Findutils.
  38. ;; XXX: We're relying on the higher-level `package-derivations' here.
  39. (and %store
  40. (map (match-lambda
  41. ((name package)
  42. (list name (package-derivation %store package))))
  43. (@@ (distro packages base) %boot0-inputs))))
  44. (define %bootstrap-guile
  45. (@@ (distro packages base) %bootstrap-guile))
  46. (test-begin "builders")
  47. (test-assert "http-fetch"
  48. (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
  49. (hash (nix-base32-string->bytevector
  50. "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
  51. (drv-path (http-fetch %store url 'sha256 hash))
  52. (out-path (derivation-path->output-path drv-path)))
  53. (and (build-derivations %store (list drv-path))
  54. (file-exists? out-path)
  55. (valid-path? %store out-path))))
  56. (test-assert "gnu-build-system"
  57. (and (build-system? gnu-build-system)
  58. (eq? gnu-build (build-system-builder gnu-build-system))))
  59. (test-assert "gnu-build"
  60. (let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
  61. (hash (nix-base32-string->bytevector
  62. "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
  63. (tarball (http-fetch %store url 'sha256 hash))
  64. (build (gnu-build %store "hello-2.8" tarball
  65. %bootstrap-inputs
  66. #:implicit-inputs? #f
  67. #:guile %bootstrap-guile))
  68. (out (derivation-path->output-path build)))
  69. (and (build-derivations %store (list (pk 'hello-drv build)))
  70. (valid-path? %store out)
  71. (file-exists? (string-append out "/bin/hello")))))
  72. (test-end "builders")
  73. (exit (= (test-runner-fail-count (test-runner-current)) 0))
  74. ;;; Local Variables:
  75. ;;; eval: (put 'test-assert 'scheme-indent-function 1)
  76. ;;; End: