From patchwork Tue May 16 15:39:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cully X-Patchwork-Id: 50044 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 5D0D327BBEA; Tue, 16 May 2023 16:40:19 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 38B4227BBE9 for ; Tue, 16 May 2023 16:40:18 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pywmW-00054M-Si; Tue, 16 May 2023 11:40:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pywmR-000541-LG for guix-patches@gnu.org; Tue, 16 May 2023 11:40:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pywmQ-0000dj-H5 for guix-patches@gnu.org; Tue, 16 May 2023 11:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pywmQ-0002hG-9N for guix-patches@gnu.org; Tue, 16 May 2023 11:40:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63538] [PATCH 1/3] tests: Add tests for MODIFY-SERVICES procedure Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 16 May 2023 15:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63538 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63538@debbugs.gnu.org Cc: Brian Cully X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168425159910349 (code B ref -1); Tue, 16 May 2023 15:40:02 +0000 Received: (at submit) by debbugs.gnu.org; 16 May 2023 15:39:59 +0000 Received: from localhost ([127.0.0.1]:47003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pywmN-0002gr-0v for submit@debbugs.gnu.org; Tue, 16 May 2023 11:39:59 -0400 Received: from lists.gnu.org ([209.51.188.17]:36406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pywmJ-0002gi-KR for submit@debbugs.gnu.org; Tue, 16 May 2023 11:39:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pywmJ-00053D-Bb for guix-patches@gnu.org; Tue, 16 May 2023 11:39:55 -0400 Received: from coleridge.kublai.com ([166.84.7.167] helo=mail.spork.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pywmH-0000a5-R9 for guix-patches@gnu.org; Tue, 16 May 2023 11:39:55 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id BEA7FA74E; Tue, 16 May 2023 11:39:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1684251582; bh=hxk+inCuFrsozG8yBZ/fh8ZBc7VPOkKQkLgLow1kRoU=; h=From:To:Cc:Subject:Date; b=HbmO5axiZ+hy2Lu8aOb3AtX6olqbFBXeGs1WS9zgrqGGM9/payO0Pg64cUaqhPiGI JmoBQdigQRwPSQkbcuwXl0si+I8Ep0oA8MtaOrdhcHW5VykROv/gzaiYufkwfhLDC3 0eyq1YRNl2kWMF/7zG3P7TV5hd8xmhwckJCyzwL0= Date: Tue, 16 May 2023 11:39:37 -0400 Message-Id: <999ea3ff3ea32e4e1bb8b7b8abd4e0e29d1f2395.1684251578.git.bjc@spork.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Received-SPF: pass client-ip=166.84.7.167; envelope-from=bjc@spork.org; helo=mail.spork.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches X-Patchwork-Original-From: Brian Cully via Guix-patches via From: Brian Cully Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * tests/services.scm ("modify-services: do nothing") ("modify-services: delete service") ("modify-services: change value"): New tests. --- tests/services.scm | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) base-commit: b363fab46f5af42b3f653e2fee1834477bd5aacd prerequisite-patch-id: 8a03c5e8bcd4c526b93c558d550725887f932e41 prerequisite-patch-id: 89400c29b4c30dfbe8492aff1751ca583397b4f0 prerequisite-patch-id: a1963f772e753239b80e6a7b0d9f55e0ab4d662b prerequisite-patch-id: b047430c30ba9ea274aea33a467cdb49d769884e diff --git a/tests/services.scm b/tests/services.scm index 8e35758209..435f39e59b 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -286,4 +286,54 @@ (define-module (test-services) ((one) one) (x x)))) +(test-equal "modify-services: do nothing" + '(1 2 3) + (let* ((t1 (service-type (name 't1) + (extensions '()) + (description ""))) + (t2 (service-type (name 't2) + (extensions '()) + (description ""))) + (t3 (service-type (name 't3) + (extensions '()) + (description ""))) + (services (list (service t1 1) (service t2 2) (service t3 3)))) + (sort (map service-value + (modify-services services)) + <))) + +(test-equal "modify-services: delete service" + '(1 3) + (let* ((t1 (service-type (name 't1) + (extensions '()) + (description ""))) + (t2 (service-type (name 't2) + (extensions '()) + (description ""))) + (t3 (service-type (name 't3) + (extensions '()) + (description ""))) + (services (list (service t1 1) (service t2 2) (service t3 3)))) + (sort (map service-value + (modify-services services + (delete t2))) + <))) + +(test-equal "modify-services: change value" + '(1 2 33) + (let* ((t1 (service-type (name 't1) + (extensions '()) + (description ""))) + (t2 (service-type (name 't2) + (extensions '()) + (description ""))) + (t3 (service-type (name 't3) + (extensions '()) + (description ""))) + (services (list (service t1 1) (service t2 2) (service t3 3)))) + (sort (map service-value + (modify-services services + (t3 value => 33))) + <))) + (test-end) From patchwork Tue May 16 15:41:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cully X-Patchwork-Id: 50046 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 9E27E27BBEA; Tue, 16 May 2023 16:42:21 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 19A6327BBE9 for ; Tue, 16 May 2023 16:42:21 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pywoN-0005Wc-51; Tue, 16 May 2023 11:42:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pywoM-0005Uv-0q for guix-patches@gnu.org; Tue, 16 May 2023 11:42:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pywoL-00017N-OY for guix-patches@gnu.org; Tue, 16 May 2023 11:42:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pywoL-0002l3-Hg for guix-patches@gnu.org; Tue, 16 May 2023 11:42:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63538] [PATCH 2/3] tests: Check for service existence in MODIFY-SERVICES Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 16 May 2023 15:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63538 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63538@debbugs.gnu.org Cc: Brian Cully Received: via spool by 63538-submit@debbugs.gnu.org id=B63538.168425171410581 (code B ref 63538); Tue, 16 May 2023 15:42:01 +0000 Received: (at 63538) by debbugs.gnu.org; 16 May 2023 15:41:54 +0000 Received: from localhost ([127.0.0.1]:47012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pywoE-0002kV-HJ for submit@debbugs.gnu.org; Tue, 16 May 2023 11:41:54 -0400 Received: from coleridge.kublai.com ([166.84.7.167]:64233 helo=mail.spork.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pywoC-0002kL-0T for 63538@debbugs.gnu.org; Tue, 16 May 2023 11:41:52 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id CA9F4A5B2; Tue, 16 May 2023 11:41:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1684251711; bh=ikE1xPgGYduWuSPJH+JWsPYbaanAKw81Oosrc+MuUeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jugEo8KMCirYetYWTYfFaaNNV41FrNvad2+1pv2CmzV3x0269E8ypO36eH08W7EYA 2oKSDHLyyyHD0rKFEzdQToZfp+6iiaCv0RG/3pemvYpavuwwJKMpggV61KMGihSFwG DR6P+LOkwVWDsgqn6LQC8k5SNbmssXiuPKONRopo= Date: Tue, 16 May 2023 11:41:41 -0400 Message-Id: <4de40059943bdd7fa6cc45a70a9cd1087edad57d.1684251702.git.bjc@spork.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <999ea3ff3ea32e4e1bb8b7b8abd4e0e29d1f2395.1684251702.git.bjc@spork.org> References: <999ea3ff3ea32e4e1bb8b7b8abd4e0e29d1f2395.1684251702.git.bjc@spork.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches X-Patchwork-Original-From: Brian Cully via Guix-patches via From: Brian Cully Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * tests/services.scm ("modify-services: delete non-existing service") ("modify-services: change value for non-existing service"): New tests. --- tests/services.scm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/services.scm b/tests/services.scm index 435f39e59b..5a9cd47489 100644 --- a/tests/services.scm +++ b/tests/services.scm @@ -319,6 +319,21 @@ (define-module (test-services) (delete t2))) <))) +(test-error "modify-services: delete non-existing service" + #t + (let* ((t1 (service-type (name 't1) + (extensions '()) + (description ""))) + (t2 (service-type (name 't2) + (extensions '()) + (description ""))) + (t3 (service-type (name 't2) + (extensions '()) + (description ""))) + (services (list (service t1 1) (service t2 2)))) + (modify-services services + (delete t3)))) + (test-equal "modify-services: change value" '(1 2 33) (let* ((t1 (service-type (name 't1) @@ -336,4 +351,20 @@ (define-module (test-services) (t3 value => 33))) <))) +(test-error "modify-services: change value for non-existing service" + #t + (let* ((t1 (service-type (name 't1) + (extensions '()) + (description ""))) + (t2 (service-type (name 't2) + (extensions '()) + (description ""))) + (t3 (service-type (name 't3) + (extensions '()) + (description ""))) + (services (list (service t1 1) (service t3 3)))) + (map service-value + (modify-services services + (t2 value => 22))))) + (test-end) From patchwork Tue May 16 15:41:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cully X-Patchwork-Id: 50045 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 1218927BBEA; Tue, 16 May 2023 16:42:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 40A7127BBE2 for ; Tue, 16 May 2023 16:42:10 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pywoO-0005X8-2V; Tue, 16 May 2023 11:42:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pywoM-0005Vy-IM for guix-patches@gnu.org; Tue, 16 May 2023 11:42:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pywoM-00018Q-3A for guix-patches@gnu.org; Tue, 16 May 2023 11:42:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pywoL-0002lA-Un for guix-patches@gnu.org; Tue, 16 May 2023 11:42:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63538] [PATCH 3/3] gnu: services: Error in MODIFY-SERVICES when services don't exist Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 16 May 2023 15:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63538 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63538@debbugs.gnu.org Cc: Brian Cully Received: via spool by 63538-submit@debbugs.gnu.org id=B63538.168425171710590 (code B ref 63538); Tue, 16 May 2023 15:42:01 +0000 Received: (at 63538) by debbugs.gnu.org; 16 May 2023 15:41:57 +0000 Received: from localhost ([127.0.0.1]:47014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pywoG-0002kk-SD for submit@debbugs.gnu.org; Tue, 16 May 2023 11:41:57 -0400 Received: from coleridge.kublai.com ([166.84.7.167]:58179 helo=mail.spork.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pywoE-0002kU-5s for 63538@debbugs.gnu.org; Tue, 16 May 2023 11:41:54 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id 01292A753; Tue, 16 May 2023 11:41:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1684251714; bh=TpDxmyOBFJGOK8zw0jml7uH4HGnwt/1CMv3Xvfet96w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VoHH2LJVyMKlSOlpDR6rP+TQNoHKs4lWc5aWQSvsQeeYYWE183e63i5Q+XNySxahK nF9MmLsKkpMOmmYf4RaB/+PgaQvwtC0CcHP/SYiL0ue0yg3cRSnbVa+cwMMp6S/4Ns 8yUaSKflFpUPzJSgjSC4YD1OybEy0+akXpb2Eyhk= Date: Tue, 16 May 2023 11:41:42 -0400 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: <999ea3ff3ea32e4e1bb8b7b8abd4e0e29d1f2395.1684251702.git.bjc@spork.org> References: <999ea3ff3ea32e4e1bb8b7b8abd4e0e29d1f2395.1684251702.git.bjc@spork.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches X-Patchwork-Original-From: Brian Cully via Guix-patches via From: Brian Cully Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This patch causes MODIFY-SERVICES to raise an error if a reference is made to a service which isn't in its service list. This it to help users notice if they have an invalid rule, which is currently silently ignored. * gnu/services.scm (%delete-service): new procedure (%apply-clauses): new syntax rule (%modify-service): remove syntax rule --- gnu/services.scm | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/gnu/services.scm b/gnu/services.scm index d6c7ad0553..988325b253 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -296,20 +296,35 @@ (define (simple-service name target value) (description "This is a simple service.")))) (service type value))) -(define-syntax %modify-service +(define (%delete-service kind services) + (let loop ((found #f) + (return '()) + (services services)) + (match services + ('() + (if found + (values return found) + (raise (formatted-message + (G_ "modify-services: service '~a' not found in service list") + (service-type-name kind))))) + ((svc . rest) + (if (eq? (service-kind svc) kind) + (loop svc return rest) + (loop found (cons svc return) rest)))))) + +(define-syntax %apply-clauses (syntax-rules (=> delete) - ((_ svc (delete kind) clauses ...) - (if (eq? (service-kind svc) kind) - #f - (%modify-service svc clauses ...))) - ((_ service) - service) - ((_ svc (kind param => exp ...) clauses ...) - (if (eq? (service-kind svc) kind) - (let ((param (service-value svc))) - (service (service-kind svc) - (begin exp ...))) - (%modify-service svc clauses ...))))) + ((_ ((delete kind) . rest) services) + (%apply-clauses rest (%delete-service kind services))) + ((_ ((kind param => exp ...) . rest) services) + (call-with-values (lambda () (%delete-service kind services)) + (lambda (svcs found) + (let ((param (service-value found))) + (cons (service (service-kind found) + (begin exp ...)) + svcs))))) + ((_ () services) + services))) (define-syntax modify-services (syntax-rules () @@ -345,10 +360,8 @@ (define-syntax modify-services UDEV-SERVICE-TYPE. This is a shorthand for (filter-map (lambda (svc) ...) %base-services)." - ((_ services clauses ...) - (filter-map (lambda (service) - (%modify-service service clauses ...)) - services)))) + ((_ services . clauses) + (%apply-clauses clauses services)))) ;;;