From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#32126: call-with-temporary-directory rarely cleans up after itself Date: Fri, 13 Jul 2018 10:27:35 +0200 Message-ID: <87sh4nmtfs.fsf@gnu.org> References: <20180713005136.GA22011@jasmine.lan> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdtQr-0002JB-4g for bug-guix@gnu.org; Fri, 13 Jul 2018 04:28:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdtQn-0004Oc-WB for bug-guix@gnu.org; Fri, 13 Jul 2018 04:28:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:49751) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fdtQn-0004OA-SS for bug-guix@gnu.org; Fri, 13 Jul 2018 04:28:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fdtQn-0001EV-Jc for bug-guix@gnu.org; Fri, 13 Jul 2018 04:28:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20180713005136.GA22011@jasmine.lan> (Leo Famulari's message of "Thu, 12 Jul 2018 20:51:36 -0400") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Leo Famulari Cc: 32126@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, Leo Famulari skribis: > However, with the patch there is an error in the test 'gexp->script > #:module-path': > > ------ > actual-value: #f > actual-error: > + (system-error > + "lstat" > + "~A: ~S" > + ("No such file or directory" > + "/tmp/guix-directory.6CrC8B/guix/base32.scm") > + (2)) > result: FAIL > ------ Funny. That test turned out to work thanks to the brokenness of =E2=80=98call-with-temporary-directory=E2=80=99: since it=E2=80=99s a monad= ic return, the actual code was executed after we=E2=80=99d left the =E2=80=98call-with-temporary-= directory=E2=80=99 extent, yet it expected to be able to access files from that temporary directory. This change fixes it: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/tests/gexp.scm b/tests/gexp.scm index 83fe81154..31c7ce22f 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -948,7 +948,7 @@ (return (and (zero? (close-pipe pipe)) (= (expt n 2) (string->number str))))))) -(test-assertm "gexp->script #:module-path" +(test-assert "gexp->script #:module-path" (call-with-temporary-directory (lambda (directory) (define str @@ -961,23 +961,24 @@ (define-public %fake! ,str)) port))) - (mlet* %store-monad ((exp -> (with-imported-modules '((guix base32)) - (gexp (begin - (use-modules (guix base32)) - (write (list %load-path - %fake!)))))) - (drv (gexp->script "guile-thing" exp - #:guile %bootstrap-guile - #:module-path (list directory))) - (out -> (derivation->output-path drv)) - (done (built-derivations (list drv)))) - (let* ((pipe (open-input-pipe out)) - (data (read pipe))) - (return (and (zero? (close-pipe pipe)) - (match data - ((load-path str*) - (and (string=? str* str) - (not (member directory load-path)))))))))))) + (run-with-store %store + (mlet* %store-monad ((exp -> (with-imported-modules '((guix base32)) + (gexp (begin + (use-modules (guix base32)) + (write (list %load-path + %fake!)))))) + (drv (gexp->script "guile-thing" exp + #:guile %bootstrap-guile + #:module-path (list directory))) + (out -> (derivation->output-path drv)) + (done (built-derivations (list drv)))) + (let* ((pipe (open-input-pipe out)) + (data (read pipe))) + (return (and (zero? (close-pipe pipe)) + (match data + ((load-path str*) + (and (string=? str* str) + (not (member directory load-path))))))))))))) (test-assertm "program-file" (let* ((n (random (expt 2 50))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > From e3181f30ca0711e79aab9d71d798344dfb4636b5 Mon Sep 17 00:00:00 2001 > From: Leo Famulari > Date: Wed, 11 Jul 2018 20:24:29 -0400 > Subject: [PATCH] utils: Really clean up temporary directories. > > * guix/utils.scm (delete-file-recursively): New variable. > (call-with-temporary-directory): Use DELETE-FILE-RECURSIVELY instead of > RMDIR. Instead of duplicating =E2=80=98delete-file-recursively=E2=80=99, you can t= ake it directly from (guix build utils). There=E2=80=99s already a #:use-module c= lause at the top. Thanks, Ludo=E2=80=99. --=-=-=--