unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Vollmert <rob@vllmrt.net>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 35812@debbugs.gnu.org
Subject: [bug#35812] [PATCH] fix hackage cabal tests
Date: Tue, 21 May 2019 17:10:51 +0200	[thread overview]
Message-ID: <616C2CBF-8171-401C-9515-5679A5E01823@vllmrt.net> (raw)
In-Reply-To: <874l5n2799.fsf@gnu.org>

Hi Ludo’,

> On 21. May 2019, at 16:48, Ludovic Courtès <ludo@gnu.org> wrote:
> Robert Vollmert <rob@vllmrt.net> skribis:
> 
>> Hackage cabal tests didn’t run independently due to memoization,
>> and test-cabal-6 was failing.
> 
> I don’t 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.
> 
> Or am I missing something?

I agree that memoization of a pure function shouldn’t 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’t change between calls. That
observation is consistent with the test behaviour, but I may well be
missing something.

>> From 8b6dac85a9f6c4e851c1a75a4958dff7915fb2f1 Mon Sep 17 00:00:00 2001
>> From: Robert Vollmert <rob@vllmrt.net>
>> Date: Fri, 17 May 2019 10:48:42 +0200
>> Subject: [PATCH] tests: fix cabal tests to test and pass
>> 
>> * 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
> 
> [...]
> 
>> (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)))))
> 
> 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 >= 4.7 && < 5,
                 Cabal >= 1.24,
                 haskell-gi == 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’s 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

  reply	other threads:[~2019-05-21 15:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 19:06 [bug#35812] [PATCH] fix hackage cabal tests Robert Vollmert
2019-05-21 14:48 ` Ludovic Courtès
2019-05-21 15:10   ` Robert Vollmert [this message]
2019-05-26 21:23     ` bug#35812: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=616C2CBF-8171-401C-9515-5679A5E01823@vllmrt.net \
    --to=rob@vllmrt.net \
    --cc=35812@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).