snix.scm 2.4 KB

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