Subject: Re: [bug#75010] [PATCH 7/7] WIP: gnu: tests: Add module for guix deploy tests.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 30 Dec 2024 13:21:12 +0100

Herman Rimm <[email-masked]> skribis:

> * gnu/tests/deploy.scm: Add file.
>
> Change-Id: I348c8bf2e518ec6c00af126993eaca3fcd453901

Yay, nice!

Could you add it to ‘gnu/local.mk’?

> +(define (machines os)
> +  (program-file "machines.scm"
> +    #~(list (machine (configuration

This should be ‘scheme-file’ (with normal indentation).

> +(define* (deploy-program #:optional (os #~%simple-os))
> +  (program-file "deploy.scm"
> +    (with-extensions (list guile-gcrypt)
> +      (with-imported-modules `(,@(source-module-closure
> +                                  '((guix scripts deploy))
> +                                  #:select? not-config?)
> +                               ((guix config) => ,(make-config.scm)))
> +        #~(begin
> +            (use-modules (guix scripts deploy))
> +            (guix-deploy #$(machines os)))))))

We could use the ‘guix’ package here: it would be faster, but then we
would be testing an older snapshot and not the code at hand.  Not great.

Still, maybe using ‘current-guix’ would be faster (fewer things to
build), as in:

  #~(execl #$(file-append (current-guix) "/bin/guix")
           "guix" "deploy“ #$(machines os))

> +          (define (system-generations marionette)
> +            (marionette-eval
> +             '(begin
> +                (use-modules (ice-9 ftw)
> +                             (srfi srfi-1))
> +                (let* ((profile-dir "/var/guix/profiles/")
> +                       (entries (map first (cddr (file-system-tree profile-dir)))))

Please use ‘match’ rather than ‘first’ and ‘cddr’ (info "(guix) Data
Types and Pattern Matching").

Or maybe you could just as well use ‘scandir’?

> +            (test-equal "script created new generation"
> +              (length (system-generations marionette))
> +              (1+ (length generations-prior)))
> +
> +            (test-equal "script activated the new generation"
> +              (string-append "/var/guix/profiles/system-"
> +                             (number->string (+ 1 (length generations-prior)))
> +                             "-link")
> +              (marionette-eval '(readlink "/run/current-system")
> +                               marionette)))

We could also check other things, like the host name.

Ludo’.