From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Whatson Newsgroups: gmane.lisp.guile.devel Subject: [PATCH v2] Add tests for warning locations. Date: Sun, 25 Sep 2022 08:34:27 +1000 Message-ID: <20220924223426.30825-1-whatson@gmail.com> References: <20220924134608.20312-1-whatson@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30550"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrew Whatson To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Sep 25 00:35:17 2022 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocDjw-0007kt-Uj for guile-devel@m.gmane-mx.org; Sun, 25 Sep 2022 00:35:17 +0200 Original-Received: from localhost ([::1]:35310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocDjv-0002yT-Ti for guile-devel@m.gmane-mx.org; Sat, 24 Sep 2022 18:35:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocDjV-0002d6-HG for guile-devel@gnu.org; Sat, 24 Sep 2022 18:34:49 -0400 Original-Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:46911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocDjT-0002dj-Jr for guile-devel@gnu.org; Sat, 24 Sep 2022 18:34:49 -0400 Original-Received: by mail-pl1-x62d.google.com with SMTP id jm5so3124625plb.13 for ; Sat, 24 Sep 2022 15:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=aUv045wU7g3BwVJly0d5HADMZ6NhBeC5QQuKhEZkzM8=; b=AfXxm1tZZ/OJb/SGJ0nItpOdm5T3HZtJSjfhBz2wGPxVl1h4DzCY1m4VD7W2yIUGEM o0nAjQcVuSe3gl+WOeIJ111TCqEyJ6fklU5/Jh6lngihrAIEDi7fx+oyv2+xbbyC3DLy Y81WwEMicEFBErUFsclN8nqmMXNVvuxMbFh/isJjAkhetuotQMyf9qUQIF6Ak1MlWNjg Q+CRMfeWD0/xhO324ToQppJkbdYfvTcGem8tyL4XXfEElRTQuMGxMfqjI9IKnLL1KMNC kRJPe0MRl8UZ/Ovl53PCQ9U2hQGbB+lLKqX+dhQSm6g77GCleLnnmERPWV+E+xWb27/N 0BYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=aUv045wU7g3BwVJly0d5HADMZ6NhBeC5QQuKhEZkzM8=; b=x8VHjkxDc1u4KZQLSvTFLk6MTi0AYEW4Y9YeUyvTyUmXCtyIgeSdc5KaLEgN+Fj7SE ao9RCEQhCUT4zvmw+4rAQo3kkSkbXGsDFaPRJGTm6oWNKvdUHhSofBBH/Nqv4MusWBLh 0CeEXSknnt4OWZDtB1pCRehG38K09oaAQt2NdW4k9CsYmTAvhG+/tt2BJ3FroC2ZdUKs 8xXURICY79eGcZHAt/wTXAxtZgx1KBNBOszdpyxTybNTlF8gKVWIzedB5vgjBYUqVk4d h1/5XC87fgCnXWU0Kz0Lu6ahEv6UTFZyZTVBRs2tPcbZIzhXcjtHdXKtr5EWWsPiSdNr b8Tg== X-Gm-Message-State: ACrzQf1Pe9eaU9NxEnvcVE509wE5dJOYnQIxeg5Vajwywz1o0VMS9xbE YoUY5J4Vn7eA9oUsITaMWI+R16608nE= X-Google-Smtp-Source: AMsMyM572t+DIufVH7C92a8gge5OPja9GJVeOt+idnVZoW6D6V0kHnU/OoHtX3AT9yecd/XDYuyP8A== X-Received: by 2002:a17:902:8217:b0:176:e41d:b804 with SMTP id x23-20020a170902821700b00176e41db804mr14988992pln.111.1664058885722; Sat, 24 Sep 2022 15:34:45 -0700 (PDT) Original-Received: from fumo.fritz.box (eft1854679.lnk.telstra.net. [101.187.131.186]) by smtp.gmail.com with ESMTPSA id y18-20020a1709027c9200b001782f94cf5fsm8288131pll.17.2022.09.24.15.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 15:34:45 -0700 (PDT) X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220924134608.20312-1-whatson@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=whatson@gmail.com; helo=mail-pl1-x62d.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:21369 Archived-At: These would have caught . * test-suite/Makefile.am (SCM_TESTS): Add sample code files. * test-suite/tests/tree-il.test ("warnings"): New tests. * test-suite/tests/tree-il/unbound-spaces.scm: * test-suite/tests/tree-il/unbound-tabs.scm: * test-suite/tests/tree-il/unused-variable.scm: Sample code for compilation warning tests. --- test-suite/Makefile.am | 3 ++ test-suite/tests/tree-il.test | 37 +++++++++++++++++++- test-suite/tests/tree-il/unbound-spaces.scm | 1 + test-suite/tests/tree-il/unbound-tabs.scm | 1 + test-suite/tests/tree-il/unused-variable.scm | 3 ++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test-suite/tests/tree-il/unbound-spaces.scm create mode 100644 test-suite/tests/tree-il/unbound-tabs.scm create mode 100644 test-suite/tests/tree-il/unused-variable.scm diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index 16fa2e952..35f264195 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -187,6 +187,9 @@ SCM_TESTS = tests/00-initial-env.test \ tests/threads.test \ tests/time.test \ tests/tree-il.test \ + tests/tree-il/unbound-spaces.scm \ + tests/tree-il/unbound-tabs.scm \ + tests/tree-il/unused-variable.scm \ tests/types.test \ tests/unicode.test \ tests/version.test \ diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test index 686eab9d2..1f66ecccf 100644 --- a/test-suite/tests/tree-il.test +++ b/test-suite/tests/tree-il.test @@ -1519,7 +1519,42 @@ #:to 'cps))))) (and (= (length w) 1) (number? (string-contains (car w) - "cannot be meaningfully compared"))))))) + "cannot be meaningfully compared")))))) + + (with-test-prefix "location" + (define (test-file filename) + (string-append + (dirname (current-filename)) "/" filename)) + + (pass-if "unused variable" + (let ((w (call-with-warnings + (lambda () + (compile-file (test-file "tree-il/unused-variable.scm") + #:opts %opts-w-unused + #:to 'cps))))) + (and (= (length w) 1) + (number? (string-contains (car w) "unused variable `y'")) + (number? (string-contains (car w) "tree-il/unused-variable.scm:2:2"))))) + + (pass-if "unbound variable (spaces)" + (let ((w (call-with-warnings + (lambda () + (compile-file (test-file "tree-il/unbound-spaces.scm") + #:opts %opts-w-unbound + #:to 'cps))))) + (and (= (length w) 1) + (number? (string-contains (car w) "unbound variable `foo'")) + (number? (string-contains (car w) "tree-il/unbound-spaces.scm:1:3"))))) + + (pass-if "unbound variable (tabs)" + (let ((w (call-with-warnings + (lambda () + (compile-file (test-file "tree-il/unbound-tabs.scm") + #:opts %opts-w-unbound + #:to 'cps))))) + (and (= (length w) 1) + (number? (string-contains (car w) "unbound variable `foo'")) + (number? (string-contains (car w) "tree-il/unbound-tabs.scm:1:17"))))))) ;; Local Variables: ;; eval: (put 'pass-if-primitives-resolved 'scheme-indent-function 1) diff --git a/test-suite/tests/tree-il/unbound-spaces.scm b/test-suite/tests/tree-il/unbound-spaces.scm new file mode 100644 index 000000000..9de3b9861 --- /dev/null +++ b/test-suite/tests/tree-il/unbound-spaces.scm @@ -0,0 +1 @@ + (foo) diff --git a/test-suite/tests/tree-il/unbound-tabs.scm b/test-suite/tests/tree-il/unbound-tabs.scm new file mode 100644 index 000000000..b8c7ae23d --- /dev/null +++ b/test-suite/tests/tree-il/unbound-tabs.scm @@ -0,0 +1 @@ + (foo) diff --git a/test-suite/tests/tree-il/unused-variable.scm b/test-suite/tests/tree-il/unused-variable.scm new file mode 100644 index 000000000..73dcd3585 --- /dev/null +++ b/test-suite/tests/tree-il/unused-variable.scm @@ -0,0 +1,3 @@ +(lambda (x) + (let ((y (+ x 2))) + x)) -- 2.37.3