From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id zmycL2zi0mBKBwEAgWs5BA (envelope-from ) for ; Wed, 23 Jun 2021 09:27:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id KJ6lKmzi0mD1agAAbx9fmQ (envelope-from ) for ; Wed, 23 Jun 2021 07:27:40 +0000 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 EDE9C154CA for ; Wed, 23 Jun 2021 09:27:39 +0200 (CEST) Received: from localhost ([::1]:44434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvxIP-0003jD-Vv for larch@yhetil.org; Wed, 23 Jun 2021 03:27:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvxHq-0003hf-L9 for guix-patches@gnu.org; Wed, 23 Jun 2021 03:27:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvxHq-0007mw-Ck for guix-patches@gnu.org; Wed, 23 Jun 2021 03:27:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lvxHq-0002wh-BP for guix-patches@gnu.org; Wed, 23 Jun 2021 03:27:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49181] [PATCH 1/1] guix: Make modify-phases error when adding before/after a missing phase Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 23 Jun 2021 07:27:02 +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: carlo@zancanaro.id.au Received: via spool by 49181-submit@debbugs.gnu.org id=B49181.162443317311230 (code B ref 49181); Wed, 23 Jun 2021 07:27:02 +0000 Received: (at 49181) by debbugs.gnu.org; 23 Jun 2021 07:26:13 +0000 Received: from localhost ([127.0.0.1]:40320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvxGz-0002v1-Ul for submit@debbugs.gnu.org; Wed, 23 Jun 2021 03:26:13 -0400 Received: from mailrelay.tugraz.at ([129.27.2.202]:41846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvxGu-0002ud-US for 49181@debbugs.gnu.org; Wed, 23 Jun 2021 03:26:07 -0400 Received: from localhost.localdomain (62-116-34-49.adsl.highway.telekom.at [62.116.34.49]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4G8vvG415Jz3wGN; Wed, 23 Jun 2021 09:26:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1624433162; bh=HgxJ/Z3/n9DQG5QYrUJB3O8c1qvhUZeMxcMdxLC9BZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ff47mQ2GcZivtSNRPzmz8V8hYhNRf1P7B/7XgFBB3BNjhsguIHSucVCOC4sbXuklx 4LArIIjMOS2RyNMqkeauUpwZpOxlQYb4mHrAUXqfOat/47MPJBFDUdIBog9nWo4za+ Tq8y7Ywd4Pm9j9H61MC5wR5yi+e1XwDVtE7tInFc= From: Leo Prikler Date: Wed, 23 Jun 2021 09:25:10 +0200 Message-Id: <20210623072509.7165-2-leo.prikler@student.tugraz.at> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210623072509.7165-1-leo.prikler@student.tugraz.at> References: <20210623072509.7165-1-leo.prikler@student.tugraz.at> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 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: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624433260; 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=HgxJ/Z3/n9DQG5QYrUJB3O8c1qvhUZeMxcMdxLC9BZo=; b=GMdXOfGMpxBf7WB1/r395mDW3ctkP3xJbSsLvkf3p7HXarp6PxaXmw22Ut75+B5MKrW00+ 5IYd4XkYzr5Q6hIYMmw4gt1PfPZpK9XbfPxJbV/CCIug9gZbPZFdgOIL5PeYzQ5TTD7YYs 2pFWkkuhPUq6ydK5sVqvVZnffK1rxHceNh3tqQQQK/Qf8T65mGWI2C0hHwJuiiN5y3miaM zB+ozpKl3VvMcWG3mZ3oUajojpYJIDHAbWRZ7ujzfLBBwkwD0OPV4sYXSSPjlZe7OYnAIx LYKLrsaTgYdzRZJKcet2JioLormFca8uMt2Q/siuDgq5jOqxdSZtHuU7vSScGA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624433260; a=rsa-sha256; cv=none; b=gp4o/x167TUXxASho/GK1OH/Wg5d5lpPT40WgXs7E0AsmykjpzpikJi/1kyL/IgDKCDryx 3o6l94203MkIKc3m53orOsxY56nZ1IIFlT3B7WjPMl/ik/2ZoLSIliJRgZ/DAqu85q16D5 ieHPfDyq6LK6bN3tYrQ+2w69e/bSwq6YlGV4SsvX+5t+6sV8GXqPndLMhexIx94ufYa+Al /RfhGMjGl2C3QIEDImWx2b47xZhVbmBGqIK17XACQNFiT4r9ZFJgnwxFcdhvfJP7RD2kWG 7WKYZomX9GIX1+IDVKOtaQpJpsLhzRK4i0NtCR/6vbqo44izNyGKVHny3vtb0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tugraz.at header.s=mailrelay header.b=ff47mQ2G; dmarc=fail reason="SPF not aligned (relaxed)" header.from=student.tugraz.at (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tugraz.at header.s=mailrelay header.b=ff47mQ2G; dmarc=fail reason="SPF not aligned (relaxed)" header.from=student.tugraz.at (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: EDE9C154CA X-Spam-Score: -0.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: Wa6NWZmQrRip From: Carlo Zancanaro * 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 419c10195b..6e052a7ea1 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2015, 2018 Mark H Weaver ;;; Copyright © 2018 Arun Isaac ;;; Copyright © 2018, 2019 Ricardo Wurmus +;;; Copyright © 2021 Carlo Zancanaro ;;; ;;; This file is part of GNU Guix. ;;; @@ -571,18 +572,22 @@ effects, such as displaying warnings or error messages." (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 + ((reference after ...) + (append before (alist-cons key value (cons reference 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 . _) @@ -590,9 +595,7 @@ is REFERENCE in ALIST. Use KEY=? to compare keys." 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 654b480ed9..c694b479b3 100644 --- a/tests/build-utils.scm +++ b/tests/build-utils.scm @@ -38,17 +38,17 @@ '((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)) -- 2.32.0