diff options
| author | Reepca Russelstein <reepca@russelstein.xyz> | 2025-09-16 22:08:19 -0500 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-10-12 22:22:01 +0200 |
| commit | 55a10ce4e618d334ccc5df71bf94483d7c9966ed (patch) | |
| tree | ce57a8ee7ad45b670dc250b0857c8c85da845213 /tests/derivations.scm | |
| parent | b39f914b3ef779ab50b2af5e4eee0d0f93e9b7f4 (diff) | |
tests: don't use 'file://...' URIs for testing git downloads.
While 'url-fetch*' in (guix download) special-cases these URIs, 'git-fetch'
does not. Consequently, the recent changes to (guix scripts perform-download)
that disallow these URIs cause tests that use builtin:git-download to fail.
* guix/tests/git.scm (serve-git-repository, call-with-served-git-repository):
new procedures.
(with-served-git-repository, with-served-temporary-git-repository): new
syntax.
* .dir-locals.el (scheme-mode): add indentation information for
'with-served-git-repository'.
* tests/builders.scm ("git-fetch, file URI"): use git:// URI with
'with-served-temporary-git-repository'.
* tests/derivations.scm ("'git-download' build-in builder, invalid hash",
"'git-download' built-in builder, invalid commit", "'git-download' built-in
builder, not found"): same.
("'git-download' built-in builder"): same, and use a nonce in the repo
contents so that success isn't cached.
Change-Id: Id3e1233bb74d5987faf89c4341e1d37f09c77c80
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/derivations.scm')
| -rw-r--r-- | tests/derivations.scm | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm index 077aee09094..d4cca0f6058 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm | |||
| @@ -306,12 +306,14 @@ | |||
| 306 | get-string-all) | 306 | get-string-all) |
| 307 | text)))))) | 307 | text)))))) |
| 308 | 308 | ||
| 309 | (define %nonce (random-text)) | ||
| 310 | |||
| 309 | (test-equal "'git-download' built-in builder" | 311 | (test-equal "'git-download' built-in builder" |
| 310 | `(("/a.txt" . "AAA") | 312 | `(("/a.txt" . ,%nonce) |
| 311 | ("/b.scm" . "#t")) | 313 | ("/b.scm" . "#t")) |
| 312 | (let ((nonce (random-text))) | 314 | (let ((nonce (random-text))) |
| 313 | (with-temporary-git-repository directory | 315 | (with-served-temporary-git-repository directory port |
| 314 | `((add "a.txt" "AAA") | 316 | `((add "a.txt" ,%nonce) |
| 315 | (add "b.scm" "#t") | 317 | (add "b.scm" "#t") |
| 316 | (commit ,nonce)) | 318 | (commit ,nonce)) |
| 317 | (let* ((commit (with-repository directory repository | 319 | (let* ((commit (with-repository directory repository |
| @@ -322,7 +324,9 @@ | |||
| 322 | #:env-vars | 324 | #:env-vars |
| 323 | `(("url" | 325 | `(("url" |
| 324 | . ,(object->string | 326 | . ,(object->string |
| 325 | (string-append "file://" directory))) | 327 | (string-append "git://localhost:" |
| 328 | (number->string port) | ||
| 329 | "/"))) | ||
| 326 | ("commit" . ,commit)) | 330 | ("commit" . ,commit)) |
| 327 | #:hash-algo 'sha256 | 331 | #:hash-algo 'sha256 |
| 328 | #:hash (file-hash* directory | 332 | #:hash (file-hash* directory |
| @@ -335,7 +339,7 @@ | |||
| 335 | (directory-contents (derivation->output-path drv) get-string-all))))) | 339 | (directory-contents (derivation->output-path drv) get-string-all))))) |
| 336 | 340 | ||
| 337 | (test-assert "'git-download' built-in builder, invalid hash" | 341 | (test-assert "'git-download' built-in builder, invalid hash" |
| 338 | (with-temporary-git-repository directory | 342 | (with-served-temporary-git-repository directory port |
| 339 | `((add "a.txt" "AAA") | 343 | `((add "a.txt" "AAA") |
| 340 | (add "b.scm" "#t") | 344 | (add "b.scm" "#t") |
| 341 | (commit "Commit!")) | 345 | (commit "Commit!")) |
| @@ -347,7 +351,9 @@ | |||
| 347 | #:env-vars | 351 | #:env-vars |
| 348 | `(("url" | 352 | `(("url" |
| 349 | . ,(object->string | 353 | . ,(object->string |
| 350 | (string-append "file://" directory))) | 354 | (string-append "git://localhost:" |
| 355 | (number->string port) | ||
| 356 | "/"))) | ||
| 351 | ("commit" . ,commit)) | 357 | ("commit" . ,commit)) |
| 352 | #:hash-algo 'sha256 | 358 | #:hash-algo 'sha256 |
| 353 | #:hash (gcrypt:sha256 #vu8()) | 359 | #:hash (gcrypt:sha256 #vu8()) |
| @@ -358,7 +364,7 @@ | |||
| 358 | #f)))) | 364 | #f)))) |
| 359 | 365 | ||
| 360 | (test-assert "'git-download' built-in builder, invalid commit" | 366 | (test-assert "'git-download' built-in builder, invalid commit" |
| 361 | (with-temporary-git-repository directory | 367 | (with-served-temporary-git-repository directory port |
| 362 | `((add "a.txt" "AAA") | 368 | `((add "a.txt" "AAA") |
| 363 | (add "b.scm" "#t") | 369 | (add "b.scm" "#t") |
| 364 | (commit "Commit!")) | 370 | (commit "Commit!")) |
| @@ -367,7 +373,9 @@ | |||
| 367 | #:env-vars | 373 | #:env-vars |
| 368 | `(("url" | 374 | `(("url" |
| 369 | . ,(object->string | 375 | . ,(object->string |
| 370 | (string-append "file://" directory))) | 376 | (string-append "git://localhost:" |
| 377 | (number->string port) | ||
| 378 | "/"))) | ||
| 371 | ("commit" | 379 | ("commit" |
| 372 | . "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) | 380 | . "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) |
| 373 | #:hash-algo 'sha256 | 381 | #:hash-algo 'sha256 |
| @@ -379,19 +387,24 @@ | |||
| 379 | #f)))) | 387 | #f)))) |
| 380 | 388 | ||
| 381 | (test-assert "'git-download' built-in builder, not found" | 389 | (test-assert "'git-download' built-in builder, not found" |
| 382 | (let* ((drv (derivation %store "git-download" | 390 | (with-served-temporary-git-repository directory port |
| 383 | "builtin:git-download" '() | 391 | '() |
| 384 | #:env-vars | 392 | (let* ((drv (derivation %store "git-download" |
| 385 | `(("url" . "file:///does-not-exist.git") | 393 | "builtin:git-download" '() |
| 386 | ("commit" | 394 | #:env-vars |
| 387 | . "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) | 395 | `(("url" . ,(object->string |
| 388 | #:hash-algo 'sha256 | 396 | (string-append "git://localhost:" |
| 389 | #:hash (gcrypt:sha256 #vu8()) | 397 | (number->string port) |
| 390 | #:recursive? #t))) | 398 | "/nonexistent"))) |
| 391 | (guard (c ((store-protocol-error? c) | 399 | ("commit" |
| 392 | (string-contains (store-protocol-error-message c) "failed"))) | 400 | . "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) |
| 393 | (build-derivations %store (list drv)) | 401 | #:hash-algo 'sha256 |
| 394 | #f))) | 402 | #:hash (gcrypt:sha256 #vu8()) |
| 403 | #:recursive? #t))) | ||
| 404 | (guard (c ((store-protocol-error? c) | ||
| 405 | (string-contains (store-protocol-error-message c) "failed"))) | ||
| 406 | (build-derivations %store (list drv)) | ||
| 407 | #f)))) | ||
| 395 | 408 | ||
| 396 | (test-equal "derivation-name" | 409 | (test-equal "derivation-name" |
| 397 | "foo-0.0" | 410 | "foo-0.0" |
