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 ms5.migadu.com with LMTPS id MGRAHLSidmI1PAAAbAwnHQ (envelope-from ) for ; Sat, 07 May 2022 18:47:48 +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 AIo7HLSidmLejgAA9RJhRA (envelope-from ) for ; Sat, 07 May 2022 18:47:48 +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 AC9442CC97 for ; Sat, 7 May 2022 18:47:47 +0200 (CEST) Received: from localhost ([::1]:36002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnNas-0005GC-Hf for larch@yhetil.org; Sat, 07 May 2022 12:47:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnNaq-0005Fo-8Y for gwl-devel@gnu.org; Sat, 07 May 2022 12:47:44 -0400 Received: from smtp.polymtl.ca ([132.207.4.11]:32823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnNan-000877-Dc for gwl-devel@gnu.org; Sat, 07 May 2022 12:47:43 -0400 Received: from laura.hitronhub.home (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 247Gl8Mf014065 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Sat, 7 May 2022 12:47:34 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 247Gl8Mf014065 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1651942054; bh=ZAMLlzXngGRKPC5sVfANgqEHJNb98fDZ87YvnaoS+GY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=l+xEzYfhxw37j0/yDp3zSZse8aTQf05U2fT0eQ9a3axuLicHki3PRh10K7UZIW04u QjRtlQm0GNH6Z7BRqPSwNxto6LVGWIA69fawBDQH7Bc8cAt65f1YyfQuKcqEmsgzao /Vt1ENDFCCizCNbIcyIfUjJjLreoMoQomAv042Ko= From: Olivier Dion To: Olivier Dion , gwl-devel@gnu.org Subject: [PATCH v2] tests/examples: Add running of workflow examples Date: Sat, 7 May 2022 12:47:03 -0400 Message-Id: <20220507164703.27219-1-olivier.dion@polymtl.ca> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220429175500.17176-1-olivier.dion@polymtl.ca> References: <20220429175500.17176-1-olivier.dion@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) at Sat, 7 May 2022 16:47:08 +0000 Received-SPF: pass client-ip=132.207.4.11; envelope-from=olivier.dion@polymtl.ca; helo=smtp.polymtl.ca X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: gwl-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gwl-devel-bounces+larch=yhetil.org@gnu.org Sender: "gwl-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651942068; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=ZAMLlzXngGRKPC5sVfANgqEHJNb98fDZ87YvnaoS+GY=; b=JCjH5sDOO6safNS+Y3meY9Gny1lUAMCESNjyvJdQseaKvyw3yNvK6FKfoRzrfh8C7L4h8/ u/5AhsLn/qugIAXCWfSl3FSwPBr3xFlBZ8x3Bjarwj7gni2d5esKX5fpq0SYkmcSbOfeH1 LvxgrSDRA2G9jfoICxiDjTx2hNkd3MZ5y+HwaKiZWlikMBCXzsfnRp/NL7qnD3G1CdwCWL 0jUXtIJwCI3clXuIH3sQgz7IzYC689cFAFq7xt8cIEwmbXVRTdqW5wnrPgiEkBnSx0cLAT 2OsB7Nfx+wyYnhWtNOFwcRaF53Ox34LH+7vHPoccKTDpZj95TH0TBirzTM6V5w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651942068; a=rsa-sha256; cv=none; b=kdd11tCI3VreZkfBn0aeIgMfec+Q10GDg+NUAmFtwVCSreZQO9xhCAVJ1x5SpOCqeZXpFj v5Sfet49RMK3cLlffq2fFRzu+4I4TCDinFhxHKouNg3aX61j7i+INCdmuTzGEvFoj0wMf0 9BxU7xqI270HYrmYceQTngpHUXwZSoqREUGk05o3wM34ZhXDVu/CulyUdkYB3i98FmY0Ha KIWVFvt4TbSHFVj28njfOsTspTDa2wjYFBYGC6PheGTK+jHKhnSi79FEbFKdf9+jjNeLJ1 XFxLNdWVep0fuvFaWBzLAOWNQhyyLlFbxm8qKoQvaG7eRJDQ4TFSnjsHk/VZ1A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=polymtl.ca header.s=default header.b=l+xEzYfh; dmarc=pass (policy=quarantine) header.from=polymtl.ca; spf=pass (aspmx1.migadu.com: domain of "gwl-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="gwl-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.00 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=polymtl.ca header.s=default header.b=l+xEzYfh; dmarc=pass (policy=quarantine) header.from=polymtl.ca; spf=pass (aspmx1.migadu.com: domain of "gwl-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="gwl-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: AC9442CC97 X-Spam-Score: -4.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6Co9UAcrkcun End to end testing of pre-defined scenarios are a good way to check for regression. Here we introduce testing of some examples available in the documentation. That way, we're sure that new users should be able to run them without problems. Each scenario is a different test and is run in a different temporary directory which get destroyed if the scenario succeeded. --- tests/examples.scm | 51 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/tests/examples.scm b/tests/examples.scm index 6f7a64e..22edd12 100644 --- a/tests/examples.scm +++ b/tests/examples.scm @@ -14,12 +14,13 @@ ;;; along with this program. If not, see . (define-module (test-examples) + #:use-module (gwl ui) #:use-module (gwl utils) #:use-module (gwl errors) + #:use-module ((guix build utils) + #:select (delete-file-recursively)) #:use-module (srfi srfi-64)) -(test-begin "examples") - (define user-module-for-file (@@ (gwl workflows utils) user-module-for-file)) @@ -30,6 +31,48 @@ (lambda (port) (wisp-reader port (user-module-for-file "test.w")))) +(define top-srcdir (getenv "abs_top_srcdir")) + +(define-syntax-rule (with-temporary-directory prefix body body* ...) + (let ((old-dir (getcwd)) + (tmp-dir (mkdtemp + (format #f "/tmp/~a.XXXXXX" prefix)))) + (dynamic-wind + (lambda () + (log-event 'info (G_ "Changing directory: ~a") tmp-dir) + (chdir tmp-dir)) + (lambda () body body* ...) + (lambda () + (log-event 'info (G_ "Changing directory: ~a") old-dir) + (chdir old-dir) + (delete-file-recursively tmp-dir))))) + +(define (process-success? status) + (zero? (or (status:exit-val status) + (status:term-sig status)))) + +(define (run-example example) + + (define abs-example + (canonicalize-path + (string-append top-srcdir "/doc/examples/" example))) + + (with-temporary-directory + (string-append "gwl-example-" example) + (process-success? + (system* "guix" + "workflow" + "run" + "--force" + "--container" + "--log-events=all" + abs-example)))) + +(define-syntax-rule (test-example example) + (test-assert example (run-example example))) + +(test-begin "examples") + (test-equal "wisp syntax produces the expected S-expression" '(process haiku (outputs "haiku.txt") @@ -39,8 +82,10 @@ (with-output-to-file (unquote outputs) (lambda () (display "the library book\noverdue?\nslow falling snow")))))) - (call-with-input-file (string-append (getenv "abs_top_srcdir") + (call-with-input-file (string-append top-srcdir "/doc/examples/haiku.w") read-wisp)) +(test-example "extended-example-workflow.w") + (test-end "examples") -- 2.36.0