From patchwork Sat Jun 1 22:27:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Vollmert X-Patchwork-Id: 14195 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 CC8181707B; Sat, 1 Jun 2019 23:29:08 +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 5E86017079 for ; Sat, 1 Jun 2019 23:29:08 +0100 (BST) Received: from localhost ([127.0.0.1]:42069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXCUt-0005vG-8r for patchwork@mira.cbaines.net; Sat, 01 Jun 2019 18:29:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXCUq-0005uv-IV for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXCUp-0008Cl-Ei for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXCUp-0008Cd-Br for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hXCUp-0003nJ-7u for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36047] [PATCH 1/2] tests: hackage: Test multiline cabal description. Resent-From: Robert Vollmert Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 01 Jun 2019 22:29:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36047 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 36047@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155942809514513 (code B ref -1); Sat, 01 Jun 2019 22:29:03 +0000 Received: (at submit) by debbugs.gnu.org; 1 Jun 2019 22:28:15 +0000 Received: from localhost ([127.0.0.1]:38930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hXCU2-0003lv-Qf for submit@debbugs.gnu.org; Sat, 01 Jun 2019 18:28:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hXCU0-0003lb-Fa for submit@debbugs.gnu.org; Sat, 01 Jun 2019 18:28:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:41369) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXCTv-0007pK-BT for submit@debbugs.gnu.org; Sat, 01 Jun 2019 18:28:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXCTu-0005rp-5Z for guix-patches@gnu.org; Sat, 01 Jun 2019 18:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXCTt-0007kf-1G for guix-patches@gnu.org; Sat, 01 Jun 2019 18:28:06 -0400 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]:31458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXCTs-0007hp-RU for guix-patches@gnu.org; Sat, 01 Jun 2019 18:28:04 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id D54054F184; Sun, 2 Jun 2019 00:28:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id lZ6xqH2-WxZF; Sun, 2 Jun 2019 00:27:52 +0200 (CEST) From: Robert Vollmert Date: Sun, 2 Jun 2019 00:27:49 +0200 Message-Id: <20190601222750.74262-1-rob@vllmrt.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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 * tests/hackage.scm: Add test case with multi-line description. --- tests/hackage.scm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/hackage.scm b/tests/hackage.scm index 269c1e1f9b..2f45194fab 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -236,6 +236,25 @@ library (test-assert "hackage->guix-package test 6" (eval-test-with-cabal test-cabal-6 match-ghc-foo-6)) +;; Check multi-line layouted description +(define test-cabal-multiline-desc + "name: foo +version: 1.0.0 +homepage: http://test.org +synopsis: synopsis +description: first line + second line +license: BSD3 +executable cabal + build-depends: + HTTP >= 4000.2.5 && < 4000.3, + mtl >= 2.0 && < 3 +") + +(test-assert "hackage->guix-package test multiline desc" + (eval-test-with-cabal test-cabal-multiline-desc match-ghc-foo)) + + (test-assert "read-cabal test 1" (match (call-with-input-string test-read-cabal-1 read-cabal) ((("name" ("test-me")) From patchwork Sat Jun 1 22:27:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Vollmert X-Patchwork-Id: 14196 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 F3A151707A; Sat, 1 Jun 2019 23:29:08 +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 306B617074 for ; Sat, 1 Jun 2019 23:29:08 +0100 (BST) Received: from localhost ([127.0.0.1]:42071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXCUt-0005vK-Gw for patchwork@mira.cbaines.net; Sat, 01 Jun 2019 18:29:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXCUq-0005uu-2A for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXCUo-0008CP-NI for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXCUo-0008CG-KI for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hXCUo-0003n5-Ec for guix-patches@gnu.org; Sat, 01 Jun 2019 18:29:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36046] [PATCH 2/2] guix import hackage: Parse braced properties. Resent-From: Robert Vollmert Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 01 Jun 2019 22:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36046 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 36046@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155942809414506 (code B ref -1); Sat, 01 Jun 2019 22:29:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Jun 2019 22:28:14 +0000 Received: from localhost ([127.0.0.1]:38928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hXCU2-0003lt-AL for submit@debbugs.gnu.org; Sat, 01 Jun 2019 18:28:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60831) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hXCTz-0003lZ-Vb for submit@debbugs.gnu.org; Sat, 01 Jun 2019 18:28:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:53340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXCTu-0007n8-Qd for submit@debbugs.gnu.org; Sat, 01 Jun 2019 18:28:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXCTt-0005rJ-8d for guix-patches@gnu.org; Sat, 01 Jun 2019 18:28:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXCTr-0007j4-Sc for guix-patches@gnu.org; Sat, 01 Jun 2019 18:28:05 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:56830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXCTr-0007hv-Jq for guix-patches@gnu.org; Sat, 01 Jun 2019 18:28:03 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 3053F4F779; Sun, 2 Jun 2019 00:28:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id 6_rT3LP9aA-w; Sun, 2 Jun 2019 00:27:55 +0200 (CEST) From: Robert Vollmert Date: Sun, 2 Jun 2019 00:27:50 +0200 Message-Id: <20190601222750.74262-2-rob@vllmrt.net> In-Reply-To: <20190601222750.74262-1-rob@vllmrt.net> References: <20190601222750.74262-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 adds partial support for cabal properties that use curly braces instead of the layout rule. See for example https://hackage.haskell.org/package/cassava/ * guix/import/cabal.scm: Generalize property parsing to both layouted and simple braced blocks. * guix/tests/hackage.scm: Test braced description import. --- guix/import/cabal.scm | 35 ++++++++++++++++++++++++++++------- tests/hackage.scm | 25 ++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index 13c2f3f48c..1a87be0b00 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -270,6 +270,10 @@ following lines with indentation larger than MIN-INDENT." (peek-next-line-indent port))) val))) +(define* (read-braced-value port) + "Read up to a closing brace." + (string-trim-both (read-delimited "}" port 'trim))) + (define (lex-white-space port bol) "Consume white spaces and comment lines on PORT. If a new line is started return #t, otherwise return BOL (beginning-of-line)." @@ -343,8 +347,11 @@ matching a string against the created regexp." (make-regexp pat)))) (cut regexp-exec rx <>))) -(define is-property (make-rx-matcher "([a-z0-9-]+)[ \t]*:[ \t]*(\\w?.*)$" - regexp/icase)) +(define is-layout-property (make-rx-matcher "([a-z0-9-]+)[ \t]*:[ \t]*(\\w?[^{}]*)$" + regexp/icase)) + +(define is-braced-property (make-rx-matcher "([a-z0-9-]+)[ \t]*:[ \t]*\\{[ \t]*$" + regexp/icase)) (define is-flag (make-rx-matcher "^flag +([a-z0-9_-]+)" regexp/icase)) @@ -435,13 +442,19 @@ string with the read characters." (begin (unread-char c) (list->string res))))) (else (list->string res))))) -(define (lex-property k-v-rx-res loc port) +(define (lex-layout-property k-v-rx-res loc port) (let ((key (string-downcase (match:substring k-v-rx-res 1))) (value (match:substring k-v-rx-res 2))) (make-lexical-token 'PROPERTY loc (list key `(,(read-value port value (current-indentation))))))) +(define (lex-braced-property k-rx-res loc port) + (let ((key (string-downcase (match:substring k-rx-res 1)))) + (make-lexical-token + 'PROPERTY loc + (list key `(,(read-braced-value port)))))) + (define (lex-rx-res rx-res token loc) (let ((name (string-downcase (match:substring rx-res 1)))) (make-lexical-token token loc name))) @@ -552,7 +565,6 @@ LOC is the current port location." the current port location." (let* ((s (read-delimited "\n{}" port 'peek))) (cond - ((is-property s) => (cut lex-property <> loc port)) ((is-flag s) => (cut lex-flag <> loc)) ((is-src-repo s) => (cut lex-src-repo <> loc)) ((is-exec s) => (cut lex-exec <> loc)) @@ -561,13 +573,22 @@ the current port location." ((is-benchmark s) => (cut lex-benchmark <> loc)) ((is-lib s) (lex-lib loc)) ((is-else s) (lex-else loc)) - (else - #f)))) + (else (unread-string s port) #f)))) + +(define (lex-property port loc) + (let* ((s (read-delimited "\n" port 'peek))) + (cond + ((is-braced-property s) => (cut lex-braced-property <> loc port)) + ((is-layout-property s) => (cut lex-layout-property <> loc port)) + (else #f)))) (define (lex-token port) (let* ((loc (make-source-location (cabal-file-name) (port-line port) (port-column port) -1 -1))) - (or (lex-single-char port loc) (lex-word port loc) (lex-line port loc)))) + (or (lex-single-char port loc) + (lex-word port loc) + (lex-line port loc) + (lex-property port loc)))) ;; Lexer- and error-function generators diff --git a/tests/hackage.scm b/tests/hackage.scm index 2f45194fab..38a5825af7 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -237,7 +237,7 @@ library (eval-test-with-cabal test-cabal-6 match-ghc-foo-6)) ;; Check multi-line layouted description -(define test-cabal-multiline-desc +(define test-cabal-multiline-layout "name: foo version: 1.0.0 homepage: http://test.org @@ -251,9 +251,28 @@ executable cabal mtl >= 2.0 && < 3 ") -(test-assert "hackage->guix-package test multiline desc" - (eval-test-with-cabal test-cabal-multiline-desc match-ghc-foo)) +(test-assert "hackage->guix-package test multiline desc (layout)" + (eval-test-with-cabal test-cabal-multiline-layout match-ghc-foo)) +;; Check multi-line braced description +(define test-cabal-multiline-braced + "name: foo +version: 1.0.0 +homepage: http://test.org +synopsis: synopsis +description: { +first line +second line +} +license: BSD3 +executable cabal + build-depends: + HTTP >= 4000.2.5 && < 4000.3, + mtl >= 2.0 && < 3 +") + +(test-assert "hackage->guix-package test multiline desc (braced)" + (eval-test-with-cabal test-cabal-multiline-braced match-ghc-foo)) (test-assert "read-cabal test 1" (match (call-with-input-string test-read-cabal-1 read-cabal)