Subject: [bug#75302] [PATCH] packages: Match renamed origin fields.

From: Herman Rimm <[email-masked]>
Date: Tue, 21 Jan 2025 19:32:44 +0100

Hi,

On Wed, Jan 08, 2025 at 11:06:08AM +0100, Ludovic Courtès wrote:
> If you really wanted to do this, try:
> 
>   ./pre-inst-env guile --no-auto-compile tests/packages.scm
> 

Thanks, I'll use this from now on.

> > guix shell -CPWN
> > make check TESTS="tests/packages.scm"
> >
> > returns:
> 
> [...]
> 
> > [ 77%] LOAD     gnu.scm
> > ice-9/eval.scm:293:34: error: diff: unbound variable
> > hint: Did you forget a `use-modules' form?
> > make[2]: *** [Makefile:7518: make-system-go] Error 1
> 
> Well, it definitely builds here.  Could it be that you have local
> changes in your tree?  Or perhaps you need ‘make clean-go’ first?

With ae217b7159ee202229eab39cd49adb9254cd4a96 checked out out and the
patch applied, I get the same result running:

guix shell -CPWN
make clean-go
make check TESTS="tests/packages.scm"

> >   source-form: (test-assert "package-source-derivation, local-file" (let* ((file (local-file "../guix/base32.scm")) (package (package (inherit (dummy-package "p")) (source file))) (source (package-source-derivation %store (package-source package)))) (and (store-path? source) (string-suffix? "base32.scm" source) (valid-path? %store source) (equal? (call-with-input-file source get-bytevector-all) (call-with-input-file (search-path %load-path "guix/base32.scm") get-bytevector-all)))))
> > Test end:
> >   result-kind: fail
> >   actual-value: #f
> >   actual-error: (system-error "canonicalize-path" "~A: ~S" ("No such file or directory" "../guix/base32.scm") (2))
> 
> Probably has to do with running the test through standard input ‘guix
> repl’: in that case it cannot correctly determine what the current file
> name is, and so relative file name resolution fails.

Yeah, now this test passes.  Another test fails instead:

Test begin:
  test-name: "fold-available-packages with/without cache"
  source-file: "tests/packages.scm"
  source-line: 1819
  source-form: (test-assert "fold-available-packages with/without cache" (let () (define no-cache (fold-available-packages (lambda* (name version result #:rest rest) (cons (cons* name version rest) result)) (quote ()))) (define from-cache (call-with-temporary-directory (lambda (cache) (generate-package-cache cache) (mock ((guix describe) current-profile (const cache)) (mock ((gnu packages) cache-is-authoritative? (const #t)) (fold-available-packages (lambda* (name version result #:rest rest) (cons (cons* name version rest) result)) (quote ()))))))) (define (list->set* lst) (let loop ((lst lst) (duplicates (quote ())) (seen (set))) (match lst (() (values seen duplicates)) ((head . tail) (if (set-contains? seen head) (loop tail (cons head duplicates) seen) (loop tail duplicates (set-insert head seen))))))) (let ((set1 duplicates1 (list->set* from-cache)) (set2 duplicates2 (list->set* no-cache))) (pk (quote from-cache-duplicates:) duplicates1) (pk (quote no-cache-duplicates:) duplicates2) (and (null? duplicates1) (null? duplicates2) (every (cut set-contains? set1 <>) no-cache) (every (cut set-contains? set2 <>) from-cache)))))
Test end:
  result-kind: fail
  actual-value: #f

Cheers,
Herman