[bug#75595,2/4] tests: Make ‘inferior-eval-with-store’ test more robust.

Message ID a67711385cec3c256c047ff2f243d2e1d74e8678.1736977759.git.ludo@gnu.org
State New
Headers
Series 'guix container run' and isolated inferiors |

Commit Message

Ludovic Courtès Jan. 15, 2025, 10:14 p.m. UTC
  * tests/inferior.scm ("inferior-eval-with-store"): Use ‘random-text’ for
the store item’s body.

Change-Id: Ia39e276955e1836a0272713ff25c4490273c666f
---
 tests/inferior.scm | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
  

Patch

diff --git a/tests/inferior.scm b/tests/inferior.scm
index 963d405e33..11a27c0006 100644
--- a/tests/inferior.scm
+++ b/tests/inferior.scm
@@ -1,5 +1,5 @@ 
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018-2022 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018-2022, 2025 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -27,6 +27,8 @@  (define-module (test-inferior)
   #:use-module (gnu packages bootstrap)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages sqlite)
+  #:autoload   (gcrypt hash) (sha256)
+  #:autoload   (rnrs bytevectors) (string->utf8)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-64)
@@ -220,14 +222,15 @@  (define (manifest-entry->list entry)
     (close-inferior inferior)
     result))
 
-(test-equal "inferior-eval-with-store"
-  (add-text-to-store %store "foo" "Hello, world!")
+(test-assert "inferior-eval-with-store"
   (let* ((inferior (open-inferior %top-builddir
-                                  #:command "scripts/guix")))
-    (inferior-eval-with-store inferior %store
-                              '(lambda (store)
-                                 (add-text-to-store store "foo"
-                                                    "Hello, world!")))))
+                                  #:command "scripts/guix"))
+         (text (random-text)))
+    (string=? (inferior-eval-with-store inferior %store
+                                        `(lambda (store)
+                                           (add-text-to-store store "foo"
+                                                              ,text)))
+              (store-path "text" (sha256 (string->utf8 text)) "foo"))))
 
 (test-assert "inferior-eval-with-store, &store-protocol-error"
   (let* ((inferior (open-inferior %top-builddir