From patchwork Thu May 30 11:46:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Vollmert X-Patchwork-Id: 14162 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 9270A17050; Thu, 30 May 2019 12: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=ham 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 14DF61704D for ; Thu, 30 May 2019 12:47:11 +0100 (BST) Received: from localhost ([127.0.0.1]:52585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWJWY-00036U-Mv for patchwork@mira.cbaines.net; Thu, 30 May 2019 07:47:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWJWS-00035M-2f for guix-patches@gnu.org; Thu, 30 May 2019 07:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWJWQ-0008DM-Hu for guix-patches@gnu.org; Thu, 30 May 2019 07:47:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47338) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWJWQ-0008Cy-E7 for guix-patches@gnu.org; Thu, 30 May 2019 07:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hWJWQ-0006J1-AK for guix-patches@gnu.org; Thu, 30 May 2019 07:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35929] [PATCH 1/2] tests: hackage: Factor out package pattern. References: <20190527194556.59710-1-rob@vllmrt.net> In-Reply-To: <20190527194556.59710-1-rob@vllmrt.net> Resent-From: Robert Vollmert Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 May 2019 11:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35929 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 35929@debbugs.gnu.org Received: via spool by 35929-submit@debbugs.gnu.org id=B35929.155921678624164 (code B ref 35929); Thu, 30 May 2019 11:47:02 +0000 Received: (at 35929) by debbugs.gnu.org; 30 May 2019 11:46:26 +0000 Received: from localhost ([127.0.0.1]:60877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWJVo-0006Hd-MH for submit@debbugs.gnu.org; Thu, 30 May 2019 07:46:25 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:57326) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWJVk-0006HI-Hl for 35929@debbugs.gnu.org; Thu, 30 May 2019 07:46:21 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 129E950182; Thu, 30 May 2019 13:46:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id kxG938Ykujsv; Thu, 30 May 2019 13:46:08 +0200 (CEST) From: Robert Vollmert Date: Thu, 30 May 2019 13:46:00 +0200 Message-Id: <20190530114601.31038-1-rob@vllmrt.net> MIME-Version: 1.0 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 I don't understand how/if this is possible on a macro level, and didn't find other facilities for runtime pattern matching than eval. Works, though! And if there's no better way, it should be fine for tests. * tests/hackage.scm: Import result pattern matching via eval. --- tests/hackage.scm | 136 +++++++++++++++++++++++----------------------- 1 file changed, 69 insertions(+), 67 deletions(-) diff --git a/tests/hackage.scm b/tests/hackage.scm index 0efad0638d..c50c0cc094 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -155,93 +155,95 @@ library (test-begin "hackage") -(define* (eval-test-with-cabal test-cabal #:key (cabal-environment '())) +(define* (match-pattern obj pattern) + (eval + `(match ',obj + (,pattern #t) + (x (pk 'fail x #f))) + (interaction-environment))) + +(define* (eval-test-with-cabal test-cabal package-pattern #: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))))) + (match-pattern + (hackage->guix-package "foo" #:cabal-environment cabal-environment) + package-pattern))) + +(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))) (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) From patchwork Thu May 30 11:46:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Vollmert X-Patchwork-Id: 14161 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 E2F4C17050; Thu, 30 May 2019 12:47:09 +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 autolearn=ham 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 9E9BC1704D for ; Thu, 30 May 2019 12:47:09 +0100 (BST) Received: from localhost ([127.0.0.1]:52579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWJWX-00035a-9g for patchwork@mira.cbaines.net; Thu, 30 May 2019 07:47:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWJWS-00035N-3A for guix-patches@gnu.org; Thu, 30 May 2019 07:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWJWR-0008FQ-32 for guix-patches@gnu.org; Thu, 30 May 2019 07:47:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWJWQ-0008EW-Vc for guix-patches@gnu.org; Thu, 30 May 2019 07:47:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hWJWQ-0006J8-Rt for guix-patches@gnu.org; Thu, 30 May 2019 07:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35929] [PATCH 2/2] tests: hackage: Don't mock hackage-fetch. Resent-From: Robert Vollmert Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 May 2019 11:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35929 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 35929@debbugs.gnu.org Received: via spool by 35929-submit@debbugs.gnu.org id=B35929.155921678724173 (code B ref 35929); Thu, 30 May 2019 11:47:02 +0000 Received: (at 35929) by debbugs.gnu.org; 30 May 2019 11:46:27 +0000 Received: from localhost ([127.0.0.1]:60879 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWJVr-0006Hp-1J for submit@debbugs.gnu.org; Thu, 30 May 2019 07:46:27 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:14772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWJVm-0006HL-JA for 35929@debbugs.gnu.org; Thu, 30 May 2019 07:46:23 -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 A5B4AA017F; Thu, 30 May 2019 13:46:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id ss71_aFiU3sU; Thu, 30 May 2019 13:46:15 +0200 (CEST) From: Robert Vollmert Date: Thu, 30 May 2019 13:46:01 +0200 Message-Id: <20190530114601.31038-2-rob@vllmrt.net> In-Reply-To: <20190530114601.31038-1-rob@vllmrt.net> References: <20190530114601.31038-1-rob@vllmrt.net> MIME-Version: 1.0 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 * tests/hackage.scm: Pass a string input port to tests instead of mocking hackage download. --- tests/hackage.scm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/hackage.scm b/tests/hackage.scm index c50c0cc094..f87e548177 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -163,14 +163,10 @@ library (interaction-environment))) (define* (eval-test-with-cabal test-cabal package-pattern #:key (cabal-environment '())) - (mock - ((guix import hackage) hackage-fetch - (lambda (name-version) - (call-with-input-string test-cabal - read-cabal))) - (match-pattern - (hackage->guix-package "foo" #:cabal-environment cabal-environment) - package-pattern))) + (define port (open-input-string test-cabal)) + (match-pattern + (hackage->guix-package "foo" #:port port #:cabal-environment cabal-environment) + package-pattern)) (define ghc-foo-pattern '('package