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

From: Ludovic Courtès <[email-masked]>
Date: Wed, 15 Jan 2025 23:14:48 +0100

* 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(-)

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 <[email-masked]>
+;;; Copyright © 2018-2022, 2025 Ludovic Courtès <[email-masked]>
 ;;;
 ;;; 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
-- 
2.47.1