From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uH+BCjUqBWA4XgAA0tVLHw (envelope-from ) for ; Mon, 18 Jan 2021 06:27:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 2NgvBjUqBWDVOAAAbx9fmQ (envelope-from ) for ; Mon, 18 Jan 2021 06:27:01 +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 704709402C2 for ; Mon, 18 Jan 2021 06:27:00 +0000 (UTC) Received: from localhost ([::1]:52782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1O0B-0006n2-EB for larch@yhetil.org; Mon, 18 Jan 2021 01:26:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1NzG-0006mZ-Oz for guix-patches@gnu.org; Mon, 18 Jan 2021 01:26:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:34611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l1NzG-0001Bu-HS for guix-patches@gnu.org; Mon, 18 Jan 2021 01:26:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l1NzG-0003tH-D1 for guix-patches@gnu.org; Mon, 18 Jan 2021 01:26:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45948] [PATCH 1/5] build: test-driver.scm Make output redirection optional. References: <20210118061853.26808-1-maxim.cournoyer@gmail.com> In-Reply-To: <20210118061853.26808-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 18 Jan 2021 06:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45948 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45948@debbugs.gnu.org Received: via spool by 45948-submit@debbugs.gnu.org id=B45948.161095112214838 (code B ref 45948); Mon, 18 Jan 2021 06:26:02 +0000 Received: (at 45948) by debbugs.gnu.org; 18 Jan 2021 06:25:22 +0000 Received: from localhost ([127.0.0.1]:46142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1Nyc-0003rF-2O for submit@debbugs.gnu.org; Mon, 18 Jan 2021 01:25:22 -0500 Received: from mail-qk1-f171.google.com ([209.85.222.171]:37504) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1Nya-0003r0-Iq for 45948@debbugs.gnu.org; Mon, 18 Jan 2021 01:25:20 -0500 Received: by mail-qk1-f171.google.com with SMTP id h4so17820489qkk.4 for <45948@debbugs.gnu.org>; Sun, 17 Jan 2021 22:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4D8waMyo463f7J5zM1MjaZklpqHMDdYq3uncGDMN4Bk=; b=HvNmQVAUNsrr9ZzTroMvR6bCJpbgKf5271bOuW6gkZ8JvoZAVWr3+U+yYhLIJnlCQj D3MSmnl4kEJnp/LhtmuVdlZfCdrI6pMj4QKzscwSvXXhDBrJQeeKEq0eR7g5VbWDg/0s xnTOQTMZNjCX1ne16YsGinTMstgPo4r33AMW3YMLe8aVLWXSAZgacq7fqjCRlUxfdcu6 l6rFz1Z2wEGla4cTYlIDAWIUIEuq93sXX9X9Q101RMVaW0Ro84tre1bPLIThpUnTd4xb Mm23PfYWKuyUzsPxB2LHUpdXHW8iiw1G4+FBDHuQdGK2FqZgo9Hy0Z1NO3I5i7Neohta t31g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4D8waMyo463f7J5zM1MjaZklpqHMDdYq3uncGDMN4Bk=; b=jpbEWHfQSbMjk185FhDxfYUSNrsAQCdA2Boq6Yw6Olz37sx7Ytf26T1IWFVITTZzOE WGeDXePdiaOEc2U35fUXAHzIdBGBWs/FhICmSJM0agB3gtPmMHw4071Vs09ewAxz7fbD ROfQOsuCtOHZhf7gRSjD7hDGFAF5XLh7J3g4P0wHpCoDSHqx0dFYHlfUHsJtDYZ7b1Jy TYTsgqg+2gApCVs0tq2yNwxw/X8MRasQ8FvLt+w7ylK3Hz5sGvKWXazr7oFxE9Lz9Q9G NcinksDi7snJPzTAIzRQ8aBub4NE97wRwOYnWAjPkfq6aAmfWYU678mUqmiLyAen5aG9 Vv6g== X-Gm-Message-State: AOAM532SI/qwVuoKc9xQOP9aw21oygozq6qR4i1M1Z3cr4ZE0jpR962Z tvX+E3tJCZMDlWT9gJlD3DyvYG0qSY8= X-Google-Smtp-Source: ABdhPJwnAxWqy1hISecwYLj42Ny3jQXIeA2szCUNCnBHvY5RguSambN//01UCApOdBSk4pYq7ovlcQ== X-Received: by 2002:a37:52c1:: with SMTP id g184mr23271611qkb.364.1610951114832; Sun, 17 Jan 2021 22:25:14 -0800 (PST) Received: from localhost.localdomain (dsl-149-228.b2b2c.ca. [66.158.149.228]) by smtp.gmail.com with ESMTPSA id k187sm10266726qkc.74.2021.01.17.22.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:25:14 -0800 (PST) From: Maxim Cournoyer Date: Mon, 18 Jan 2021 01:24:56 -0500 Message-Id: <20210118062501.27022-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=yes Content-Transfer-Encoding: 8bit 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 X-Migadu-Spam-Score: -1.26 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=HvNmQVAU; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: 704709402C2 X-Spam-Score: -1.26 X-Migadu-Scanner: scn1.migadu.com X-TUID: acOcv3ETBdM6 This makes it easier (and less surprising) for users to experiment with the custom Scheme test driver directly. The behavior is unchanged from Automake's point of view. * build-aux/test-driver.scm (main): Make the --log-file and --trs-file arguments optional. Only open, redirect and close a port to a log file when the --log-file option is provided. Only open and close a port to a trs file when the --trs-file option is provided. (test-runner-gnu): Set OUT-PORT parameter default value to the current output port. Set the TRS-PORT parameter default value to a void port. Update doc. --- build-aux/test-driver.scm | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/build-aux/test-driver.scm b/build-aux/test-driver.scm index 52af1e9be7..b7622c3ed2 100644 --- a/build-aux/test-driver.scm +++ b/build-aux/test-driver.scm @@ -1,8 +1,9 @@ ;;;; test-driver.scm - Guile test driver for Automake testsuite harness -(define script-version "2017-03-22.13") ;UTC +(define script-version "2021-01-18.06") ;UTC ;;; Copyright © 2015, 2016 Mathieu Lirzin +;;; Copyright © 2021 Maxim Cournoyer ;;; ;;; This program is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by @@ -75,11 +76,14 @@ The '--test-name', '--log-file' and '--trs-file' options are mandatory.\n")) "") ;no color result))) -(define* (test-runner-gnu test-name #:key color? brief? out-port trs-port) +(define* (test-runner-gnu test-name #:key color? brief? + (out-port (current-output-port)) + (trs-port (%make-void-port "w"))) "Return an custom SRFI-64 test runner. TEST-NAME is a string specifying the file name of the current the test. COLOR? specifies whether to use colors, -and BRIEF?, well, you know. OUT-PORT and TRS-PORT must be output ports. The -current output port is supposed to be redirected to a '.log' file." +and BRIEF?, well, you know. OUT-PORT and TRS-PORT must be output ports. +OUT-PORT defaults to the current output port, while TRS-PORT defaults to a +void port, which means no TRS output is logged." (define (test-on-test-begin-gnu runner) ;; Procedure called at the start of an individual test case, before the @@ -156,20 +160,22 @@ current output port is supposed to be redirected to a '.log' file." ((option 'help #f) (show-help)) ((option 'version #f) (format #t "test-driver.scm ~A" script-version)) (else - (let ((log (open-file (option 'log-file "") "w0")) - (trs (open-file (option 'trs-file "") "wl")) - (out (duplicate-port (current-output-port) "wl"))) - (redirect-port log (current-output-port)) - (redirect-port log (current-warning-port)) - (redirect-port log (current-error-port)) + (let ((log (and=> (option 'log-file #f) (cut open-file <> "w0"))) + (trs (and=> (option 'trs-file #f) (cut open-file <> "wl"))) + (out (duplicate-port (current-output-port) "wl")) + (test-name (option 'test-name #f))) + (when log + (redirect-port log (current-output-port)) + (redirect-port log (current-warning-port)) + (redirect-port log (current-error-port))) (test-with-runner - (test-runner-gnu (option 'test-name #f) + (test-runner-gnu test-name #:color? (option->boolean opts 'color-tests) #:brief? (option->boolean opts 'brief) #:out-port out #:trs-port trs) - (load-from-path (option 'test-name #f))) - (close-port log) - (close-port trs) + (load-from-path test-name)) + (and=> log close-port) + (and=> trs close-port) (close-port out)))) (exit 0))) -- 2.29.2