From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ZqJmBvzTaGQzuAAASxT56A (envelope-from ) for ; Sat, 20 May 2023 16:06:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id SLF+BfzTaGQyPgAA9RJhRA (envelope-from ) for ; Sat, 20 May 2023 16:06:52 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EC4D121BA6 for ; Sat, 20 May 2023 16:06:50 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q0NE6-0005nU-EV; Sat, 20 May 2023 10:06:30 -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 1q0MHa-0004RM-Ke for guix-patches@gnu.org; Sat, 20 May 2023 09:06: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 1q0MHa-0000of-CU for guix-patches@gnu.org; Sat, 20 May 2023 09:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q0MHZ-0006VW-UW for guix-patches@gnu.org; Sat, 20 May 2023 09:06:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49181] [PATCH core-updates v2] guix: Make modify-phases error when adding before/after a missing phase References: <87k0mlaxkn.fsf@zancanaro.id.au> In-Reply-To: <87k0mlaxkn.fsf@zancanaro.id.au> Resent-From: Carlo Zancanaro Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 20 May 2023 13:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49181 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 49181@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 49181-submit@debbugs.gnu.org id=B49181.168458793624979 (code B ref 49181); Sat, 20 May 2023 13:06:01 +0000 Received: (at 49181) by debbugs.gnu.org; 20 May 2023 13:05:36 +0000 Received: from localhost ([127.0.0.1]:58016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0MHA-0006Up-7C for submit@debbugs.gnu.org; Sat, 20 May 2023 09:05:36 -0400 Received: from voltorb.zancanaro.id.au ([45.77.50.64]:49854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0MH5-0006UX-SY for 49181@debbugs.gnu.org; Sat, 20 May 2023 09:05:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=k1; bh=6s1ZJSIDMOZel0j MWwyHQjWy8WhNfzzHEyLzgMTviPw=; h=date:subject:cc:to:from; d=zancanaro.id.au; b=FS8nuJUSQ2ggr7hSg2dCjtYqJyeZ9PljL1lW5kPBwnh5gdtbG i8WKEvrJ8SMRVuAEAb0HklWsr0eQfY7Ry3tMZj3cMrosdAMRL64noS7abSzwxbUeymtx3u qhzDCZZtIGNQTdZkHiKE3JmbjHwX2OUrBh8mFxc6iBB7F0H8jSEo= Received: by voltorb.zancanaro.id.au (OpenSMTPD) with ESMTPSA id b45418a1 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 20 May 2023 13:05:16 +0000 (UTC) From: Carlo Zancanaro Date: Sat, 20 May 2023 23:05:06 +1000 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Sat, 20 May 2023 10:06:27 -0400 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1684591611; a=rsa-sha256; cv=none; b=CWCvh7PTL50moTVONdtkDekWPU5WCXwxJliuuH8+HlPJFn98n+TPMaDLHSthmfrUGYnmRc g7ffWePQB4joGhl+ieYUez8j23Wt3/ipKVHzLFld3/5tmaNT4gcQOUfVZyi5vPhFXrkm4A DTPgBG/A5jealD3Vy6hsE2kwhdG2MnXQ3ru0iw6qYUZIHmd461Tzf8L6WsPpnV9w8oGZjI hl99bEi8EqeRzZ8FNMOZPi59vjxFwJw0pUMABh80pXUJZV6/84PZeU2rXNlOb/xZkE4XEn 0HyD578rIUmImCYXRxoVZXxTYL8YhS5VG5pT9x8pLqszkIyJNfbolC8actTU6g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=zancanaro.id.au header.s=k1 header.b=FS8nuJUS; dmarc=fail reason="SPF not aligned (relaxed)" header.from=zancanaro.id.au (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1684591611; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=6s1ZJSIDMOZel0jMWwyHQjWy8WhNfzzHEyLzgMTviPw=; b=LPXzZySz21eV7UeAueel+nX1n56871R2xIANTmAovoYEJy6e4G5UIB6B+mFwZnTjC1pHfk K8BgmgVJHRF4Bu0zIVgNnYXL5zf3ZdI3aNolGW7uUYLxf2kNRWqw9GdbHIoG6Jbb/wh1U1 7TLJHLG2R9kDOGkbFLtP92CBpAH7ftmRKpBZQSuu4MMVDKZF4IjXxQB7TX07I1zycr1ppU oU4qe3uaWInZKgoBaYCBdz9GgzNHpS0pCICGlQxMmn5w+ecPx9zLLIhXbwLLsViFc46hd1 Mcz7eDjlAy+wQsM7k08loraoVpNbdeXZgW58knWjvi8AFt9glTg5cc2cb80wzw== X-Migadu-Spam-Score: 0.42 X-Spam-Score: 0.42 X-Migadu-Queue-Id: EC4D121BA6 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=zancanaro.id.au header.s=k1 header.b=FS8nuJUS; dmarc=fail reason="SPF not aligned (relaxed)" header.from=zancanaro.id.au (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-TUID: IAt8IW2I2+kB * guix/build/utils.scm (alist-cons-before, alist-cons-after): Cause a match failure if the reference is not found, rather than appending to the alist. * tests/build-utils.scm: Update tests to match. --- guix/build/utils.scm | 15 +++++++++------ tests/build-utils.scm | 12 ++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 2352a627e9..8e630ad586 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2020, 2021 Maxim Cournoyer ;;; Copyright © 2021, 2022 Maxime Devos ;;; Copyright © 2021 Brendan Tildesley +;;; Copyright © 2023 Carlo Zancanaro ;;; ;;; This file is part of GNU Guix. ;;; @@ -729,18 +730,22 @@ (define (every* pred lst) (define* (alist-cons-before reference key value alist #:optional (key=? equal?)) "Insert the KEY/VALUE pair before the first occurrence of a pair whose key -is REFERENCE in ALIST. Use KEY=? to compare keys." +is REFERENCE in ALIST. Use KEY=? to compare keys. An error is raised when no +such pair exists." (let-values (((before after) (break (match-lambda ((k . _) (key=? k reference))) alist))) - (append before (alist-cons key value after)))) + (match after + ((_ _ ...) + (append before (alist-cons key value after)))))) (define* (alist-cons-after reference key value alist #:optional (key=? equal?)) "Insert the KEY/VALUE pair after the first occurrence of a pair whose key -is REFERENCE in ALIST. Use KEY=? to compare keys." +is REFERENCE in ALIST. Use KEY=? to compare keys. An error is raised when +no such pair exists." (let-values (((before after) (break (match-lambda ((k . _) @@ -748,9 +753,7 @@ (define* (alist-cons-after reference key value alist alist))) (match after ((reference after ...) - (append before (cons* reference `(,key . ,value) after))) - (() - (append before `((,key . ,value))))))) + (append before (cons* reference `(,key . ,value) after)))))) (define* (alist-replace key value alist #:optional (key=? equal?)) "Replace the first pair in ALIST whose car is KEY with the KEY/VALUE pair. diff --git a/tests/build-utils.scm b/tests/build-utils.scm index 7f4f12ccc7..3babf5d544 100644 --- a/tests/build-utils.scm +++ b/tests/build-utils.scm @@ -41,17 +41,17 @@ (define-module (test build-utils) '((a . 1) (x . 42) (b . 2) (c . 3)) (alist-cons-before 'b 'x 42 '((a . 1) (b . 2) (c . 3)))) -(test-equal "alist-cons-before, reference not found" - '((a . 1) (b . 2) (c . 3) (x . 42)) - (alist-cons-before 'z 'x 42 '((a . 1) (b . 2) (c . 3)))) +(test-assert "alist-cons-before, reference not found" + (not (false-if-exception + (alist-cons-before 'z 'x 42 '((a . 1) (b . 2) (c . 3)))))) (test-equal "alist-cons-after" '((a . 1) (b . 2) (x . 42) (c . 3)) (alist-cons-after 'b 'x 42 '((a . 1) (b . 2) (c . 3)))) -(test-equal "alist-cons-after, reference not found" - '((a . 1) (b . 2) (c . 3) (x . 42)) - (alist-cons-after 'z 'x 42 '((a . 1) (b . 2) (c . 3)))) +(test-assert "alist-cons-after, reference not found" + (not (false-if-exception + (alist-cons-after 'z 'x 42 '((a . 1) (b . 2) (c . 3)))))) (test-equal "alist-replace" '((a . 1) (b . 77) (c . 3)) base-commit: 24b6f94cf9b4ab97ef2eb70d05b2104a06776e62 -- 2.40.1