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.
 
 
 
 
 
 

75 lines
2.5 KiB

  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013 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-snix)
  19. #:use-module (guix import snix)
  20. #:use-module ((guix utils) #:select (%nixpkgs-directory))
  21. #:use-module (srfi srfi-1)
  22. #:use-module (srfi srfi-64)
  23. #:use-module (ice-9 match))
  24. (define factorize-uri
  25. (@@ (guix import snix) factorize-uri))
  26. (define-syntax-rule (every? proc lists ...)
  27. (not (not (every proc lists ...))))
  28. (test-begin "snix")
  29. (test-assert "factorize-uri"
  30. (every? (match-lambda
  31. ((uri version '-> expected)
  32. (equal? (factorize-uri uri version)
  33. expected)))
  34. '(("http://example.com/foo.tgz" "1.0"
  35. -> "http://example.com/foo.tgz")
  36. ("http://example.com/foo-2.8.tgz" "2.8"
  37. -> ("http://example.com/foo-" version ".tgz"))
  38. ("http://example.com/2.8/foo-2.8.tgz" "2.8"
  39. -> ("http://example.com/" version "/foo-" version ".tgz")))))
  40. (test-skip (if (and (%nixpkgs-directory)
  41. (file-exists? (string-append (%nixpkgs-directory)
  42. "/default.nix")))
  43. 0
  44. 1))
  45. (test-assert "nixpkgs->guix-package"
  46. (match (nixpkgs->guix-package (%nixpkgs-directory) "guile")
  47. (('package
  48. ('name "guile")
  49. ('version (? string?))
  50. ('source ('origin _ ...))
  51. ('build-system _)
  52. ('inputs ('quasiquote (inputs ...)))
  53. ('propagated-inputs ('quasiquote (pinputs ...)))
  54. ('home-page (? string?))
  55. ('synopsis (? string?))
  56. ('description (? string?))
  57. ('license (? symbol?)))
  58. (and (member '("libffi" ,libffi) inputs)
  59. (member '("gmp" ,gmp) pinputs)
  60. #t))
  61. (x
  62. (pk 'fail x #f))))
  63. (test-end "snix")
  64. (exit (= (test-runner-fail-count (test-runner-current)) 0))