| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 |
|
| 24 | (define-module (tests packages)
|
| 25 | #:use-module (guix tests)
|
| 26 | #:use-module (guix store)
|
| 27 | #:use-module (guix monads)
|
| 28 | #:use-module (guix gexp)
|
| 29 | #:use-module (guix utils)
|
| 30 | #:use-module ((guix build utils) #:select (tarball?))
|
| 31 | #:use-module ((guix diagnostics)
|
| 32 | |
| 33 | |
| 34 | #:renamer (lambda (name)
|
| 35 | (cond ((eq? name 'location) 'make-location)
|
| 36 | (else name))))
|
| 37 | #:use-module ((gcrypt hash) #:prefix gcrypt:)
|
| 38 | #:use-module (guix derivations)
|
| 39 | #:use-module (guix download)
|
| 40 | #:use-module (guix packages)
|
| 41 | #:use-module (guix grafts)
|
| 42 | #:use-module (guix search-paths)
|
| 43 | #:use-module (guix build-system)
|
| 44 | #:use-module (guix build-system trivial)
|
| 45 | #:use-module (guix build-system gnu)
|
| 46 | #:use-module (guix build-system pyproject)
|
| 47 | #:use-module (guix memoization)
|
| 48 | #:use-module (guix profiles)
|
| 49 | #:use-module (guix scripts package)
|
| 50 | #:use-module (guix sets)
|
| 51 | #:use-module (gnu packages)
|
| 52 | #:use-module (gnu packages base)
|
| 53 | #:use-module (gnu packages guile)
|
| 54 | #:use-module (gnu packages bootstrap)
|
| 55 | #:use-module (gnu packages python)
|
| 56 | #:use-module (gnu packages version-control)
|
| 57 | #:use-module (gnu packages xml)
|
| 58 | #:use-module (srfi srfi-1)
|
| 59 | #:use-module (srfi srfi-11)
|
| 60 | #:use-module (srfi srfi-26)
|
| 61 | #:use-module (srfi srfi-34)
|
| 62 | #:use-module (srfi srfi-35)
|
| 63 | #:use-module (srfi srfi-64)
|
| 64 | #:use-module (srfi srfi-71)
|
| 65 | #:use-module (rnrs bytevectors)
|
| 66 | #:use-module (rnrs io ports)
|
| 67 | #:use-module (ice-9 vlist)
|
| 68 | #:use-module (ice-9 regex)
|
| 69 | #:use-module (ice-9 match))
|
| 70 |
|
| 71 | |
| 72 |
|
| 73 | (define %store
|
| 74 | (open-connection-for-tests))
|
| 75 |
|
| 76 | |
| 77 | |
| 78 | (%graft? #f)
|
| 79 |
|
| 80 | |
| 81 | (%graft-with-utf8-locale? #f)
|
| 82 |
|
| 83 | (define (bootstrap-binary name)
|
| 84 | (let ((bin (search-bootstrap-binary name (%current-system))))
|
| 85 | (and %store
|
| 86 | (add-to-store %store name #t "sha256" bin))))
|
| 87 |
|
| 88 |
|
| 89 | (test-begin "packages")
|
| 90 |
|
| 91 | (test-assert "printer with location"
|
| 92 | (string-match "^#<package foo@0 foo.scm:42 [[:xdigit:]]+>$"
|
| 93 | (with-output-to-string
|
| 94 | (lambda ()
|
| 95 | (write
|
| 96 | (dummy-package "foo"
|
| 97 | (location (make-location "foo.scm" 42 7))))))))
|
| 98 |
|
| 99 | (test-assert "printer without location"
|
| 100 | (string-match "^#<package foo@0 [[:xdigit:]]+>$"
|
| 101 | (with-output-to-string
|
| 102 | (lambda ()
|
| 103 | (write
|
| 104 | (dummy-package "foo" (location #f)))))))
|
| 105 |
|
| 106 | (test-equal "license type checking"
|
| 107 | 'bad-license
|
| 108 | (guard (c ((package-license-error? c)
|
| 109 | (package-error-invalid-license c)))
|
| 110 | (dummy-package "foo"
|
| 111 | (license 'bad-license))))
|
| 112 |
|
| 113 | (test-assert "hidden-package"
|
| 114 | (and (hidden-package? (hidden-package (dummy-package "foo")))
|
| 115 | (not (hidden-package? (dummy-package "foo")))))
|
| 116 |
|
| 117 | (test-assert "package-superseded"
|
| 118 | (let* ((new (dummy-package "bar"))
|
| 119 | (old (deprecated-package "foo" new)))
|
| 120 | (and (eq? (package-superseded old) new)
|
| 121 | (mock ((gnu packages) find-best-packages-by-name (const (list old)))
|
| 122 | (specification->package "foo")
|
| 123 | (and (eq? new (specification->package "foo"))
|
| 124 | (eq? new (specification->package+output "foo")))))))
|
| 125 |
|
| 126 | (test-assert "transaction-upgrade-entry, zero upgrades"
|
| 127 | (let* ((old (dummy-package "foo" (version "1")))
|
| 128 | (tx (mock ((gnu packages) find-best-packages-by-name
|
| 129 | (const '()))
|
| 130 | (transaction-upgrade-entry
|
| 131 | #f |
| 132 | (manifest-entry
|
| 133 | (inherit (package->manifest-entry old))
|
| 134 | (item (string-append (%store-prefix) "/"
|
| 135 | (make-string 32 #\e) "-foo-1")))
|
| 136 | (manifest-transaction)))))
|
| 137 | (manifest-transaction-null? tx)))
|
| 138 |
|
| 139 | (test-assert "transaction-upgrade-entry, zero upgrades, equivalent package"
|
| 140 | (let* ((old (dummy-package "foo" (version "1")))
|
| 141 | (drv (package-derivation %store old))
|
| 142 | (tx (mock ((gnu packages) find-best-packages-by-name
|
| 143 | (const (list old)))
|
| 144 | (transaction-upgrade-entry
|
| 145 | %store
|
| 146 | (manifest-entry
|
| 147 | (inherit (package->manifest-entry old))
|
| 148 | (item (derivation->output-path drv)))
|
| 149 | (manifest-transaction)))))
|
| 150 | (manifest-transaction-null? tx)))
|
| 151 |
|
| 152 | (test-assert "transaction-upgrade-entry, zero upgrades, propagated inputs"
|
| 153 | |
| 154 | |
| 155 | (let* ((dep (dummy-package "dep" (version "2")))
|
| 156 | (old (dummy-package "foo" (version "1")
|
| 157 | (propagated-inputs (list dep))))
|
| 158 | (drv (package-derivation %store old))
|
| 159 | (tx (mock ((gnu packages) find-best-packages-by-name
|
| 160 | (const (list old)))
|
| 161 | (transaction-upgrade-entry
|
| 162 | %store
|
| 163 | (manifest-entry
|
| 164 | (inherit (package->manifest-entry old))
|
| 165 | (item (derivation->output-path drv))
|
| 166 | (dependencies
|
| 167 | (list (manifest-entry
|
| 168 | (inherit (package->manifest-entry dep))
|
| 169 | (item (derivation->output-path
|
| 170 | (package-derivation %store dep)))))))
|
| 171 | (manifest-transaction)))))
|
| 172 | (manifest-transaction-null? tx)))
|
| 173 |
|
| 174 | (test-assert "transaction-upgrade-entry, one upgrade"
|
| 175 | (let* ((old (dummy-package "foo" (version "1")))
|
| 176 | (new (dummy-package "foo" (version "2")))
|
| 177 | (tx (mock ((gnu packages) find-best-packages-by-name
|
| 178 | (const (list new)))
|
| 179 | (transaction-upgrade-entry
|
| 180 | #f |
| 181 | (manifest-entry
|
| 182 | (inherit (package->manifest-entry old))
|
| 183 | (item (string-append (%store-prefix) "/"
|
| 184 | (make-string 32 #\e) "-foo-1")))
|
| 185 | (manifest-transaction)))))
|
| 186 | (and (match (manifest-transaction-install tx)
|
| 187 | ((($ <manifest-entry> "foo" "2" "out" item))
|
| 188 | (eq? item new)))
|
| 189 | (null? (manifest-transaction-remove tx)))))
|
| 190 |
|
| 191 | (test-assert "transaction-upgrade-entry, superseded package"
|
| 192 | (let* ((old (dummy-package "foo" (version "1")))
|
| 193 | (new (dummy-package "bar" (version "2")))
|
| 194 | (dep (deprecated-package "foo" new))
|
| 195 | (tx (mock ((gnu packages) find-best-packages-by-name
|
| 196 | (const (list dep)))
|
| 197 | (transaction-upgrade-entry
|
| 198 | #f |
| 199 | (manifest-entry
|
| 200 | (inherit (package->manifest-entry old))
|
| 201 | (item (string-append (%store-prefix) "/"
|
| 202 | (make-string 32 #\e) "-foo-1")))
|
| 203 | (manifest-transaction)))))
|
| 204 | (and (match (manifest-transaction-install tx)
|
| 205 | ((($ <manifest-entry> "bar" "2" "out" item))
|
| 206 | (eq? item new)))
|
| 207 | (match (manifest-transaction-remove tx)
|
| 208 | (((? manifest-pattern? pattern))
|
| 209 | (and (string=? (manifest-pattern-name pattern) "foo")
|
| 210 | (string=? (manifest-pattern-version pattern) "1")
|
| 211 | (string=? (manifest-pattern-output pattern) "out")))))))
|
| 212 |
|
| 213 | (test-equal "transaction-upgrade-entry, transformation options preserved"
|
| 214 | (derivation-file-name (package-derivation %store grep))
|
| 215 |
|
| 216 | (let* ((old (dummy-package "emacs" (version "1")))
|
| 217 | (props '((transformations . ((with-input . "emacs=grep")))))
|
| 218 | (tx (transaction-upgrade-entry
|
| 219 | %store
|
| 220 | (manifest-entry
|
| 221 | (inherit (package->manifest-entry old))
|
| 222 | (properties props)
|
| 223 | (item (string-append (%store-prefix) "/"
|
| 224 | (make-string 32 #\e) "-foo-1")))
|
| 225 | (manifest-transaction))))
|
| 226 | (match (manifest-transaction-install tx)
|
| 227 | (((? manifest-entry? entry))
|
| 228 | (and (string=? (manifest-entry-version entry)
|
| 229 | (package-version grep))
|
| 230 | (string=? (manifest-entry-name entry)
|
| 231 | (package-name grep))
|
| 232 | (equal? (manifest-entry-properties entry) props)
|
| 233 | (derivation-file-name
|
| 234 | (package-derivation %store (manifest-entry-item entry))))))))
|
| 235 |
|
| 236 | (test-assert "transaction-upgrade-entry, grafts"
|
| 237 | |
| 238 | |
| 239 | (with-build-handler (const 'failed!)
|
| 240 | (parameterize ((%graft? #t))
|
| 241 | (let* ((old (dummy-package "foo" (version "1")))
|
| 242 | (bar (dummy-package "bar" (version "0")
|
| 243 | (replacement old)))
|
| 244 | (new (dummy-package "foo" (version "1")
|
| 245 | (inputs (list bar))))
|
| 246 | (tx (mock ((gnu packages) find-best-packages-by-name
|
| 247 | (const (list new)))
|
| 248 | (transaction-upgrade-entry
|
| 249 | %store
|
| 250 | (manifest-entry
|
| 251 | (inherit (package->manifest-entry old))
|
| 252 | (item (string-append (%store-prefix) "/"
|
| 253 | (make-string 32 #\e) "-foo-1")))
|
| 254 | (manifest-transaction)))))
|
| 255 | (and (match (manifest-transaction-install tx)
|
| 256 | ((($ <manifest-entry> "foo" "1" "out" item))
|
| 257 | (eq? item new)))
|
| 258 | (null? (manifest-transaction-remove tx)))))))
|
| 259 |
|
| 260 | (test-assert "package-definition-location"
|
| 261 | (let ((location (package-location hello))
|
| 262 | (definition (package-definition-location hello)))
|
| 263 | |
| 264 | (and (string=? (location-file location)
|
| 265 | (location-file definition))
|
| 266 | (= 0 (location-column definition))
|
| 267 | (= 2 (location-column location))
|
| 268 | (= (location-line definition)
|
| 269 | (- (location-line location) 1)))))
|
| 270 |
|
| 271 | (test-assert "package-field-location"
|
| 272 | (let ()
|
| 273 | (define (goto port line column)
|
| 274 | (unless (and (= (port-column port) (- column 1))
|
| 275 | (= (port-line port) (- line 1)))
|
| 276 | (unless (eof-object? (get-char port))
|
| 277 | (goto port line column))))
|
| 278 |
|
| 279 | (define read-at
|
| 280 | (match-lambda
|
| 281 | (($ <location> file line column)
|
| 282 | (call-with-input-file (search-path %load-path file)
|
| 283 | (lambda (port)
|
| 284 | (goto port line column)
|
| 285 | (read port))))))
|
| 286 |
|
| 287 | |
| 288 | |
| 289 | (and (member (read-at (package-field-location %bootstrap-guile 'name))
|
| 290 | (let ((name (package-name %bootstrap-guile)))
|
| 291 | (list name `(name ,name))))
|
| 292 | (member (read-at (package-field-location %bootstrap-guile 'version))
|
| 293 | (let ((version (package-version %bootstrap-guile)))
|
| 294 | (list version `(version ,version))))
|
| 295 | (member (read-at (package-field-location coreutils
|
| 296 | 'build-system))
|
| 297 | '(build-system gnu-build-system))
|
| 298 | (not (package-field-location %bootstrap-guile 'does-not-exist)))))
|
| 299 |
|
| 300 | |
| 301 | (test-equal "package-field-location, relative file name"
|
| 302 | (location-file (package-location %bootstrap-guile))
|
| 303 | (with-fluids ((%file-port-name-canonicalization 'absolute))
|
| 304 | (location-file (package-field-location %bootstrap-guile 'version))))
|
| 305 |
|
| 306 | (test-assert "package-transitive-inputs"
|
| 307 | (let* ((a (dummy-package "a"))
|
| 308 | (b (dummy-package "b"
|
| 309 | (propagated-inputs (list a))))
|
| 310 | (c (dummy-package "c"
|
| 311 | (inputs (list a))))
|
| 312 | (d (dummy-package "d"
|
| 313 | (propagated-inputs `(("x" "something.drv")))))
|
| 314 | (e (dummy-package "e"
|
| 315 | (inputs (list b c d)))))
|
| 316 | (and (null? (package-transitive-inputs a))
|
| 317 | (equal? `(("a" ,a)) (package-transitive-inputs b))
|
| 318 | (equal? `(("a" ,a)) (package-transitive-inputs c))
|
| 319 | (equal? (package-propagated-inputs d)
|
| 320 | (package-transitive-inputs d))
|
| 321 | (equal? `(("b" ,b) ("c" ,c) ("d" ,d)
|
| 322 | ("a" ,a) ("x" "something.drv"))
|
| 323 | (pk 'x (package-transitive-inputs e))))))
|
| 324 |
|
| 325 | (test-assert "package-transitive-inputs, no duplicates"
|
| 326 | (let* ((a (dummy-package "a"))
|
| 327 | (b (dummy-package "b"
|
| 328 | (inputs `(("a+" ,a)))
|
| 329 | (native-inputs `(("a*" ,a)))
|
| 330 | (propagated-inputs `(("a" ,a)))))
|
| 331 | (c (dummy-package "c"
|
| 332 | (propagated-inputs `(("b" ,b)))))
|
| 333 | (d (dummy-package "d"
|
| 334 | (inputs `(("a" ,a) ("c" ,c)))))
|
| 335 | (e (dummy-package "e"
|
| 336 | (inputs `(("b" ,b) ("c" ,c))))))
|
| 337 | (and (null? (package-transitive-inputs a))
|
| 338 | (equal? `(("a*" ,a) ("a+" ,a) ("a" ,a)) |
| 339 | (package-transitive-inputs b))
|
| 340 | (equal? `(("b" ,b) ("a" ,a))
|
| 341 | (package-transitive-inputs c))
|
| 342 | (equal? `(("a" ,a) ("c" ,c) ("b" ,b)) |
| 343 | (package-transitive-inputs d))
|
| 344 | (equal? `(("b" ,b) ("c" ,c) ("a" ,a))
|
| 345 | (package-transitive-inputs e))))) |
| 346 |
|
| 347 | (test-equal "package-transitive-supported-systems"
|
| 348 | '(("x" "y" "z") |
| 349 | ("x" "y") |
| 350 | ("y") |
| 351 | ("y") |
| 352 | ("y")) |
| 353 | |
| 354 | |
| 355 | (let* ((a (dummy-package "a"
|
| 356 | (build-system trivial-build-system)
|
| 357 | (supported-systems '("x" "y" "z"))))
|
| 358 | (b (dummy-package "b"
|
| 359 | (build-system trivial-build-system)
|
| 360 | (supported-systems '("x" "y"))
|
| 361 | (inputs (list a))))
|
| 362 | (c (dummy-package "c"
|
| 363 | (build-system trivial-build-system)
|
| 364 | (supported-systems '("y" "z"))
|
| 365 | (inputs (list b))))
|
| 366 | (d (dummy-package "d"
|
| 367 | (build-system trivial-build-system)
|
| 368 | (supported-systems '("x" "y" "z"))
|
| 369 | (inputs (list b c))))
|
| 370 | (e (dummy-package "e"
|
| 371 | (build-system trivial-build-system)
|
| 372 | (supported-systems '("x" "y" "z"))
|
| 373 | (inputs (list d)))))
|
| 374 | (list (package-transitive-supported-systems a)
|
| 375 | (package-transitive-supported-systems b)
|
| 376 | (package-transitive-supported-systems c)
|
| 377 | (package-transitive-supported-systems d)
|
| 378 | (package-transitive-supported-systems e))))
|
| 379 |
|
| 380 | (test-equal "package-transitive-supported-systems detects cycles"
|
| 381 | '("c" "a" "b" "c")
|
| 382 | (letrec* ((a (dummy-package "a"
|
| 383 | (build-system trivial-build-system)
|
| 384 | (native-inputs (list c))))
|
| 385 | (b (dummy-package "b"
|
| 386 | (build-system trivial-build-system)
|
| 387 | (inputs (list a))))
|
| 388 | (c (dummy-package "c"
|
| 389 | (build-system trivial-build-system)
|
| 390 | (inputs (list b)))))
|
| 391 | (guard (c ((package-cyclic-dependency-error? c)
|
| 392 | (map package-name
|
| 393 | (cons (package-error-package c)
|
| 394 | (package-error-dependency-cycle c)))))
|
| 395 | (package-transitive-supported-systems c))))
|
| 396 |
|
| 397 | (test-assert "package-development-inputs"
|
| 398 | |
| 399 | |
| 400 | (lset<= equal?
|
| 401 | `(("source" ,(package-source hello)) ,@(standard-packages))
|
| 402 | (package-development-inputs hello)))
|
| 403 |
|
| 404 | (test-assert "package-development-inputs, cross-compilation"
|
| 405 | (lset<= equal?
|
| 406 | `(("source" ,(package-source hello))
|
| 407 | ,@(standard-cross-packages "mips64el-linux-gnu" 'host)
|
| 408 | ,@(standard-cross-packages "mips64el-linux-gnu" 'target))
|
| 409 | (package-development-inputs hello #:target "mips64el-linux-gnu")))
|
| 410 |
|
| 411 | (test-assert "package-closure"
|
| 412 | (let-syntax ((dummy-package/no-implicit
|
| 413 | (syntax-rules ()
|
| 414 | ((_ name rest ...)
|
| 415 | (package
|
| 416 | (inherit (dummy-package name rest ...))
|
| 417 | (build-system trivial-build-system))))))
|
| 418 | (let* ((a (dummy-package/no-implicit "a"))
|
| 419 | (b (dummy-package/no-implicit "b"
|
| 420 | (propagated-inputs (list a))))
|
| 421 | (c (dummy-package/no-implicit "c"
|
| 422 | (inputs (list a))))
|
| 423 | (d (dummy-package/no-implicit "d"
|
| 424 | (native-inputs (list b))))
|
| 425 | (e (dummy-package/no-implicit "e"
|
| 426 | (inputs (list c d)))))
|
| 427 | (lset= eq?
|
| 428 | (list a b c d e)
|
| 429 | (package-closure (list e))
|
| 430 | (package-closure (list e d))
|
| 431 | (package-closure (list e c b))))))
|
| 432 |
|
| 433 | (test-equal "origin-actual-file-name"
|
| 434 | "foo-1.tar.gz"
|
| 435 | (let ((o (dummy-origin (uri "http://www.example.com/foo-1.tar.gz"))))
|
| 436 | (origin-actual-file-name o)))
|
| 437 |
|
| 438 | (test-equal "origin-actual-file-name, file-name"
|
| 439 | "foo-1.tar.gz"
|
| 440 | (let ((o (dummy-origin
|
| 441 | (uri "http://www.example.com/tarball")
|
| 442 | (file-name "foo-1.tar.gz"))))
|
| 443 | (origin-actual-file-name o)))
|
| 444 |
|
| 445 | (let* ((o (dummy-origin))
|
| 446 | (u (dummy-origin))
|
| 447 | (i (dummy-origin))
|
| 448 | (j (dummy-origin (patches (list o))))
|
| 449 | (a (dummy-package "a"))
|
| 450 | (b (dummy-package "b" (inputs (list a i))))
|
| 451 | (c (package (inherit b) (source o)))
|
| 452 | (d (dummy-package "d"
|
| 453 | (build-system trivial-build-system)
|
| 454 | (source u) (inputs (list c))))
|
| 455 | (e (dummy-package "e" (source j)))
|
| 456 | (f (package (inherit e) (inputs (list u)))))
|
| 457 | (test-assert "package-direct-sources, no source"
|
| 458 | (null? (package-direct-sources a)))
|
| 459 | (test-equal "package-direct-sources, #f source"
|
| 460 | (list i)
|
| 461 | (package-direct-sources b))
|
| 462 | (test-equal "package-direct-sources, not input source"
|
| 463 | (list u)
|
| 464 | (package-direct-sources d))
|
| 465 | (test-assert "package-direct-sources"
|
| 466 | (let ((s (package-direct-sources c)))
|
| 467 | (and (= (length (pk 's-sources s)) 2)
|
| 468 | (member o s)
|
| 469 | (member i s))))
|
| 470 | (test-assert "package-direct-sources, with patches"
|
| 471 | (let ((s (package-direct-sources e)))
|
| 472 | (and (= (length (pk 's-sources s)) 2)
|
| 473 | (member o s)
|
| 474 | (member j s))))
|
| 475 | (test-assert "package-direct-sources, with patches and inputs"
|
| 476 | (let ((s (package-direct-sources f)))
|
| 477 | (and (= (length (pk 's-sources s)) 3)
|
| 478 | (member o s)
|
| 479 | (member j s)
|
| 480 | (member u s))))
|
| 481 | (test-assert "package-transitive-sources"
|
| 482 | (let ((s (package-transitive-sources d)))
|
| 483 | (and (= (length (pk 'd-sources s)) 3)
|
| 484 | (member o s)
|
| 485 | (member i s)
|
| 486 | (member u s)))))
|
| 487 |
|
| 488 | (test-assert "transitive-input-references"
|
| 489 | (let* ((a (dummy-package "a"))
|
| 490 | (b (dummy-package "b"))
|
| 491 | (c (dummy-package "c"
|
| 492 | (inputs `(("a" ,a)))
|
| 493 | (propagated-inputs `(("boo" ,b)))))
|
| 494 | (d (dummy-package "d"
|
| 495 | (inputs `(("c*" ,c)))))
|
| 496 | (keys (map (match-lambda
|
| 497 | (('assoc-ref 'l key)
|
| 498 | key))
|
| 499 | (pk 'refs (transitive-input-references
|
| 500 | 'l (package-inputs d))))))
|
| 501 | (and (= (length keys) 2)
|
| 502 | (member "c*" keys)
|
| 503 | (member "boo" keys))))
|
| 504 |
|
| 505 | (test-equal "package-transitive-supported-systems, implicit inputs"
|
| 506 | (filter target-linux? %supported-systems)
|
| 507 |
|
| 508 | |
| 509 | |
| 510 | (let ((p (dummy-package "foo"
|
| 511 | (build-system gnu-build-system)
|
| 512 | (supported-systems
|
| 513 | `("does-not-exist" "foobar" ,@%supported-systems)))))
|
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | (parameterize ((%current-system "riscv64-linux"))
|
| 519 | (package-transitive-supported-systems p))))
|
| 520 |
|
| 521 | (test-equal "package-transitive-supported-systems: reduced binary seed, implicit inputs"
|
| 522 | '("x86_64-linux" "i686-linux")
|
| 523 |
|
| 524 | |
| 525 | |
| 526 | (let ((p (dummy-package "foo"
|
| 527 | (build-system gnu-build-system)
|
| 528 | (supported-systems
|
| 529 | `("does-not-exist" "foobar" ,@%supported-systems)))))
|
| 530 | (parameterize ((%current-system "x86_64-linux"))
|
| 531 | (package-transitive-supported-systems p))))
|
| 532 |
|
| 533 | (test-assert "supported-package?"
|
| 534 | (let* ((d (dummy-package "dep"
|
| 535 | (build-system trivial-build-system)
|
| 536 | (supported-systems '("x86_64-linux"))))
|
| 537 | (p (dummy-package "foo"
|
| 538 | (build-system gnu-build-system)
|
| 539 | (inputs (list d))
|
| 540 | (supported-systems '("x86_64-linux" "armhf-linux")))))
|
| 541 | (and (supported-package? p "x86_64-linux")
|
| 542 | (not (supported-package? p "i686-linux"))
|
| 543 | (not (supported-package? p "armhf-linux")))))
|
| 544 |
|
| 545 | (test-assert "supported-package? vs. system-dependent graph"
|
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | (let* ((p0a (dummy-package "foo-arm"
|
| 551 | (build-system trivial-build-system)
|
| 552 | (supported-systems '("armhf-linux"))))
|
| 553 | (p0b (dummy-package "foo-x86_64"
|
| 554 | (build-system trivial-build-system)
|
| 555 | (supported-systems '("x86_64-linux"))))
|
| 556 | (p (dummy-package "bar"
|
| 557 | (build-system trivial-build-system)
|
| 558 | (inputs
|
| 559 | (if (string=? (%current-system) "armhf-linux")
|
| 560 | `(("foo" ,p0a))
|
| 561 | `(("foo" ,p0b)))))))
|
| 562 | (and (supported-package? p "x86_64-linux")
|
| 563 | (supported-package? p "armhf-linux"))))
|
| 564 |
|
| 565 | (test-assert "supported-package? vs. %current-target-system"
|
| 566 | |
| 567 | (parameterize ((%current-target-system "arm-linux-gnueabihf"))
|
| 568 | (let ((p (dummy-package "foo"
|
| 569 | (build-system gnu-build-system)
|
| 570 | (supported-systems '("x86_64-linux" "armhf-linux")))))
|
| 571 | (and (supported-package? p "x86_64-linux")
|
| 572 | (not (supported-package? p "i686-linux"))
|
| 573 | (supported-package? p "armhf-linux")))))
|
| 574 |
|
| 575 | (test-skip (if (not %store) 8 0))
|
| 576 |
|
| 577 | (test-assert "package-source-derivation, file"
|
| 578 | (let* ((file (search-path %load-path "guix.scm"))
|
| 579 | (package (package (inherit (dummy-package "p"))
|
| 580 | (source file)))
|
| 581 | (source (package-source-derivation %store
|
| 582 | (package-source package))))
|
| 583 | (and (store-path? source)
|
| 584 | (valid-path? %store source)
|
| 585 | (equal? (call-with-input-file source get-bytevector-all)
|
| 586 | (call-with-input-file file get-bytevector-all)))))
|
| 587 |
|
| 588 | (test-assert "package-source-derivation, store path"
|
| 589 | (let* ((file (add-to-store %store "guix.scm" #t "sha256"
|
| 590 | (search-path %load-path "guix.scm")))
|
| 591 | (package (package (inherit (dummy-package "p"))
|
| 592 | (source file)))
|
| 593 | (source (package-source-derivation %store
|
| 594 | (package-source package))))
|
| 595 | (string=? file source)))
|
| 596 |
|
| 597 | (test-assert "package-source-derivation, indirect store path"
|
| 598 | (let* ((dir (add-to-store %store "guix-build" #t "sha256"
|
| 599 | (dirname (search-path %load-path
|
| 600 | "guix/build/utils.scm"))))
|
| 601 | (package (package (inherit (dummy-package "p"))
|
| 602 | (source (string-append dir "/utils.scm"))))
|
| 603 | (source (package-source-derivation %store
|
| 604 | (package-source package))))
|
| 605 | (and (direct-store-path? source)
|
| 606 | (string-suffix? "utils.scm" source))))
|
| 607 |
|
| 608 | (test-assert "package-source-derivation, local-file"
|
| 609 | (let* ((file (local-file "../guix/base32.scm"))
|
| 610 | (package (package (inherit (dummy-package "p"))
|
| 611 | (source file)))
|
| 612 | (source (package-source-derivation %store
|
| 613 | (package-source package))))
|
| 614 | (and (store-path? source)
|
| 615 | (string-suffix? "base32.scm" source)
|
| 616 | (valid-path? %store source)
|
| 617 | (equal? (call-with-input-file source get-bytevector-all)
|
| 618 | (call-with-input-file
|
| 619 | (search-path %load-path "guix/base32.scm")
|
| 620 | get-bytevector-all)))))
|
| 621 |
|
| 622 | (test-equal "package-source-derivation, origin, sha512"
|
| 623 | "hello"
|
| 624 | (let* ((bash (bootstrap-binary "bash"))
|
| 625 | (builder (add-text-to-store %store "my-fixed-builder.sh"
|
| 626 | "echo -n hello > $out" '()))
|
| 627 | (method (lambda* (url hash-algo hash #:optional name
|
| 628 | #:rest rest)
|
| 629 | (and (eq? hash-algo 'sha512)
|
| 630 | (raw-derivation name bash (list builder)
|
| 631 | #:sources (list bash builder)
|
| 632 | #:hash hash
|
| 633 | #:hash-algo hash-algo))))
|
| 634 | (source (origin
|
| 635 | (method method)
|
| 636 | (uri "unused://")
|
| 637 | (file-name "origin-sha512")
|
| 638 | (hash (content-hash
|
| 639 | (gcrypt:bytevector-hash (string->utf8 "hello")
|
| 640 | (gcrypt:lookup-hash-algorithm
|
| 641 | 'sha512))
|
| 642 | sha512))))
|
| 643 | (drv (package-source-derivation %store source))
|
| 644 | (output (derivation->output-path drv)))
|
| 645 | (build-derivations %store (list drv))
|
| 646 | (call-with-input-file output get-string-all)))
|
| 647 |
|
| 648 | (test-equal "package-source-derivation, origin, sha3-512"
|
| 649 | "hello, sha3"
|
| 650 | (let* ((bash (bootstrap-binary "bash"))
|
| 651 | (builder (add-text-to-store %store "my-fixed-builder.sh"
|
| 652 | "echo -n hello, sha3 > $out" '()))
|
| 653 | (method (lambda* (url hash-algo hash #:optional name
|
| 654 | #:rest rest)
|
| 655 | (and (eq? hash-algo 'sha3-512)
|
| 656 | (raw-derivation name bash (list builder)
|
| 657 | #:sources (list bash builder)
|
| 658 | #:hash hash
|
| 659 | #:hash-algo hash-algo))))
|
| 660 | (source (origin
|
| 661 | (method method)
|
| 662 | (uri "unused://")
|
| 663 | (file-name "origin-sha3")
|
| 664 | (hash (content-hash
|
| 665 | (gcrypt:bytevector-hash (string->utf8 "hello, sha3")
|
| 666 | (gcrypt:lookup-hash-algorithm
|
| 667 | 'sha3-512))
|
| 668 | sha3-512))))
|
| 669 | (drv (package-source-derivation %store source))
|
| 670 | (output (derivation->output-path drv)))
|
| 671 | (build-derivations %store (list drv))
|
| 672 | (call-with-input-file output get-string-all)))
|
| 673 |
|
| 674 | (test-equal "package-upstream-name*"
|
| 675 | (package-upstream-name* (specification->package "guile-gcrypt"))
|
| 676 | "gcrypt")
|
| 677 |
|
| 678 |
|
| 679 | |
| 680 | |
| 681 | |
| 682 |
|
| 683 | (unless (network-reachable?) (test-skip 1))
|
| 684 | (test-equal "package-source-derivation, snippet"
|
| 685 | "OK"
|
| 686 | (let* ((source (bootstrap-origin
|
| 687 | (origin
|
| 688 | (inherit (bootstrap-guile-origin (%current-system)))
|
| 689 | (patch-inputs
|
| 690 | `(("tar" ,%bootstrap-coreutils&co)
|
| 691 | ("xz" ,%bootstrap-coreutils&co)
|
| 692 | ("patch" ,%bootstrap-coreutils&co)))
|
| 693 | (patch-guile %bootstrap-guile)
|
| 694 | (modules '((guix build utils)))
|
| 695 | (snippet '(begin
|
| 696 | |
| 697 | |
| 698 | |
| 699 | (chmod "." #o777)
|
| 700 | (symlink "guile" "guile-rocks")
|
| 701 | (copy-recursively "../share/guile/2.0/scripts"
|
| 702 | "scripts")
|
| 703 |
|
| 704 | |
| 705 | (chmod ".." #o777))))))
|
| 706 | (package (package (inherit (dummy-package "with-snippet"))
|
| 707 | (source source)
|
| 708 | (build-system trivial-build-system)
|
| 709 | (inputs
|
| 710 | `(("tar" ,(search-bootstrap-binary "tar"
|
| 711 | (%current-system)))
|
| 712 | ("xz" ,(search-bootstrap-binary "xz"
|
| 713 | (%current-system)))))
|
| 714 | (arguments
|
| 715 | `(#:guile ,%bootstrap-guile
|
| 716 | #:modules ((guix build utils))
|
| 717 | #:builder
|
| 718 | (begin
|
| 719 | (use-modules (guix build utils))
|
| 720 | (let ((tar (assoc-ref %build-inputs "tar"))
|
| 721 | (xz (assoc-ref %build-inputs "xz"))
|
| 722 | (source (assoc-ref %build-inputs "source")))
|
| 723 | (invoke tar "xvf" source
|
| 724 | "--use-compress-program" xz)
|
| 725 | (unless (and (string=? "guile" (readlink "bin/guile-rocks"))
|
| 726 | (file-exists? "bin/scripts/compile.scm"))
|
| 727 | (error "the snippet apparently failed"))
|
| 728 | (let ((out (assoc-ref %outputs "out")))
|
| 729 | (call-with-output-file out
|
| 730 | (lambda (p)
|
| 731 | (display "OK" p))))
|
| 732 | #t))))))
|
| 733 | (drv (package-derivation %store package))
|
| 734 | (out (derivation->output-path drv)))
|
| 735 | (and (build-derivations %store (list (pk 'snippet-drv drv)))
|
| 736 | (call-with-input-file out get-string-all))))
|
| 737 |
|
| 738 | |
| 739 | |
| 740 | (define compressors '(("gzip" . "gz")
|
| 741 | ("xz" . "xz")
|
| 742 | ("bzip2" . "bz2")
|
| 743 | (#f . #f)))
|
| 744 |
|
| 745 | (for-each
|
| 746 | (match-lambda
|
| 747 | ((comp . ext)
|
| 748 | (unless (network-reachable?) (test-skip 1))
|
| 749 | (test-equal (string-append "origin->derivation, single file with snippet "
|
| 750 | "(compression: " (if comp comp "None") ")")
|
| 751 | "2 + 2 = 4"
|
| 752 | (let*-values
|
| 753 | (((name) "maths")
|
| 754 | ((compressed-name) (if comp
|
| 755 | (string-append name "." ext)
|
| 756 | name))
|
| 757 | ((file hash) (test-file %store compressed-name "2 + 2 = 5"))
|
| 758 | |
| 759 | ((source) (origin
|
| 760 | (method url-fetch)
|
| 761 | (uri (string-append "file://" file))
|
| 762 | (file-name compressed-name)
|
| 763 | (patch-inputs `(("tar" ,%bootstrap-coreutils&co)
|
| 764 | ("xz" ,%bootstrap-coreutils&co)
|
| 765 | ("bzip2" ,%bootstrap-coreutils&co)
|
| 766 | ("gzip" ,%bootstrap-coreutils&co)))
|
| 767 | (patch-guile %bootstrap-guile)
|
| 768 | (modules '((guix build utils)))
|
| 769 | (snippet `(substitute* ,name
|
| 770 | (("5") "4")))
|
| 771 | (hash (content-hash hash))))
|
| 772 | |
| 773 | ((drv) (run-with-store %store (origin->derivation source)))
|
| 774 | ((out) (derivation->output-path drv)))
|
| 775 | |
| 776 | (and (build-derivations %store (list drv))
|
| 777 | (if (tarball? out)
|
| 778 | (let* ((bin #~(string-append #+%bootstrap-coreutils&co
|
| 779 | "/bin"))
|
| 780 | (f (computed-file
|
| 781 | name
|
| 782 | (with-imported-modules '((guix build utils))
|
| 783 | #~(begin
|
| 784 | (use-modules (guix build utils))
|
| 785 | (setenv "PATH" #+bin)
|
| 786 | (invoke "tar" "xvf" #+out)
|
| 787 | (copy-file #+name #$output)))
|
| 788 | #:guile %bootstrap-guile))
|
| 789 | (drv (run-with-store %store (lower-object f)))
|
| 790 | (_ (build-derivations %store (list drv))))
|
| 791 | (call-with-input-file (derivation->output-path drv)
|
| 792 | get-string-all))
|
| 793 | (call-with-input-file out get-string-all)))))))
|
| 794 | compressors)
|
| 795 |
|
| 796 | (test-assert "return value"
|
| 797 | (let ((drv (package-derivation %store (dummy-package "p"))))
|
| 798 | (and (derivation? drv)
|
| 799 | (file-exists? (derivation-file-name drv)))))
|
| 800 |
|
| 801 | (test-assert "package-derivation, inputs deduplicated"
|
| 802 | (let* ((dep (dummy-package "dep"))
|
| 803 | (p0 (dummy-package "p" (inputs (list dep))))
|
| 804 | (p1 (package (inherit p0)
|
| 805 | (inputs `(("dep" ,(package (inherit dep)))
|
| 806 | ,@(package-inputs p0))))))
|
| 807 | |
| 808 | |
| 809 | |
| 810 | |
| 811 | (string=? (derivation-file-name (package-derivation %store p0))
|
| 812 | (derivation-file-name (package-derivation %store p1)))))
|
| 813 |
|
| 814 | (test-assert "package-derivation, different system"
|
| 815 | |
| 816 | (let* ((system (if (string=? (%current-system) "x86_64-linux")
|
| 817 | "aarch64-linux"
|
| 818 | "x86_64-linux"))
|
| 819 | (drv (package-derivation %store (dummy-package "p")
|
| 820 | system #:graft? #f)))
|
| 821 | (define right-system?
|
| 822 | (mlambdaq (drv)
|
| 823 | (and (string=? (derivation-system drv) system)
|
| 824 | (every (compose right-system? derivation-input-derivation)
|
| 825 | (derivation-inputs drv)))))
|
| 826 |
|
| 827 | (right-system? drv)))
|
| 828 |
|
| 829 | (test-assert "package-output"
|
| 830 | (let* ((package (dummy-package "p"))
|
| 831 | (drv (package-derivation %store package)))
|
| 832 | (and (derivation? drv)
|
| 833 | (string=? (derivation->output-path drv)
|
| 834 | (package-output %store package "out")))))
|
| 835 |
|
| 836 | (test-equal "patch not found yields a run-time error"
|
| 837 | '("~a: patch not found\n" "does-not-exist.patch")
|
| 838 | (guard (c ((formatted-message? c)
|
| 839 | (cons (formatted-message-string c)
|
| 840 | (formatted-message-arguments c))))
|
| 841 | (let ((p (package
|
| 842 | (inherit (dummy-package "p"))
|
| 843 | (source (origin
|
| 844 | (method (const #f))
|
| 845 | (uri "http://whatever")
|
| 846 | (patches
|
| 847 | (list (search-patch "does-not-exist.patch")))
|
| 848 | (sha256
|
| 849 | (base32
|
| 850 | "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks4")))))))
|
| 851 | (package-derivation %store p)
|
| 852 | #f)))
|
| 853 |
|
| 854 | (let ((dummy (dummy-package "foo" (inputs `(("x" ,(current-module)))))))
|
| 855 | (test-equal "&package-input-error"
|
| 856 | (list dummy `("x" ,(current-module)))
|
| 857 | (guard (c ((package-input-error? c)
|
| 858 | (list (package-error-package c)
|
| 859 | (package-error-invalid-input c))))
|
| 860 | (package-derivation %store dummy))))
|
| 861 |
|
| 862 | (test-assert "reference to non-existent output"
|
| 863 | |
| 864 | (parameterize ((%graft? #f))
|
| 865 | (let* ((dep (dummy-package "dep"))
|
| 866 | (p (dummy-package "p"
|
| 867 | (inputs (list `(,dep "non-existent"))))))
|
| 868 | (guard (c ((derivation-missing-output-error? c)
|
| 869 | (and (string=? (derivation-missing-output c) "non-existent")
|
| 870 | (equal? (package-derivation %store dep)
|
| 871 | (derivation-error-derivation c)))))
|
| 872 | (package-derivation %store p)))))
|
| 873 |
|
| 874 | (test-assert "trivial"
|
| 875 | (let* ((p (package (inherit (dummy-package "trivial"))
|
| 876 | (build-system trivial-build-system)
|
| 877 | (source #f)
|
| 878 | (arguments
|
| 879 | `(#:guile ,%bootstrap-guile
|
| 880 | #:builder
|
| 881 | (begin
|
| 882 | (mkdir %output)
|
| 883 | (call-with-output-file (string-append %output "/test")
|
| 884 | (lambda (p)
|
| 885 | (display '(hello guix) p)))
|
| 886 | #t)))))
|
| 887 | (d (package-derivation %store p)))
|
| 888 | (and (build-derivations %store (list d))
|
| 889 | (let ((p (pk 'drv d (derivation->output-path d))))
|
| 890 | (equal? '(hello guix)
|
| 891 | (call-with-input-file (string-append p "/test") read))))))
|
| 892 |
|
| 893 | (test-assert "trivial with local file as input"
|
| 894 | (let* ((i (search-path %load-path "ice-9/boot-9.scm"))
|
| 895 | (p (package (inherit (dummy-package "trivial-with-input-file"))
|
| 896 | (build-system trivial-build-system)
|
| 897 | (source #f)
|
| 898 | (arguments
|
| 899 | `(#:guile ,%bootstrap-guile
|
| 900 | #:builder (begin
|
| 901 | (copy-file (assoc-ref %build-inputs "input")
|
| 902 | %output)
|
| 903 | #t)))
|
| 904 | (inputs `(("input" ,i)))))
|
| 905 | (d (package-derivation %store p)))
|
| 906 | (and (build-derivations %store (list d))
|
| 907 | (let ((p (pk 'drv d (derivation->output-path d))))
|
| 908 | (equal? (call-with-input-file p get-bytevector-all)
|
| 909 | (call-with-input-file i get-bytevector-all))))))
|
| 910 |
|
| 911 | (test-assert "trivial with source"
|
| 912 | (let* ((i (search-path %load-path "ice-9/boot-9.scm"))
|
| 913 | (p (package (inherit (dummy-package "trivial-with-source"))
|
| 914 | (build-system trivial-build-system)
|
| 915 | (source i)
|
| 916 | (arguments
|
| 917 | `(#:guile ,%bootstrap-guile
|
| 918 | #:builder (begin
|
| 919 | (copy-file (assoc-ref %build-inputs "source")
|
| 920 | %output)
|
| 921 | #t)))))
|
| 922 | (d (package-derivation %store p)))
|
| 923 | (and (build-derivations %store (list d))
|
| 924 | (let ((p (derivation->output-path d)))
|
| 925 | (equal? (call-with-input-file p get-bytevector-all)
|
| 926 | (call-with-input-file i get-bytevector-all))))))
|
| 927 |
|
| 928 | (test-assert "trivial with system-dependent input"
|
| 929 | (let* ((p (package (inherit (dummy-package "trivial-system-dependent-input"))
|
| 930 | (build-system trivial-build-system)
|
| 931 | (source #f)
|
| 932 | (arguments
|
| 933 | `(#:guile ,%bootstrap-guile
|
| 934 | #:modules ((guix build utils))
|
| 935 | #:builder
|
| 936 | (begin
|
| 937 | (use-modules (guix build utils))
|
| 938 | (let ((out (assoc-ref %outputs "out"))
|
| 939 | (bash (assoc-ref %build-inputs "bash")))
|
| 940 | (invoke bash "-c"
|
| 941 | (format #f "echo hello > ~a" out))))))
|
| 942 | (inputs `(("bash" ,(search-bootstrap-binary "bash"
|
| 943 | (%current-system)))))))
|
| 944 | (d (package-derivation %store p)))
|
| 945 | (and (build-derivations %store (list d))
|
| 946 | (let ((p (pk 'drv d (derivation->output-path d))))
|
| 947 | (eq? 'hello (call-with-input-file p read))))))
|
| 948 |
|
| 949 | (test-assert "trivial with #:allowed-references"
|
| 950 | (let* ((p (package
|
| 951 | (inherit (dummy-package "trivial"))
|
| 952 | (build-system trivial-build-system)
|
| 953 | (arguments
|
| 954 | `(#:guile ,%bootstrap-guile
|
| 955 | #:allowed-references (,%bootstrap-guile)
|
| 956 | #:builder
|
| 957 | (begin
|
| 958 | (mkdir %output)
|
| 959 | |
| 960 | |
| 961 | (symlink %output (string-append %output "/self"))
|
| 962 | #t)))))
|
| 963 | (d (package-derivation %store p)))
|
| 964 | (guard (c ((store-protocol-error? c) #t))
|
| 965 | (build-derivations %store (list d))
|
| 966 | #f)))
|
| 967 |
|
| 968 | (test-assert "trivial with #:allowed-references + grafts"
|
| 969 | (let* ((g (package
|
| 970 | (inherit %bootstrap-guile)
|
| 971 | (replacement (package
|
| 972 | (inherit %bootstrap-guile)
|
| 973 | (version "9.9")))))
|
| 974 | (p (package
|
| 975 | (inherit (dummy-package "trivial"))
|
| 976 | (build-system trivial-build-system)
|
| 977 | (inputs (list g))
|
| 978 | (arguments
|
| 979 | `(#:guile ,g
|
| 980 | #:allowed-references (,g)
|
| 981 | #:builder (mkdir %output)))))
|
| 982 | (d0 (package-derivation %store p #:graft? #f))
|
| 983 | (d1 (parameterize ((%graft? #t))
|
| 984 | (package-derivation %store p #:graft? #t))))
|
| 985 | |
| 986 | |
| 987 | |
| 988 | (string=? (derivation-file-name d1) (derivation-file-name d0))))
|
| 989 |
|
| 990 | (test-assert "search paths"
|
| 991 | (let* ((p (make-prompt-tag "return-search-paths"))
|
| 992 | (t (make-parameter "guile-0"))
|
| 993 | (s (build-system
|
| 994 | (name 'raw)
|
| 995 | (description "Raw build system with direct store access")
|
| 996 | (lower (lambda* (name #:key source inputs system target
|
| 997 | #:allow-other-keys)
|
| 998 | (bag
|
| 999 | (name name)
|
| 1000 | (system system) (target target)
|
| 1001 | (build-inputs inputs)
|
| 1002 | (build
|
| 1003 | (lambda* (name inputs
|
| 1004 | #:key outputs system search-paths)
|
| 1005 | (if (string=? name (t))
|
| 1006 | (abort-to-prompt p search-paths)
|
| 1007 | (gexp->derivation name
|
| 1008 | #~(mkdir #$output))))))))))
|
| 1009 | (x (list (search-path-specification
|
| 1010 | (variable "GUILE_LOAD_PATH")
|
| 1011 | (files '("share/guile/site/2.0")))
|
| 1012 | (search-path-specification
|
| 1013 | (variable "GUILE_LOAD_COMPILED_PATH")
|
| 1014 | (files '("share/guile/site/2.0")))))
|
| 1015 | (a (package (inherit (dummy-package "guile"))
|
| 1016 | (build-system s)
|
| 1017 | (native-search-paths x)))
|
| 1018 | (b (package (inherit (dummy-package "guile-foo"))
|
| 1019 | (build-system s)
|
| 1020 | (inputs `(("guile" ,a)))))
|
| 1021 | (c (package (inherit (dummy-package "guile-bar"))
|
| 1022 | (build-system s)
|
| 1023 | (inputs `(("guile" ,a)
|
| 1024 | ("guile-foo" ,b))))))
|
| 1025 | (let-syntax ((collect (syntax-rules ()
|
| 1026 | ((_ body ...)
|
| 1027 | (call-with-prompt p
|
| 1028 | (lambda ()
|
| 1029 | body ...)
|
| 1030 | (lambda (k search-paths)
|
| 1031 | search-paths))))))
|
| 1032 | (and (null? (collect (package-derivation %store a)))
|
| 1033 | (parameterize ((t "guile-foo-0"))
|
| 1034 | (equal? x (collect (package-derivation %store b))))
|
| 1035 | (parameterize ((t "guile-bar-0"))
|
| 1036 | (equal? x (collect (package-derivation %store c))))))))
|
| 1037 |
|
| 1038 | (test-assert "package-transitive-native-search-paths"
|
| 1039 | (let* ((sp (lambda (name)
|
| 1040 | (list (search-path-specification
|
| 1041 | (variable name)
|
| 1042 | (files '("foo/bar"))))))
|
| 1043 | (p0 (dummy-package "p0" (native-search-paths (sp "PATH0"))))
|
| 1044 | (p1 (dummy-package "p1" (native-search-paths (sp "PATH1"))))
|
| 1045 | (p2 (dummy-package "p2"
|
| 1046 | (native-search-paths (sp "PATH2"))
|
| 1047 | (inputs (list p0))
|
| 1048 | (propagated-inputs (list p1))))
|
| 1049 | (p3 (dummy-package "p3"
|
| 1050 | (native-search-paths (sp "PATH3"))
|
| 1051 | (native-inputs (list p0))
|
| 1052 | (propagated-inputs (list p2)))))
|
| 1053 | (lset= string=?
|
| 1054 | '("PATH1" "PATH2" "PATH3")
|
| 1055 | (map search-path-specification-variable
|
| 1056 | (package-transitive-native-search-paths p3)))))
|
| 1057 |
|
| 1058 | (test-assert "package-cross-derivation"
|
| 1059 | (let ((drv (package-cross-derivation %store (dummy-package "p")
|
| 1060 | "mips64el-linux-gnu")))
|
| 1061 | (and (derivation? drv)
|
| 1062 | (file-exists? (derivation-file-name drv)))))
|
| 1063 |
|
| 1064 | (test-assert "package-cross-derivation, trivial-build-system"
|
| 1065 | (let ((p (package (inherit (dummy-package "p"))
|
| 1066 | (build-system trivial-build-system)
|
| 1067 | (arguments '(#:builder (exit 1))))))
|
| 1068 | (let ((drv (package-cross-derivation %store p "mips64el-linux-gnu")))
|
| 1069 | (derivation? drv))))
|
| 1070 |
|
| 1071 | (test-assert "package-cross-derivation, no cross builder"
|
| 1072 | (let* ((b (build-system (inherit trivial-build-system)
|
| 1073 | (lower (const #f))))
|
| 1074 | (p (package (inherit (dummy-package "p"))
|
| 1075 | (build-system b))))
|
| 1076 | (guard (c ((package-cross-build-system-error? c)
|
| 1077 | (eq? (package-error-package c) p)))
|
| 1078 | (package-cross-derivation %store p "mips64el-linux-gnu")
|
| 1079 | #f)))
|
| 1080 |
|
| 1081 | |
| 1082 | |
| 1083 | |
| 1084 |
|
| 1085 | |
| 1086 | |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 |
|
| 1091 | |
| 1092 | |
| 1093 | |
| 1094 | |
| 1095 | |
| 1096 | |
| 1097 | |
| 1098 |
|
| 1099 | (test-assert "package-grafts, indirect grafts"
|
| 1100 | (let* ((new (dummy-package "dep"
|
| 1101 | (arguments '(#:implicit-inputs? #f))))
|
| 1102 | (dep (package (inherit new) (version "0.0")))
|
| 1103 | (dep* (package (inherit dep) (replacement new)))
|
| 1104 | (dummy (dummy-package "dummy"
|
| 1105 | (arguments '(#:implicit-inputs? #f))
|
| 1106 | (inputs (list dep*)))))
|
| 1107 | (match (package-grafts %store dummy)
|
| 1108 | ((graft)
|
| 1109 | (and (eq? (graft-origin graft)
|
| 1110 | (package-derivation %store dep))
|
| 1111 | (eq? (run-with-store %store
|
| 1112 | (lower-object (graft-replacement graft)))
|
| 1113 | (package-derivation %store new)))))))
|
| 1114 |
|
| 1115 | (test-assert "package-grafts, indirect grafts, #:system argument"
|
| 1116 | (let* ((system (if (string=? (%current-system) "riscv64-linux")
|
| 1117 | "x86_64-linux"
|
| 1118 | "riscv64-linux"))
|
| 1119 | (new (dummy-package "dep"
|
| 1120 | (arguments `(#:implicit-inputs? #f
|
| 1121 | #:system ,system))))
|
| 1122 | (dep (package (inherit new) (version "0.0")))
|
| 1123 | (dep* (package (inherit dep) (replacement new)))
|
| 1124 | (dummy (dummy-package "dummy"
|
| 1125 | (arguments '(#:implicit-inputs? #f))
|
| 1126 | (inputs (list dep*)))))
|
| 1127 | (match (package-grafts %store dummy)
|
| 1128 | ((graft)
|
| 1129 | (and (eq? (graft-origin graft)
|
| 1130 | (package-derivation %store dep system))
|
| 1131 | (eq? (run-with-store %store
|
| 1132 | (lower-object (graft-replacement graft)))
|
| 1133 | (package-derivation %store new)))))))
|
| 1134 |
|
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | |
| 1153 | |
| 1154 |
|
| 1155 | (test-assert "package-grafts, indirect grafts, propagated inputs"
|
| 1156 | (let* ((new (dummy-package "dep"
|
| 1157 | (arguments '(#:implicit-inputs? #f))))
|
| 1158 | (dep (package (inherit new) (version "0.0")))
|
| 1159 | (dep* (package (inherit dep) (replacement new)))
|
| 1160 | (prop (dummy-package "propagated"
|
| 1161 | (propagated-inputs (list dep*))
|
| 1162 | (arguments '(#:implicit-inputs? #f))))
|
| 1163 | (dummy (dummy-package "dummy"
|
| 1164 | (arguments '(#:implicit-inputs? #f))
|
| 1165 | (inputs (list prop)))))
|
| 1166 | (match (package-grafts %store dummy)
|
| 1167 | ((graft)
|
| 1168 | (and (eq? (graft-origin graft)
|
| 1169 | (package-derivation %store dep))
|
| 1170 | (eq? (run-with-store %store
|
| 1171 | (lower-object (graft-replacement graft)))
|
| 1172 | (package-derivation %store new)))))))
|
| 1173 |
|
| 1174 | (test-assert "package-grafts, same replacement twice"
|
| 1175 | (let* ((new (dummy-package "dep"
|
| 1176 | (version "1")
|
| 1177 | (arguments '(#:implicit-inputs? #f))))
|
| 1178 | (dep (package (inherit new) (version "0") (replacement new)))
|
| 1179 | (p1 (dummy-package "intermediate1"
|
| 1180 | (arguments '(#:implicit-inputs? #f))
|
| 1181 | (inputs (list dep))))
|
| 1182 | (p2 (dummy-package "intermediate2"
|
| 1183 | (arguments '(#:implicit-inputs? #f))
|
| 1184 | |
| 1185 | |
| 1186 | |
| 1187 | (inputs (list (package (inherit dep))))))
|
| 1188 | (p3 (dummy-package "final"
|
| 1189 | (arguments '(#:implicit-inputs? #f))
|
| 1190 | (inputs (list p1 p2)))))
|
| 1191 | (match (package-grafts %store p3)
|
| 1192 | ((graft)
|
| 1193 | (and (eq? (graft-origin graft)
|
| 1194 | (package-derivation %store
|
| 1195 | (package (inherit dep)
|
| 1196 | (replacement #f))))
|
| 1197 | (eq? (run-with-store %store
|
| 1198 | (lower-object (graft-replacement graft)))
|
| 1199 | (package-derivation %store new)))))))
|
| 1200 |
|
| 1201 | (test-assert "package-grafts, dependency on several outputs"
|
| 1202 | |
| 1203 | (letrec* ((p0 (dummy-package "p0"
|
| 1204 | (version "1.0")
|
| 1205 | (replacement p0*)
|
| 1206 | (arguments '(#:implicit-inputs? #f))
|
| 1207 | (outputs '("out" "lib"))))
|
| 1208 | (p0* (package (inherit p0) (version "1.1")))
|
| 1209 | (p1 (dummy-package "p1"
|
| 1210 | (arguments '(#:implicit-inputs? #f))
|
| 1211 | (inputs (list p0 `(,p0 "lib"))))))
|
| 1212 | (match (sort (package-grafts %store p1)
|
| 1213 | (lambda (graft1 graft2)
|
| 1214 | (string<? (graft-origin-output graft1)
|
| 1215 | (graft-origin-output graft2))))
|
| 1216 | ((graft1 graft2)
|
| 1217 | (and (eq? (graft-origin graft1) (graft-origin graft2)
|
| 1218 | (package-derivation %store p0))
|
| 1219 | (eq? (run-with-store %store
|
| 1220 | (lower-object (graft-replacement graft1)))
|
| 1221 | (run-with-store %store
|
| 1222 | (lower-object (graft-replacement graft2)))
|
| 1223 | (package-derivation %store p0*))
|
| 1224 | (string=? "lib"
|
| 1225 | (graft-origin-output graft1)
|
| 1226 | (graft-replacement-output graft1))
|
| 1227 | (string=? "out"
|
| 1228 | (graft-origin-output graft2)
|
| 1229 | (graft-replacement-output graft2)))))))
|
| 1230 |
|
| 1231 | (test-assert "replacement also grafted"
|
| 1232 | |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | (let* ((p1r (dummy-package "P1"
|
| 1249 | (build-system trivial-build-system)
|
| 1250 | (arguments
|
| 1251 | `(#:guile ,%bootstrap-guile
|
| 1252 | #:builder (let ((out (assoc-ref %outputs "out")))
|
| 1253 | (mkdir out)
|
| 1254 | (call-with-output-file
|
| 1255 | (string-append out "/replacement")
|
| 1256 | (const #t)))))))
|
| 1257 | (p1 (package
|
| 1258 | (inherit p1r) (name "p1") (replacement p1r)
|
| 1259 | (arguments
|
| 1260 | `(#:guile ,%bootstrap-guile
|
| 1261 | #:builder (begin
|
| 1262 | (mkdir (assoc-ref %outputs "out"))
|
| 1263 | #t)))))
|
| 1264 | (p2r (dummy-package "P2"
|
| 1265 | (build-system trivial-build-system)
|
| 1266 | (inputs (list p1))
|
| 1267 | (arguments
|
| 1268 | `(#:guile ,%bootstrap-guile
|
| 1269 | #:builder (let ((out (assoc-ref %outputs "out")))
|
| 1270 | (mkdir out)
|
| 1271 | (chdir out)
|
| 1272 | (symlink (assoc-ref %build-inputs "p1") "p1")
|
| 1273 | (call-with-output-file (string-append out "/replacement")
|
| 1274 | (const #t)))))))
|
| 1275 | (p2 (package
|
| 1276 | (inherit p2r) (name "p2") (replacement p2r)
|
| 1277 | (arguments
|
| 1278 | `(#:guile ,%bootstrap-guile
|
| 1279 | #:builder (let ((out (assoc-ref %outputs "out")))
|
| 1280 | (mkdir out)
|
| 1281 | (chdir out)
|
| 1282 | (symlink (assoc-ref %build-inputs "p1")
|
| 1283 | "p1")
|
| 1284 | #t)))))
|
| 1285 | (p3 (dummy-package "p3"
|
| 1286 | (build-system trivial-build-system)
|
| 1287 | (inputs (list p2))
|
| 1288 | (arguments
|
| 1289 | `(#:guile ,%bootstrap-guile
|
| 1290 | #:builder (let ((out (assoc-ref %outputs "out")))
|
| 1291 | (mkdir out)
|
| 1292 | (chdir out)
|
| 1293 | (symlink (assoc-ref %build-inputs "p2")
|
| 1294 | "p2")
|
| 1295 | #t))))))
|
| 1296 | (match (package-grafts %store p3)
|
| 1297 | ((graft1 graft2)
|
| 1298 | (and (eq? (graft-origin graft1)
|
| 1299 | (package-derivation %store p1 #:graft? #f))
|
| 1300 | (eq? (run-with-store %store
|
| 1301 | (lower-object (graft-replacement graft1)))
|
| 1302 | (package-derivation %store p1r #:graft? #t))
|
| 1303 | (eq? (graft-origin graft2)
|
| 1304 | (package-derivation %store p2 #:graft? #f))
|
| 1305 | |
| 1306 | |
| 1307 | (eq? (parameterize ((%graft? #t))
|
| 1308 | (run-with-store %store
|
| 1309 | (lower-object (graft-replacement graft2))))
|
| 1310 | (package-derivation %store p2r #:graft? #t)))))))
|
| 1311 |
|
| 1312 | |
| 1313 | |
| 1314 | |
| 1315 | |
| 1316 | |
| 1317 | |
| 1318 | |
| 1319 | |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | |
| 1325 | |
| 1326 | |
| 1327 | |
| 1328 | |
| 1329 | |
| 1330 |
|
| 1331 | |
| 1332 | |
| 1333 |
|
| 1334 | (test-equal "package->bag"
|
| 1335 | (parameterize ((%current-system "foo86-hurd"))
|
| 1336 | `("foo86-hurd" #f (,(package-source gnu-make))
|
| 1337 | (,(canonical-package glibc)) (,(canonical-package coreutils))))
|
| 1338 | (let ((bag (package->bag gnu-make "foo86-hurd")))
|
| 1339 | (list (bag-system bag) (bag-target bag)
|
| 1340 | (assoc-ref (bag-build-inputs bag) "source")
|
| 1341 | (assoc-ref (bag-build-inputs bag) "libc")
|
| 1342 | (assoc-ref (bag-build-inputs bag) "coreutils"))))
|
| 1343 |
|
| 1344 | (test-assert "package->bag, sensitivity to %current-target-system"
|
| 1345 | |
| 1346 | (let* ((lower (lambda* (name #:key system target inputs native-inputs
|
| 1347 | #:allow-other-keys)
|
| 1348 | (and (not target)
|
| 1349 | (bag (name name) (system system) (target target)
|
| 1350 | (build-inputs native-inputs)
|
| 1351 | (host-inputs inputs)
|
| 1352 | (build (lambda* (name inputs
|
| 1353 | #:key system target
|
| 1354 | #:allow-other-keys)
|
| 1355 | (gexp->derivation "foo"
|
| 1356 | #~(mkdir #$output))))))))
|
| 1357 | (bs (build-system
|
| 1358 | (name 'build-system-without-cross-compilation)
|
| 1359 | (description "Does not support cross compilation.")
|
| 1360 | (lower lower)))
|
| 1361 | (dep (dummy-package "dep" (build-system bs)))
|
| 1362 | (pkg (dummy-package "example"
|
| 1363 | (native-inputs (list dep))))
|
| 1364 | (do-not-build (lambda (continue store lst . _) lst)))
|
| 1365 | (equal? (with-build-handler do-not-build
|
| 1366 | (parameterize ((%current-target-system "powerpc64le-linux-gnu")
|
| 1367 | (%graft? #t))
|
| 1368 | (package-cross-derivation %store pkg
|
| 1369 | (%current-target-system)
|
| 1370 | #:graft? #t)))
|
| 1371 | (with-build-handler do-not-build
|
| 1372 | (package-cross-derivation %store
|
| 1373 | (package (inherit pkg))
|
| 1374 | "powerpc64le-linux-gnu"
|
| 1375 | #:graft? #t)))))
|
| 1376 |
|
| 1377 | (test-equal "package->bag, cross-compilation"
|
| 1378 | `(,(%current-system) "foo86-hurd"
|
| 1379 | (,(package-source gnu-make))
|
| 1380 | (,(canonical-package glibc)) (,(canonical-package coreutils)))
|
| 1381 | (let ((bag (package->bag gnu-make (%current-system) "foo86-hurd")))
|
| 1382 | (list (bag-system bag) (bag-target bag)
|
| 1383 | (assoc-ref (bag-build-inputs bag) "source")
|
| 1384 | (assoc-ref (bag-build-inputs bag) "libc")
|
| 1385 | (assoc-ref (bag-build-inputs bag) "coreutils"))))
|
| 1386 |
|
| 1387 | (test-assert "package->bag, propagated inputs"
|
| 1388 | (let* ((dep (dummy-package "dep"))
|
| 1389 | (prop (dummy-package "prop"
|
| 1390 | (propagated-inputs (list dep))))
|
| 1391 | (dummy (dummy-package "dummy"
|
| 1392 | (inputs (list prop))))
|
| 1393 | (inputs (bag-transitive-inputs (package->bag dummy #:graft? #f))))
|
| 1394 | (match (assoc "dep" inputs)
|
| 1395 | (("dep" package)
|
| 1396 | (eq? package dep)))))
|
| 1397 |
|
| 1398 | (test-assert "package->bag, sensitivity to %current-system"
|
| 1399 | (let* ((dep (dummy-package "dep"
|
| 1400 | (propagated-inputs (if (string=? (%current-system)
|
| 1401 | "i586-gnu")
|
| 1402 | `(("libxml2" ,libxml2))
|
| 1403 | '()))))
|
| 1404 | (pkg (dummy-package "foo"
|
| 1405 | (native-inputs (list dep))))
|
| 1406 | (bag (package->bag pkg (%current-system) "i586-gnu")))
|
| 1407 | (equal? (parameterize ((%current-system "x86_64-linux"))
|
| 1408 | (bag-transitive-inputs bag))
|
| 1409 | (parameterize ((%current-system "i586-gnu"))
|
| 1410 | (bag-transitive-inputs bag)))))
|
| 1411 |
|
| 1412 | (test-assert "package->bag, sensitivity to %current-target-system"
|
| 1413 | (let* ((dep (dummy-package "dep"
|
| 1414 | (propagated-inputs (if (%current-target-system)
|
| 1415 | `(("libxml2" ,libxml2))
|
| 1416 | '()))))
|
| 1417 | (pkg (dummy-package "foo"
|
| 1418 | (native-inputs (list dep))))
|
| 1419 | (bag (package->bag pkg (%current-system) "foo86-hurd")))
|
| 1420 | (equal? (parameterize ((%current-target-system "foo64-gnu"))
|
| 1421 | (bag-transitive-inputs bag))
|
| 1422 | (parameterize ((%current-target-system #f))
|
| 1423 | (bag-transitive-inputs bag)))))
|
| 1424 |
|
| 1425 | (test-assertm "bag->derivation"
|
| 1426 | (parameterize ((%graft? #f))
|
| 1427 | (let ((bag (package->bag gnu-make))
|
| 1428 | (drv (package-derivation %store gnu-make)))
|
| 1429 | (parameterize ((%current-system "foox86-hurd")) |
| 1430 | (mlet %store-monad ((bag-drv (bag->derivation bag)))
|
| 1431 | (return (equal? drv bag-drv)))))))
|
| 1432 |
|
| 1433 | (test-assert "bag->derivation, cross-compilation"
|
| 1434 | (parameterize ((%graft? #f))
|
| 1435 | (let* ((target "mips64el-linux-gnu")
|
| 1436 | (bag (package->bag gnu-make (%current-system) target))
|
| 1437 | (drv (package-cross-derivation %store gnu-make target)))
|
| 1438 | (parameterize ((%current-system "foox86-hurd") |
| 1439 | (%current-target-system "foo64-linux-gnu"))
|
| 1440 | (mlet %store-monad ((bag-drv (bag->derivation bag)))
|
| 1441 | (return (equal? drv bag-drv)))))))
|
| 1442 |
|
| 1443 | (when (or (not (network-reachable?)) (shebang-too-long?))
|
| 1444 | (test-skip 1))
|
| 1445 | (test-assert "GNU Make, bootstrap"
|
| 1446 | |
| 1447 | |
| 1448 | (let ((gnu-make gnu-make-for-tests))
|
| 1449 | (and (package? gnu-make)
|
| 1450 | (or (location? (package-location gnu-make))
|
| 1451 | (not (package-location gnu-make)))
|
| 1452 | (let* ((drv (package-derivation %store gnu-make))
|
| 1453 | (out (derivation->output-path drv)))
|
| 1454 | (and (build-derivations %store (list drv))
|
| 1455 | (file-exists? (string-append out "/bin/make")))))))
|
| 1456 |
|
| 1457 | (test-equal "package-mapping"
|
| 1458 | 42
|
| 1459 | (let* ((dep (dummy-package "chbouib"
|
| 1460 | (native-inputs `(("x" ,grep)))))
|
| 1461 | (p0 (dummy-package "example"
|
| 1462 | (source 77)
|
| 1463 | (inputs `(("foo" ,coreutils)
|
| 1464 | ("bar" ,grep)
|
| 1465 | ("baz" ,dep)))))
|
| 1466 | (transform (lambda (p)
|
| 1467 | (package (inherit p) (source 42))))
|
| 1468 | (rewrite (package-mapping transform))
|
| 1469 | (p1 (rewrite p0))
|
| 1470 | (bag0 (package->bag p0))
|
| 1471 | (bag1 (package->bag p1)))
|
| 1472 | (and (eq? p1 (rewrite p0))
|
| 1473 | (eqv? 42 (package-source p1))
|
| 1474 |
|
| 1475 | |
| 1476 | |
| 1477 | (equal? (drop (bag-direct-inputs bag0) 4)
|
| 1478 | (drop (bag-direct-inputs bag1) 4))
|
| 1479 |
|
| 1480 | (match (package-inputs p1)
|
| 1481 | ((("foo" dep1) ("bar" dep2) ("baz" dep3))
|
| 1482 | (and (eq? dep1 (rewrite coreutils)) |
| 1483 | (eq? dep2 (rewrite grep))
|
| 1484 | (eq? dep3 (rewrite dep))
|
| 1485 | (eqv? 42
|
| 1486 | (package-source dep1) (package-source dep2)
|
| 1487 | (package-source dep3))
|
| 1488 | (match (package-native-inputs dep3)
|
| 1489 | ((("x" dep))
|
| 1490 | (and (eq? dep (rewrite grep))
|
| 1491 | (package-source dep))))))))))
|
| 1492 |
|
| 1493 | (test-equal "package-mapping, deep"
|
| 1494 | '(42)
|
| 1495 | (let* ((p0 (dummy-package "example"
|
| 1496 | (inputs `(("foo" ,coreutils)
|
| 1497 | ("bar" ,grep)))))
|
| 1498 | (transform (lambda (p)
|
| 1499 | (package (inherit p) (source 42))))
|
| 1500 | (rewrite (package-mapping transform #:deep? #t))
|
| 1501 | (p1 (rewrite p0))
|
| 1502 | (bag (package->bag p1)))
|
| 1503 | (and (eq? p1 (rewrite p0))
|
| 1504 | (match (bag-direct-inputs bag)
|
| 1505 | ((("source" 42) ("foo" dep1) ("bar" dep2) rest ..1)
|
| 1506 | (and (eq? dep1 (rewrite coreutils)) |
| 1507 | (eq? dep2 (rewrite grep))
|
| 1508 | (= 42 (package-source dep1))
|
| 1509 | (= 42 (package-source dep2))
|
| 1510 |
|
| 1511 | |
| 1512 | (delete-duplicates
|
| 1513 | (map (match-lambda
|
| 1514 | ((_ package . _)
|
| 1515 | (package-source package)))
|
| 1516 | rest))))))))
|
| 1517 |
|
| 1518 | (test-assert "package-input-rewriting"
|
| 1519 | (let* ((dep (dummy-package "chbouib"
|
| 1520 | (native-inputs `(("x" ,grep)))))
|
| 1521 | (p0 (dummy-package "example"
|
| 1522 | (inputs `(("foo" ,coreutils)
|
| 1523 | ("bar" ,grep)
|
| 1524 | ("baz" ,dep)))))
|
| 1525 | (rewrite (package-input-rewriting `((,coreutils . ,sed)
|
| 1526 | (,grep . ,findutils))
|
| 1527 | (cut string-append "r-" <>)
|
| 1528 | #:deep? #f))
|
| 1529 | (p1 (rewrite p0))
|
| 1530 | (p2 (rewrite p0)))
|
| 1531 | (and (not (eq? p1 p0))
|
| 1532 | (eq? p1 p2) |
| 1533 | (string=? "r-example" (package-name p1))
|
| 1534 | (match (package-inputs p1)
|
| 1535 | ((("foo" dep1) ("bar" dep2) ("baz" dep3))
|
| 1536 | (and (eq? dep1 sed)
|
| 1537 | (eq? dep2 findutils)
|
| 1538 | (string=? (package-name dep3) "r-chbouib")
|
| 1539 | (eq? dep3 (rewrite dep)) |
| 1540 | (match (package-native-inputs dep3)
|
| 1541 | ((("x" dep))
|
| 1542 | (eq? dep findutils))))))
|
| 1543 |
|
| 1544 | |
| 1545 | (equal? (drop (bag-direct-inputs (package->bag p1)) 3)
|
| 1546 | (drop (bag-direct-inputs (package->bag p0)) 3)))))
|
| 1547 |
|
| 1548 | (test-eq "package-input-rewriting, deep"
|
| 1549 | (derivation-file-name (package-derivation %store sed))
|
| 1550 | (let* ((p0 (dummy-package "chbouib"
|
| 1551 | (build-system pyproject-build-system)
|
| 1552 | (arguments (list #:python python))))
|
| 1553 | (rewrite (package-input-rewriting `((,python . ,sed))))
|
| 1554 | (p1 (rewrite p0)))
|
| 1555 | (match (bag-direct-inputs (package->bag p1))
|
| 1556 | ((("python" python) _ ...)
|
| 1557 | (derivation-file-name (package-derivation %store python))))))
|
| 1558 |
|
| 1559 | (test-assert "package-input-rewriting, recursive"
|
| 1560 | (let* ((dep (dummy-package "dep" (native-inputs (list grep))))
|
| 1561 | (p0 (dummy-package "example1" (inputs (list dep grep))))
|
| 1562 | (p1 (dummy-package "example2" (inputs (list dep grep))))
|
| 1563 | (replacements `((,grep . ,findutils) (,p0 . ,p1)))
|
| 1564 | (rewrite (package-input-rewriting replacements))
|
| 1565 | (rewrite/recursive (package-input-rewriting replacements
|
| 1566 | #:recursive? #t))
|
| 1567 | (p2 (rewrite p0))
|
| 1568 | (p3 (rewrite/recursive p0)))
|
| 1569 | (and (string=? (package-name p2) "example2")
|
| 1570 | |
| 1571 | (match (package-inputs p2)
|
| 1572 | ((("dep" dep1) ("grep" dep2))
|
| 1573 | (and (match (package-native-inputs dep1)
|
| 1574 | ((("grep" x)) (eq? x grep)))
|
| 1575 | (eq? dep2 grep))))
|
| 1576 |
|
| 1577 | |
| 1578 | |
| 1579 | (string=? (package-name p3) "example2")
|
| 1580 | (match (package-inputs p3)
|
| 1581 | ((("dep" dep1) ("grep" dep2))
|
| 1582 | (and (match (package-native-inputs dep1)
|
| 1583 | ((("grep" x))
|
| 1584 | (string=? (package-full-name x)
|
| 1585 | (package-full-name findutils))))
|
| 1586 | (string=? (package-full-name dep2)
|
| 1587 | (package-full-name findutils))))))))
|
| 1588 |
|
| 1589 | (test-assert "package-input-rewriting/spec"
|
| 1590 | (let* ((dep (dummy-package "chbouib"
|
| 1591 | (native-inputs `(("x" ,grep)))))
|
| 1592 | (p0 (dummy-package "example"
|
| 1593 | (inputs `(("foo" ,coreutils)
|
| 1594 | ("bar" ,grep)
|
| 1595 | ("baz" ,dep)))))
|
| 1596 | (rewrite (package-input-rewriting/spec
|
| 1597 | `(("coreutils" . ,(const sed))
|
| 1598 | ("grep" . ,(const findutils)))
|
| 1599 | #:deep? #f))
|
| 1600 | (p1 (rewrite p0))
|
| 1601 | (p2 (rewrite p0)))
|
| 1602 | (and (not (eq? p1 p0))
|
| 1603 | (eq? p1 p2) |
| 1604 | (string=? "example" (package-name p1))
|
| 1605 | (match (package-inputs p1)
|
| 1606 | ((("foo" dep1) ("bar" dep2) ("baz" dep3))
|
| 1607 | (and (string=? (package-full-name dep1)
|
| 1608 | (package-full-name sed))
|
| 1609 | (string=? (package-full-name dep2)
|
| 1610 | (package-full-name findutils))
|
| 1611 | (string=? (package-name dep3) "chbouib")
|
| 1612 | (eq? dep3 (rewrite dep)) |
| 1613 | (match (package-native-inputs dep3)
|
| 1614 | ((("x" dep))
|
| 1615 | (string=? (package-full-name dep)
|
| 1616 | (package-full-name findutils)))))))
|
| 1617 |
|
| 1618 | |
| 1619 | (equal? (drop (bag-direct-inputs (package->bag p1)) 3)
|
| 1620 | (drop (bag-direct-inputs (package->bag p0)) 3)))))
|
| 1621 |
|
| 1622 | (test-assert "package-input-rewriting/spec, partial match"
|
| 1623 | (let* ((dep (dummy-package "chbouib"
|
| 1624 | (version "1")
|
| 1625 | (native-inputs `(("x" ,grep)))))
|
| 1626 | (p0 (dummy-package "example"
|
| 1627 | (inputs `(("foo" ,coreutils)
|
| 1628 | ("bar" ,dep)))))
|
| 1629 | (rewrite (package-input-rewriting/spec
|
| 1630 | `(("chbouib@123" . ,(const sed)) |
| 1631 | ("grep" . ,(const findutils)))
|
| 1632 | #:deep? #f))
|
| 1633 | (p1 (rewrite p0)))
|
| 1634 | (and (not (eq? p1 p0))
|
| 1635 | (string=? "example" (package-name p1))
|
| 1636 | (match (package-inputs p1)
|
| 1637 | ((("foo" dep1) ("bar" dep2))
|
| 1638 | (and (string=? (package-full-name dep1)
|
| 1639 | (package-full-name coreutils))
|
| 1640 | (eq? dep2 (rewrite dep)) |
| 1641 | (match (package-native-inputs dep2)
|
| 1642 | ((("x" dep))
|
| 1643 | (string=? (package-full-name dep)
|
| 1644 | (package-full-name findutils))))))))))
|
| 1645 |
|
| 1646 | (test-assert "package-input-rewriting/spec, deep"
|
| 1647 | (let* ((dep (dummy-package "chbouib"))
|
| 1648 | (p0 (dummy-package "example"
|
| 1649 | (build-system gnu-build-system)
|
| 1650 | (inputs `(("dep" ,dep)))))
|
| 1651 | (rewrite (package-input-rewriting/spec
|
| 1652 | `(("tar" . ,(const sed))
|
| 1653 | ("gzip" . ,(const findutils)))))
|
| 1654 | (p1 (rewrite p0))
|
| 1655 | (p2 (rewrite p0)))
|
| 1656 | (and (not (eq? p1 p0))
|
| 1657 | (eq? p1 p2) |
| 1658 | (string=? "example" (package-name p1))
|
| 1659 | (match (package-inputs p1)
|
| 1660 | ((("dep" dep1))
|
| 1661 | (and (string=? (package-full-name dep1)
|
| 1662 | (package-full-name dep))
|
| 1663 | (eq? dep1 (rewrite dep))))) |
| 1664 |
|
| 1665 | |
| 1666 | (match (bag-direct-inputs (package->bag p1))
|
| 1667 | ((("dep" dep1) ("tar" tar) ("gzip" gzip) _ ...)
|
| 1668 | (and (eq? dep1 (rewrite dep))
|
| 1669 | (string=? (package-full-name tar)
|
| 1670 | (package-full-name sed))
|
| 1671 | (string=? (package-full-name gzip)
|
| 1672 | (package-full-name findutils))))))))
|
| 1673 |
|
| 1674 | (test-assert "package-input-rewriting/spec, no duplicates"
|
| 1675 | |
| 1676 | |
| 1677 | |
| 1678 | |
| 1679 | |
| 1680 | |
| 1681 | (let* ((dep0 (dummy-package "dep0"
|
| 1682 | (build-system trivial-build-system)
|
| 1683 | (propagated-inputs `(("python" ,python)))))
|
| 1684 | (p0 (dummy-package "chbouib"
|
| 1685 | (build-system pyproject-build-system)
|
| 1686 | (arguments (list #:python python))
|
| 1687 | (inputs (list dep0))))
|
| 1688 | (rewrite (package-input-rewriting/spec '() #:deep? #t))
|
| 1689 | (p1 (rewrite p0))
|
| 1690 | (bag1 (package->bag p1))
|
| 1691 | (pythons (filter-map (match-lambda
|
| 1692 | (("python" python) python)
|
| 1693 | (_ #f))
|
| 1694 | (bag-transitive-inputs bag1))))
|
| 1695 | (match (delete-duplicates pythons eq?)
|
| 1696 | ((p) (eq? p (rewrite python))))))
|
| 1697 |
|
| 1698 | (test-assert "package-input-rewriting/spec, hidden package"
|
| 1699 | |
| 1700 | (let* ((python (hidden-package python))
|
| 1701 | (p0 (dummy-package "chbouib"
|
| 1702 | (build-system trivial-build-system)
|
| 1703 | (inputs (list python))))
|
| 1704 | (rewrite (package-input-rewriting/spec
|
| 1705 | `(("python" . ,(const sed)))
|
| 1706 | #:deep? #t))
|
| 1707 | (p1 (rewrite p0))
|
| 1708 | (bag1 (package->bag p1))
|
| 1709 | (pythons (filter-map (match-lambda
|
| 1710 | (("python" python) python)
|
| 1711 | (_ #f))
|
| 1712 | (bag-transitive-inputs bag1))))
|
| 1713 | (match (delete-duplicates pythons eq?)
|
| 1714 | ((p) (eq? p python)))))
|
| 1715 |
|
| 1716 | (test-assert "package-input-rewriting/spec, replace hidden package"
|
| 1717 | |
| 1718 | (let* ((python (hidden-package python))
|
| 1719 | (p0 (dummy-package "chbouib"
|
| 1720 | (build-system trivial-build-system)
|
| 1721 | (inputs (list python))))
|
| 1722 | (rewrite (package-input-rewriting/spec
|
| 1723 | `(("python" . ,(const sed)))
|
| 1724 | #:replace-hidden? #t))
|
| 1725 | (p1 (rewrite p0)))
|
| 1726 | (match (package-inputs p1)
|
| 1727 | ((("python" python))
|
| 1728 | (and (string=? (package-full-name python)
|
| 1729 | (package-full-name sed)))))))
|
| 1730 |
|
| 1731 | (test-equal "package-input-rewriting/spec, graft"
|
| 1732 | (derivation-file-name (package-derivation %store sed))
|
| 1733 |
|
| 1734 | |
| 1735 | (let* ((dep0 (dummy-package "dep"
|
| 1736 | (version "1")
|
| 1737 | (build-system trivial-build-system)
|
| 1738 | (inputs `(("coreutils" ,coreutils)))))
|
| 1739 | (dep1 (dummy-package "dep"
|
| 1740 | (version "0")
|
| 1741 | (build-system trivial-build-system)
|
| 1742 | (replacement dep0)))
|
| 1743 | (p0 (dummy-package "p"
|
| 1744 | (build-system trivial-build-system)
|
| 1745 | (inputs `(("dep" ,dep1)))))
|
| 1746 | (rewrite (package-input-rewriting/spec
|
| 1747 | `(("coreutils" . ,(const sed)))))
|
| 1748 | (p1 (rewrite p0)))
|
| 1749 | (match (package-inputs p1)
|
| 1750 | ((("dep" dep))
|
| 1751 | (match (package-inputs (package-replacement dep))
|
| 1752 | ((("coreutils" coreutils))
|
| 1753 | |
| 1754 | |
| 1755 | (derivation-file-name
|
| 1756 | (package-derivation %store coreutils))))))))
|
| 1757 |
|
| 1758 | (test-assert "package-with-c-toolchain"
|
| 1759 | (let* ((dep (dummy-package "chbouib"
|
| 1760 | (build-system gnu-build-system)
|
| 1761 | (native-inputs `(("x" ,grep)))))
|
| 1762 | (p0 (dummy-package "thingie"
|
| 1763 | (build-system gnu-build-system)
|
| 1764 | (inputs `(("foo" ,grep)
|
| 1765 | ("bar" ,dep)))))
|
| 1766 | (tc (dummy-package "my-toolchain"))
|
| 1767 | (p1 (package-with-c-toolchain p0 `(("toolchain" ,tc)))))
|
| 1768 | (define toolchain-packages
|
| 1769 | '("gcc" "binutils" "glibc" "ld-wrapper"))
|
| 1770 |
|
| 1771 | (match (bag-build-inputs (package->bag p1))
|
| 1772 | ((("foo" foo) ("bar" bar) (_ (= package-name packages) . _) ...)
|
| 1773 | (and (not (any (cut member <> packages) toolchain-packages))
|
| 1774 | (member "my-toolchain" packages)
|
| 1775 | (eq? foo grep)
|
| 1776 | (eq? bar dep))))))
|
| 1777 |
|
| 1778 | (test-assert "package-input-rewriting/spec, identity"
|
| 1779 | |
| 1780 | |
| 1781 | |
| 1782 | |
| 1783 | (let* ((libffi (dummy-package "libffi"
|
| 1784 | (build-system trivial-build-system)))
|
| 1785 | (glib (dummy-package "glib"
|
| 1786 | (build-system trivial-build-system)
|
| 1787 | (propagated-inputs (list libffi))))
|
| 1788 | (gobject (dummy-package "gobject-introspection"
|
| 1789 | (build-system trivial-build-system)
|
| 1790 | (inputs (list glib))
|
| 1791 | (propagated-inputs (list libffi))))
|
| 1792 | (rewrite (package-input-rewriting/spec
|
| 1793 | `(("glib" . ,identity)))))
|
| 1794 | (and (= (length (package-transitive-inputs gobject))
|
| 1795 | (length (package-transitive-inputs (rewrite gobject))))
|
| 1796 | (string=? (derivation-file-name
|
| 1797 | (package-derivation %store (rewrite gobject)))
|
| 1798 | (derivation-file-name
|
| 1799 | (package-derivation %store gobject))))))
|
| 1800 |
|
| 1801 | (test-assert "package-input-rewriting, identity"
|
| 1802 | |
| 1803 | |
| 1804 | (let* ((libffi (dummy-package "libffi"
|
| 1805 | (build-system trivial-build-system)))
|
| 1806 | (glib (dummy-package "glib"
|
| 1807 | (build-system trivial-build-system)
|
| 1808 | (propagated-inputs (list libffi))))
|
| 1809 | (gobject (dummy-package "gobject-introspection"
|
| 1810 | (build-system trivial-build-system)
|
| 1811 | (inputs (list glib))
|
| 1812 | (propagated-inputs (list libffi))))
|
| 1813 | (rewrite (package-input-rewriting `((,glib . ,glib)))))
|
| 1814 | (and (= (length (package-transitive-inputs gobject))
|
| 1815 | (length (package-transitive-inputs (rewrite gobject))))
|
| 1816 | (string=? (derivation-file-name
|
| 1817 | (package-derivation %store (rewrite gobject)))
|
| 1818 | (derivation-file-name
|
| 1819 | (package-derivation %store gobject))))))
|
| 1820 |
|
| 1821 | (test-equal "package-patched-vulnerabilities"
|
| 1822 | '(("CVE-2015-1234")
|
| 1823 | ("CVE-2016-1234" "CVE-2018-4567")
|
| 1824 | ())
|
| 1825 | (let ((p1 (dummy-package "pi"
|
| 1826 | (source (dummy-origin
|
| 1827 | (patches (list "/a/b/pi-CVE-2015-1234.patch"))))))
|
| 1828 | (p2 (dummy-package "pi"
|
| 1829 | (source (dummy-origin
|
| 1830 | (patches (list
|
| 1831 | "/a/b/pi-CVE-2016-1234-CVE-2018-4567.patch"))))))
|
| 1832 | (p3 (dummy-package "pi" (source (dummy-origin)))))
|
| 1833 | (map package-patched-vulnerabilities
|
| 1834 | (list p1 p2 p3))))
|
| 1835 |
|
| 1836 | (test-eq "fold-packages" hello
|
| 1837 | (fold-packages (lambda (p r)
|
| 1838 | (if (string=? (package-name p) "hello")
|
| 1839 | p
|
| 1840 | r))
|
| 1841 | #f))
|
| 1842 |
|
| 1843 | (test-assert "fold-packages, hidden package"
|
| 1844 | |
| 1845 | |
| 1846 | |
| 1847 | (match (fold-packages (lambda (p r)
|
| 1848 | (if (and (string=? (package-name p) "guile")
|
| 1849 | (string-prefix? "2.0"
|
| 1850 | (package-version p)))
|
| 1851 | (cons p r)
|
| 1852 | r))
|
| 1853 | '())
|
| 1854 | ((one)
|
| 1855 | (eq? one guile-2.0))))
|
| 1856 |
|
| 1857 | (test-assert "fold-available-packages with/without cache"
|
| 1858 | (let ()
|
| 1859 | (define no-cache
|
| 1860 | (fold-available-packages (lambda* (name version result #:rest rest)
|
| 1861 | (cons (cons* name version rest)
|
| 1862 | result))
|
| 1863 | '()))
|
| 1864 |
|
| 1865 | (define from-cache
|
| 1866 | (call-with-temporary-directory
|
| 1867 | (lambda (cache)
|
| 1868 | (generate-package-cache cache)
|
| 1869 | (mock ((guix describe) current-profile (const cache))
|
| 1870 | (mock ((gnu packages) cache-is-authoritative? (const #t))
|
| 1871 | (fold-available-packages (lambda* (name version result
|
| 1872 | #:rest rest)
|
| 1873 | (cons (cons* name version rest)
|
| 1874 | result))
|
| 1875 | '()))))))
|
| 1876 |
|
| 1877 | (define (list->set* lst)
|
| 1878 | |
| 1879 | |
| 1880 | (let loop ((lst lst)
|
| 1881 | (duplicates '())
|
| 1882 | (seen (set)))
|
| 1883 | (match lst
|
| 1884 | (()
|
| 1885 | (values seen duplicates))
|
| 1886 | ((head . tail)
|
| 1887 | (if (set-contains? seen head)
|
| 1888 | (loop tail (cons head duplicates) seen)
|
| 1889 | (loop tail duplicates (set-insert head seen)))))))
|
| 1890 |
|
| 1891 | |
| 1892 | |
| 1893 | (let ((set1 duplicates1 (list->set* from-cache))
|
| 1894 | (set2 duplicates2 (list->set* no-cache)))
|
| 1895 | |
| 1896 | (pk 'from-cache-duplicates: duplicates1)
|
| 1897 | (pk 'no-cache-duplicates: duplicates2)
|
| 1898 | (and (null? duplicates1) (null? duplicates2)
|
| 1899 | (every (cut set-contains? set1 <>) no-cache)
|
| 1900 | (every (cut set-contains? set2 <>) from-cache)))))
|
| 1901 |
|
| 1902 | (test-assert "find-packages-by-name"
|
| 1903 | (match (find-packages-by-name "hello")
|
| 1904 | (((? (cut eq? hello <>))) #t)
|
| 1905 | (wrong (pk 'find-packages-by-name wrong #f))))
|
| 1906 |
|
| 1907 | (test-assert "find-packages-by-name with version"
|
| 1908 | (match (find-packages-by-name "hello" (package-version hello))
|
| 1909 | (((? (cut eq? hello <>))) #t)
|
| 1910 | (wrong (pk 'find-packages-by-name wrong #f))))
|
| 1911 |
|
| 1912 | (test-equal "find-packages-by-name with cache"
|
| 1913 | (find-packages-by-name "guile")
|
| 1914 | (call-with-temporary-directory
|
| 1915 | (lambda (cache)
|
| 1916 | (generate-package-cache cache)
|
| 1917 | (mock ((guix describe) current-profile (const cache))
|
| 1918 | (mock ((gnu packages) cache-is-authoritative? (const #t))
|
| 1919 | (find-packages-by-name "guile"))))))
|
| 1920 |
|
| 1921 | (test-equal "find-packages-by-name + version, with cache"
|
| 1922 | (find-packages-by-name "guile" "2")
|
| 1923 | (call-with-temporary-directory
|
| 1924 | (lambda (cache)
|
| 1925 | (generate-package-cache cache)
|
| 1926 | (mock ((guix describe) current-profile (const cache))
|
| 1927 | (mock ((gnu packages) cache-is-authoritative? (const #t))
|
| 1928 | (find-packages-by-name "guile" "2"))))))
|
| 1929 |
|
| 1930 | (test-assert "--search-paths with pattern"
|
| 1931 | |
| 1932 | |
| 1933 | |
| 1934 | |
| 1935 | (let* ((p1 (package
|
| 1936 | (name "foo") (version "0") (source #f)
|
| 1937 | (build-system trivial-build-system)
|
| 1938 | (arguments
|
| 1939 | `(#:guile ,%bootstrap-guile
|
| 1940 | #:modules ((guix build utils))
|
| 1941 | #:builder (begin
|
| 1942 | (use-modules (guix build utils))
|
| 1943 | (let ((out (assoc-ref %outputs "out")))
|
| 1944 | (mkdir-p (string-append out "/xml/bar/baz"))
|
| 1945 | (call-with-output-file
|
| 1946 | (string-append out "/xml/bar/baz/catalog.xml")
|
| 1947 | (lambda (port)
|
| 1948 | (display "xml? wat?!" port)))
|
| 1949 | #t))))
|
| 1950 | (synopsis #f) (description #f)
|
| 1951 | (home-page #f) (license #f)))
|
| 1952 | (p2 (package
|
| 1953 | |
| 1954 | |
| 1955 | |
| 1956 | (name "libxml2") (version "0.0.0") (source #f)
|
| 1957 | (build-system trivial-build-system)
|
| 1958 | (arguments
|
| 1959 | `(#:guile ,%bootstrap-guile
|
| 1960 | #:builder (begin
|
| 1961 | (mkdir (assoc-ref %outputs "out"))
|
| 1962 | #t)))
|
| 1963 | (native-search-paths (package-native-search-paths libxml2))
|
| 1964 | (synopsis #f) (description #f)
|
| 1965 | (home-page #f) (license #f)))
|
| 1966 | (prof (run-with-store %store
|
| 1967 | (profile-derivation
|
| 1968 | (manifest (map package->manifest-entry
|
| 1969 | (list p1 p2)))
|
| 1970 | #:hooks '()
|
| 1971 | #:locales? #f)
|
| 1972 | #:guile-for-build (%guile-for-build))))
|
| 1973 | (build-derivations %store (list prof))
|
| 1974 | (string-match (format #f "^export XML_CATALOG_FILES=\"~a/xml/+bar/baz/catalog\\.xml\"\n"
|
| 1975 | (regexp-quote (derivation->output-path prof)))
|
| 1976 | (with-output-to-string
|
| 1977 | (lambda ()
|
| 1978 | (guix-package "-p" (derivation->output-path prof)
|
| 1979 | "--search-paths"))))))
|
| 1980 |
|
| 1981 | (test-assert "--search-paths with single-item search path"
|
| 1982 | |
| 1983 | |
| 1984 | |
| 1985 | (let* ((p1 (dummy-package "foo"
|
| 1986 | (build-system trivial-build-system)
|
| 1987 | (arguments
|
| 1988 | `(#:guile ,%bootstrap-guile
|
| 1989 | #:modules ((guix build utils))
|
| 1990 | #:builder (begin
|
| 1991 | (use-modules (guix build utils))
|
| 1992 | (let ((out (assoc-ref %outputs "out")))
|
| 1993 | (mkdir-p (string-append out "/etc/ssl/certs"))
|
| 1994 | (call-with-output-file
|
| 1995 | (string-append
|
| 1996 | out "/etc/ssl/certs/ca-certificates.crt")
|
| 1997 | (const #t))))))))
|
| 1998 | (p2 (package (inherit p1) (name "bar")))
|
| 1999 | (p3 (dummy-package "git"
|
| 2000 | |
| 2001 | (build-system trivial-build-system)
|
| 2002 | (arguments
|
| 2003 | `(#:guile ,%bootstrap-guile
|
| 2004 | #:builder (begin
|
| 2005 | (mkdir (assoc-ref %outputs "out"))
|
| 2006 | #t)))
|
| 2007 | (native-search-paths (package-native-search-paths git))))
|
| 2008 | (prof1 (run-with-store %store
|
| 2009 | (profile-derivation
|
| 2010 | (packages->manifest (list p1 p3))
|
| 2011 | #:hooks '()
|
| 2012 | #:locales? #f)
|
| 2013 | #:guile-for-build (%guile-for-build)))
|
| 2014 | (prof2 (run-with-store %store
|
| 2015 | (profile-derivation
|
| 2016 | (packages->manifest (list p2 p3))
|
| 2017 | #:hooks '()
|
| 2018 | #:locales? #f)
|
| 2019 | #:guile-for-build (%guile-for-build))))
|
| 2020 | (build-derivations %store (list prof1 prof2))
|
| 2021 | (string-match (format #f "^export GIT_SSL_CAINFO=\"~a/etc/ssl/certs/ca-certificates.crt"
|
| 2022 | (regexp-quote (derivation->output-path prof1)))
|
| 2023 | (with-output-to-string
|
| 2024 | (lambda ()
|
| 2025 | (guix-package "-p" (derivation->output-path prof1)
|
| 2026 | "-p" (derivation->output-path prof2)
|
| 2027 | "--search-paths"))))))
|
| 2028 |
|
| 2029 | (test-equal "specification->package when not found"
|
| 2030 | 'quit
|
| 2031 | (catch 'quit
|
| 2032 | (lambda ()
|
| 2033 | |
| 2034 | (specification->package "this-package-does-not-exist"))
|
| 2035 | (lambda (key . args)
|
| 2036 | key)))
|
| 2037 |
|
| 2038 | (test-equal "specification->package+output"
|
| 2039 | `((,coreutils "out") (,coreutils "debug"))
|
| 2040 | (list (call-with-values (lambda ()
|
| 2041 | (specification->package+output "coreutils"))
|
| 2042 | list)
|
| 2043 | (call-with-values (lambda ()
|
| 2044 | (specification->package+output "coreutils:debug"))
|
| 2045 | list)))
|
| 2046 |
|
| 2047 | (test-equal "specification->package+output invalid output"
|
| 2048 | 'error
|
| 2049 | (catch 'quit
|
| 2050 | (lambda ()
|
| 2051 | (specification->package+output "coreutils:does-not-exist"))
|
| 2052 | (lambda _
|
| 2053 | 'error)))
|
| 2054 |
|
| 2055 | (test-equal "specification->package+output no default output"
|
| 2056 | `(,coreutils #f)
|
| 2057 | (call-with-values
|
| 2058 | (lambda ()
|
| 2059 | (specification->package+output "coreutils" #f))
|
| 2060 | list))
|
| 2061 |
|
| 2062 | (test-equal "specification->package+output invalid output, no default"
|
| 2063 | 'error
|
| 2064 | (catch 'quit
|
| 2065 | (lambda ()
|
| 2066 | (specification->package+output "coreutils:does-not-exist" #f))
|
| 2067 | (lambda _
|
| 2068 | 'error)))
|
| 2069 |
|
| 2070 | (test-equal "find-package-locations"
|
| 2071 | (map (lambda (package)
|
| 2072 | (cons (package-version package)
|
| 2073 | (package-location package)))
|
| 2074 | (find-packages-by-name "guile"))
|
| 2075 | (find-package-locations "guile"))
|
| 2076 |
|
| 2077 | (test-equal "find-package-locations with cache"
|
| 2078 | (map (lambda (package)
|
| 2079 | (cons (package-version package)
|
| 2080 | (package-location package)))
|
| 2081 | (find-packages-by-name "guile"))
|
| 2082 | (call-with-temporary-directory
|
| 2083 | (lambda (cache)
|
| 2084 | (generate-package-cache cache)
|
| 2085 | (mock ((guix describe) current-profile (const cache))
|
| 2086 | (mock ((gnu packages) cache-is-authoritative? (const #t))
|
| 2087 | (find-package-locations "guile"))))))
|
| 2088 |
|
| 2089 | (test-equal "specification->location"
|
| 2090 | (package-location (specification->package "guile@2"))
|
| 2091 | (specification->location "guile@2"))
|
| 2092 |
|
| 2093 | (test-equal "package-unique-version-prefix, gcc@8"
|
| 2094 | "8"
|
| 2095 | (let ((gcc (specification->package "gcc-toolchain@8")))
|
| 2096 | (package-unique-version-prefix (package-name gcc)
|
| 2097 | (package-version gcc))))
|
| 2098 |
|
| 2099 | (test-equal "package-unique-version-prefix, grep"
|
| 2100 | ""
|
| 2101 | (let ((grep (specification->package "grep")))
|
| 2102 | (package-unique-version-prefix (package-name grep)
|
| 2103 | (package-version grep))))
|
| 2104 |
|
| 2105 |
|
| 2106 | (test-eq "this-package-input, exists"
|
| 2107 | hello
|
| 2108 | (package-arguments
|
| 2109 | (dummy-package "a"
|
| 2110 | (inputs `(("hello" ,hello)))
|
| 2111 | (arguments (this-package-input "hello")))))
|
| 2112 |
|
| 2113 | (test-eq "this-package-input, exists in propagated-inputs"
|
| 2114 | hello
|
| 2115 | (package-arguments
|
| 2116 | (dummy-package "a"
|
| 2117 | (propagated-inputs `(("hello" ,hello)))
|
| 2118 | (arguments (this-package-input "hello")))))
|
| 2119 |
|
| 2120 | (test-eq "this-package-input, does not exist"
|
| 2121 | #f
|
| 2122 | (package-arguments
|
| 2123 | (dummy-package "a"
|
| 2124 | (arguments (this-package-input "hello")))))
|
| 2125 |
|
| 2126 | (test-eq "this-package-native-input, exists"
|
| 2127 | hello
|
| 2128 | (package-arguments
|
| 2129 | (dummy-package "a"
|
| 2130 | (native-inputs `(("hello" ,hello)))
|
| 2131 | (arguments (this-package-native-input "hello")))))
|
| 2132 |
|
| 2133 | (test-eq "this-package-native-input, does not exists"
|
| 2134 | #f
|
| 2135 | (package-arguments
|
| 2136 | (dummy-package "a"
|
| 2137 | (arguments (this-package-native-input "hello")))))
|
| 2138 |
|
| 2139 | (test-equal "this-package-input, origin"
|
| 2140 | "http://example.org/foo.tar.gz"
|
| 2141 | (origin-uri
|
| 2142 | (package-arguments
|
| 2143 | (dummy-package "a"
|
| 2144 | (inputs (list (dummy-origin (uri "http://example.org/foo.tar.gz"))))
|
| 2145 | (arguments (this-package-input "foo.tar.gz"))))))
|
| 2146 |
|
| 2147 | (test-eq "modify-inputs, replace"
|
| 2148 | coreutils
|
| 2149 | |
| 2150 | (let* ((p1 (dummy-package "p"
|
| 2151 | (inputs (list hello))))
|
| 2152 | (p2 (package
|
| 2153 | (inherit p1)
|
| 2154 | (version "1")
|
| 2155 | (inputs (modify-inputs (package-inputs p1)
|
| 2156 | (replace "hello" coreutils))))))
|
| 2157 | (lookup-package-input p2 "hello")))
|
| 2158 |
|
| 2159 | (test-eq "modify-inputs, replace, change output"
|
| 2160 | guile-3.0
|
| 2161 | |
| 2162 | (let* ((p1 (dummy-package "p"
|
| 2163 | (inputs (list `(,coreutils "debug")))))
|
| 2164 | (p2 (package
|
| 2165 | (inherit p1)
|
| 2166 | (version "1")
|
| 2167 | (inputs (modify-inputs (package-inputs p1)
|
| 2168 | (replace "coreutils" `(,guile-3.0 "out")))))))
|
| 2169 | (match (package-inputs p2)
|
| 2170 | ((("coreutils" input "out"))
|
| 2171 | input))))
|
| 2172 |
|
| 2173 | (test-eq "modify-inputs, replace, extra output"
|
| 2174 | guile-3.0
|
| 2175 | |
| 2176 | |
| 2177 | (let* ((p1 (dummy-package "p"
|
| 2178 | (inputs (list `(,coreutils "debug")))))
|
| 2179 | (p2 (package
|
| 2180 | (inherit p1)
|
| 2181 | (version "1")
|
| 2182 | (inputs (modify-inputs (package-inputs p1)
|
| 2183 | (replace "coreutils" guile-3.0))))))
|
| 2184 | (match (package-inputs p2)
|
| 2185 | ((("coreutils" input "debug"))
|
| 2186 | input))))
|
| 2187 |
|
| 2188 | (test-end "packages")
|
| 2189 |
|
| 2190 | |
| 2191 | |
| 2192 | |
| 2193 | |