From patchwork Mon May 27 19:45:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Vollmert X-Patchwork-Id: 14090 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DDD6E1701A; Mon, 27 May 2019 20:47:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 7818C16CC8 for ; Mon, 27 May 2019 20:47:11 +0100 (BST) Received: from localhost ([127.0.0.1]:49979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVLaN-00017o-Pw for patchwork@mira.cbaines.net; Mon, 27 May 2019 15:47:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVLaL-00017i-HD for guix-patches@gnu.org; Mon, 27 May 2019 15:47:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVLaK-0007Y1-4c for guix-patches@gnu.org; Mon, 27 May 2019 15:47:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40593) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVLaJ-0007UA-H7 for guix-patches@gnu.org; Mon, 27 May 2019 15:47:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hVLaJ-0005nS-CZ for guix-patches@gnu.org; Mon, 27 May 2019 15:47:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35929] [PATCH] tests: hackage: avoid mock, and extract test data Resent-From: Robert Vollmert Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 27 May 2019 19:47:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35929 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 35929@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155898638722231 (code B ref -1); Mon, 27 May 2019 19:47:03 +0000 Received: (at submit) by debbugs.gnu.org; 27 May 2019 19:46:27 +0000 Received: from localhost ([127.0.0.1]:54135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVLZj-0005mU-7p for submit@debbugs.gnu.org; Mon, 27 May 2019 15:46:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34237) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVLZg-0005mF-9n for submit@debbugs.gnu.org; Mon, 27 May 2019 15:46:25 -0400 Received: from lists.gnu.org ([209.51.188.17]:34383) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVLZb-0006FN-4q for submit@debbugs.gnu.org; Mon, 27 May 2019 15:46:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVLZZ-00015N-LQ for guix-patches@gnu.org; Mon, 27 May 2019 15:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVLZY-0006BX-Au for guix-patches@gnu.org; Mon, 27 May 2019 15:46:17 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:57490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVLZY-000669-2H for guix-patches@gnu.org; Mon, 27 May 2019 15:46:16 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 6D7D3A0217; Mon, 27 May 2019 21:46:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id 00Ox58xYxs4a; Mon, 27 May 2019 21:46:02 +0200 (CEST) From: Robert Vollmert Date: Mon, 27 May 2019 21:45:56 +0200 Message-Id: <20190527194556.59710-1-rob@vllmrt.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Robert Vollmert Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This is partially in order to make tests depend less on the implementation of `hackage-fetch`, in preparation for hackage revision import. * tests/hackage.scm: Provide cabal input port directly, instead of mocking hackage-fetch. And make cabal tests more explicit and consistent by defining package pattern per test. --- tests/hackage.scm | 135 ++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 72 deletions(-) diff --git a/tests/hackage.scm b/tests/hackage.scm index 0efad0638d..a6d039afaa 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -155,93 +155,84 @@ library (test-begin "hackage") -(define* (eval-test-with-cabal test-cabal #:key (cabal-environment '())) - (mock - ((guix import hackage) hackage-fetch - (lambda (name-version) - (call-with-input-string test-cabal - read-cabal))) - (match (hackage->guix-package "foo" #:cabal-environment cabal-environment) - (('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-http" ('unquote 'ghc-http)) - ("ghc-mtl" ('unquote 'ghc-mtl))))) - ('home-page "http://test.org") - ('synopsis (? string?)) - ('description (? string?)) - ('license 'bsd-3)) - #t) - (x - (pk 'fail x #f))))) +(define ghc-foo-pattern + '('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-http" ('unquote 'ghc-http)) + ("ghc-mtl" ('unquote 'ghc-mtl))))) + ('home-page "http://test.org") + ('synopsis (? string?)) + ('description (? string?)) + ('license 'bsd-3))) + +(define* (eval-test-with-cabal test-cabal package-pattern #:key (cabal-environment '())) + (define port (open-input-string test-cabal)) + (match (hackage->guix-package "foo" #:port port #:cabal-environment cabal-environment) + (package-pattern #t) + (x (pk 'fail x #f)))) (test-assert "hackage->guix-package test 1" - (eval-test-with-cabal test-cabal-1)) + (eval-test-with-cabal test-cabal-1 ghc-foo-pattern)) (test-assert "hackage->guix-package test 2" - (eval-test-with-cabal test-cabal-2)) + (eval-test-with-cabal test-cabal-2 ghc-foo-pattern)) (test-assert "hackage->guix-package test 3" - (eval-test-with-cabal test-cabal-3 + (eval-test-with-cabal test-cabal-3 ghc-foo-pattern #:cabal-environment '(("impl" . "ghc-7.8")))) (test-assert "hackage->guix-package test 4" - (eval-test-with-cabal test-cabal-4 + (eval-test-with-cabal test-cabal-4 ghc-foo-pattern #:cabal-environment '(("impl" . "ghc-7.8")))) (test-assert "hackage->guix-package test 5" - (eval-test-with-cabal test-cabal-5 + (eval-test-with-cabal test-cabal-5 ghc-foo-pattern #:cabal-environment '(("impl" . "ghc-7.8")))) +(define ghc-foo-pattern-6 + '('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))) + (test-assert "hackage->guix-package test 6" - (mock - ((guix import hackage) hackage-fetch - (lambda (name-version) - (call-with-input-string test-cabal-6 - read-cabal))) - (match (hackage->guix-package "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))))) + (eval-test-with-cabal test-cabal-6 ghc-foo-pattern-6)) (test-assert "read-cabal test 1" (match (call-with-input-string test-read-cabal-1 read-cabal)