From mboxrd@z Thu Jan 1 00:00:00 1970 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 Subject: [bug#35929] [PATCH] tests: hackage: avoid mock, and extract test data Resent-Message-ID: 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 From: Robert Vollmert Date: Mon, 27 May 2019 21:45:56 +0200 Message-Id: <20190527194556.59710-1-rob@vllmrt.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: 35929@debbugs.gnu.org Cc: Robert Vollmert 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 =20 (test-begin "hackage") =20 -(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-environ= ment) - (('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-e= nvironment '())) + (define port (open-input-string test-cabal)) + (match (hackage->guix-package "foo" #:port port #:cabal-environment ca= bal-environment) + (package-pattern #t) + (x (pk 'fail x #f)))) =20 (test-assert "hackage->guix-package test 1" - (eval-test-with-cabal test-cabal-1)) + (eval-test-with-cabal test-cabal-1 ghc-foo-pattern)) =20 (test-assert "hackage->guix-package test 2" - (eval-test-with-cabal test-cabal-2)) + (eval-test-with-cabal test-cabal-2 ghc-foo-pattern)) =20 (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")))) =20 (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")))) =20 (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")))) =20 +(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)) =20 (test-assert "read-cabal test 1" (match (call-with-input-string test-read-cabal-1 read-cabal) --=20 2.20.1 (Apple Git-117)