From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:53229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hT6Qt-0005kq-Cb for guix-patches@gnu.org; Tue, 21 May 2019 11:12:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hT6Qs-0004oU-62 for guix-patches@gnu.org; Tue, 21 May 2019 11:12:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55268) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hT6Qs-0004oL-32 for guix-patches@gnu.org; Tue, 21 May 2019 11:12:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hT6Qr-0006Up-OJ for guix-patches@gnu.org; Tue, 21 May 2019 11:12:01 -0400 Subject: [bug#35812] [PATCH] fix hackage cabal tests Resent-Message-ID: Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) From: Robert Vollmert In-Reply-To: <874l5n2799.fsf@gnu.org> Date: Tue, 21 May 2019 17:10:51 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <616C2CBF-8171-401C-9515-5679A5E01823@vllmrt.net> References: <874l5n2799.fsf@gnu.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 35812@debbugs.gnu.org Hi Ludo=E2=80=99, > On 21. May 2019, at 16:48, Ludovic Court=C3=A8s wrote: > Robert Vollmert skribis: >=20 >> Hackage cabal tests didn=E2=80=99t run independently due to = memoization, >> and test-cabal-6 was failing. >=20 > I don=E2=80=99t think memoization can get in the way here: the = argument list is > used as a key in the memoization hash table. Thus, if you pass > different arguments, you get a cache miss and call the underlying > procedure. >=20 > Or am I missing something? I agree that memoization of a pure function shouldn=E2=80=99t have such = effects, but my (limited) understanding is that hackage->guix-packages would cache import results by package name on the assumption that cabal files for the same package name don=E2=80=99t change between calls. That observation is consistent with the test behaviour, but I may well be missing something. >> =46rom 8b6dac85a9f6c4e851c1a75a4958dff7915fb2f1 Mon Sep 17 00:00:00 = 2001 >> From: Robert Vollmert >> Date: Fri, 17 May 2019 10:48:42 +0200 >> Subject: [PATCH] tests: fix cabal tests to test and pass >>=20 >> * guix/import/hackage.scm: export unmemoized import function >> * tests/hackage.scm: use unmemoized import function to make tests = independent >> * tests/hackage.scm: fix failing test-cabal-6 by providing expected = output >=20 > [...] >=20 >> (test-assert "hackage->guix-package test 6" >> - (eval-test-with-cabal test-cabal-6 >> - #:cabal-environment '(("impl" . = "ghc-7.8")))) >> + (mock >> + ((guix import hackage) hackage-fetch >> + (lambda (name-version) >> + (call-with-input-string test-cabal-6 >> + read-cabal))) >> + (match (hackage->guix-package-impl "foo") >> + (('package >> + ('name "ghc-foo") >> + ('version "1.0.0") >> + ('source >> + ('origin >> + ('method 'url-fetch) >> + ('uri ('string-append >> + "https://hackage.haskell.org/package/foo/foo-" >> + 'version >> + ".tar.gz")) >> + ('sha256 >> + ('base32 >> + (? string? hash))))) >> + ('build-system 'haskell-build-system) >> + ('inputs >> + ('quasiquote >> + (("ghc-b" ('unquote 'ghc-b)) >> + ("ghc-http" ('unquote 'ghc-http)) >> + ("ghc-mtl" ('unquote 'ghc-mtl))))) >> + ('native-inputs >> + ('quasiquote >> + (("ghc-haskell-gi" ('unquote 'ghc-haskell-gi))))) >> + ('home-page "http://test.org") >> + ('synopsis (? string?)) >> + ('description (? string?)) >> + ('license 'bsd-3)) >> + #t) >> + (x >> + (pk 'fail x #f))))) >=20 > So this test needed to be changed as a result of turning off > memoization? Precisely. The other tests all expect various cabal fragments to yield the same package definition, while the extra fragment custom-setup setup-depends: base >=3D 4.7 && < 5, Cabal >=3D 1.24, haskell-gi =3D=3D 0.21.* in test-cabal-6 causes the extra native input ghc-haskell-gi. As I understand it, this test failure used to be shadowed because hackage->guix-packages would just return the successful parse of the test-cabal-1. (There=E2=80=99s probably some more elegant way to avoid duplicating the whole package definition, but I generally prefer a bit of explicit verbosity in test data.) Cheers Rob