summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2022-09-24 12:42:21 +0200
committerMathieu Othacehe <othacehe@gnu.org>2022-09-24 12:48:16 +0200
commitfe4663ae2476cb527d4f1f49ff8fa077d43f7251 (patch)
tree5c65204900c454cbfbf8a5001a525017613c0e59
parente1ce1009156d7923bcf1b93ca3918c9b18123007 (diff)
downloadguix-fe4663ae2476cb527d4f1f49ff8fa077d43f7251.tar.gz
installer: Fix configuration edition during testing.
When the configuration is edited, it looks like there are some leftover
fragments from the input configuration:

Example content of config.scm after edition:

  #:imported-modules
  '((gnu services herd)
    (guix build utils)
    (guix combinators)))

unted".  The unique
  ;; file system identifiers there ("UUIDs") can be obtained
  ;; by running 'blkid' in a terminal.

...

This is strange because call-with-output-file uses the O_TRUNC flag which
resets the file size to zero. Remove the configuration file before writing it
as a work-around.

* gnu/installer/tests.scm (edit-configuration-file): Remove the configuration
file before re-writing it.
-rw-r--r--gnu/installer/tests.scm4
1 files changed, 4 insertions, 0 deletions
diff --git a/gnu/installer/tests.scm b/gnu/installer/tests.scm
index 3c049a1c85..82c3d3ee88 100644
--- a/gnu/installer/tests.scm
+++ b/gnu/installer/tests.scm
@@ -280,6 +280,10 @@ instrumented for further testing."
        exp)))
 
   (let ((content (call-with-input-file file read-expressions)))
+    ;; XXX: Remove the file before re-writing it, to be sure there are no
+    ;; leftovers.  We shouldn't have to to that as CALL-WITH-OUTPUT-FILE uses
+    ;; the O_TRUNC flag by default.
+    (delete-file file)
     (call-with-output-file file
       (lambda (port)
         (format port "\