print.scm 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017, 2020 Ricardo Wurmus <rekado@elephly.net>
  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-print)
  19. #:use-module (guix import print)
  20. #:use-module (guix build-system gnu)
  21. #:use-module (guix download)
  22. #:use-module (guix packages)
  23. #:use-module ((guix licenses) #:prefix license:)
  24. #:use-module ((gnu packages) #:select (search-patches))
  25. #:use-module (srfi srfi-64))
  26. (define-syntax-rule (define-with-source object source expr)
  27. (begin
  28. (define object expr)
  29. (define source 'expr)))
  30. (test-begin "print")
  31. (define-with-source pkg pkg-source
  32. (package
  33. (name "test")
  34. (version "1.2.3")
  35. (source (origin
  36. (method url-fetch)
  37. (uri (string-append "file:///tmp/test-"
  38. version ".tar.gz"))
  39. (sha256
  40. (base32
  41. "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))))
  42. (build-system (@ (guix build-system gnu) gnu-build-system))
  43. (home-page "http://gnu.org")
  44. (synopsis "Dummy")
  45. (description "This is a dummy package.")
  46. (license license:gpl3+)))
  47. (define-with-source pkg-with-inputs pkg-with-inputs-source
  48. (package
  49. (name "test")
  50. (version "1.2.3")
  51. (source (origin
  52. (method url-fetch)
  53. (uri (string-append "file:///tmp/test-"
  54. version ".tar.gz"))
  55. (sha256
  56. (base32
  57. "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))))
  58. (build-system (@ (guix build-system gnu) gnu-build-system))
  59. (inputs (list (@ (gnu packages base) coreutils)
  60. `(,(@ (gnu packages base) glibc) "debug")))
  61. (home-page "http://gnu.org")
  62. (synopsis "Dummy")
  63. (description "This is a dummy package.")
  64. (license license:gpl3+)))
  65. (define-with-source pkg-with-origin-input pkg-with-origin-input-source
  66. (package
  67. (name "test")
  68. (version "1.2.3")
  69. (source (origin
  70. (method url-fetch)
  71. (uri (list (string-append "file:///tmp/test-"
  72. version ".tar.gz")
  73. (string-append "http://example.org/test-"
  74. version ".tar.gz")))
  75. (sha256
  76. (base32
  77. "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))
  78. (patches (search-patches "guile-linux-syscalls.patch"
  79. "guile-relocatable.patch"))))
  80. (build-system (@ (guix build-system gnu) gnu-build-system))
  81. (inputs
  82. `(("o" ,(origin
  83. (method url-fetch)
  84. (uri "http://example.org/somefile.txt")
  85. (sha256
  86. (base32
  87. "0000000000000000000000000000000000000000000000000000"))))))
  88. (home-page "http://gnu.org")
  89. (synopsis "Dummy")
  90. (description "This is a dummy package.")
  91. (license license:gpl3+)))
  92. (define-with-source pkg-with-origin-patch pkg-with-origin-patch-source
  93. (package
  94. (name "test")
  95. (version "1.2.3")
  96. (source (origin
  97. (method url-fetch)
  98. (uri (string-append "file:///tmp/test-"
  99. version ".tar.gz"))
  100. (sha256
  101. (base32
  102. "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))
  103. (patches
  104. (list (origin
  105. (method url-fetch)
  106. (uri "http://example.org/x.patch")
  107. (sha256
  108. (base32
  109. "0000000000000000000000000000000000000000000000000000")))))))
  110. (build-system (@ (guix build-system gnu) gnu-build-system))
  111. (home-page "http://gnu.org")
  112. (synopsis "Dummy")
  113. (description "This is a dummy package.")
  114. (license license:gpl3+)))
  115. (define-with-source pkg-with-arguments pkg-with-arguments-source
  116. (package
  117. (name "test")
  118. (version "1.2.3")
  119. (source (origin
  120. (method url-fetch)
  121. (uri (string-append "file:///tmp/test-"
  122. version ".tar.gz"))
  123. (sha256
  124. (base32
  125. "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))))
  126. (build-system (@ (guix build-system gnu) gnu-build-system))
  127. (arguments
  128. `(#:disallowed-references (,(@ (gnu packages base) coreutils))))
  129. (home-page "http://gnu.org")
  130. (synopsis "Dummy")
  131. (description "This is a dummy package.")
  132. (license license:gpl3+)))
  133. (define-with-source pkg-with-properties pkg-with-properties-source
  134. (package
  135. (name "test")
  136. (version "1.2.3")
  137. (source (origin
  138. (method url-fetch)
  139. (uri (string-append "file:///tmp/test-"
  140. version ".tar.gz"))
  141. (sha256
  142. (base32
  143. "070pwb7brdcn1mfvplkd56vjc7lbz4iznzkqvfsakvgbv68k71ah"))))
  144. (properties
  145. `((hidden? . #t) (upstream-name "test-upstream")))
  146. (build-system (@ (guix build-system gnu) gnu-build-system))
  147. (home-page "http://gnu.org")
  148. (synopsis "Dummy")
  149. (description "This is a dummy package.")
  150. (license license:gpl3+)))
  151. (test-equal "simple package"
  152. `(define-public test ,pkg-source)
  153. (package->code pkg))
  154. (test-equal "package with inputs"
  155. `(define-public test ,pkg-with-inputs-source)
  156. (package->code pkg-with-inputs))
  157. (test-equal "package with origin input"
  158. `(define-public test ,pkg-with-origin-input-source)
  159. (package->code pkg-with-origin-input))
  160. (test-equal "package with origin patch"
  161. `(define-public test ,pkg-with-origin-patch-source)
  162. (package->code pkg-with-origin-patch))
  163. (test-equal "package with arguments"
  164. `(define-public test ,pkg-with-arguments-source)
  165. (package->code pkg-with-arguments))
  166. (test-equal "package with properties"
  167. `(define-public test ,pkg-with-properties-source)
  168. (package->code pkg-with-properties))
  169. (test-end "print")