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] Add tests for warning locations. Date: Sat, 24 Sep 2022 23:46:08 +1000 Message-ID: <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="32548"; 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 Sat Sep 24 15:46:50 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 1oc5UY-0008Gm-5I for guile-devel@m.gmane-mx.org; Sat, 24 Sep 2022 15:46:50 +0200 Original-Received: from localhost ([::1]:41238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oc5UX-00080l-3G for guile-devel@m.gmane-mx.org; Sat, 24 Sep 2022 09:46:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oc5UC-0007yj-TX for guile-devel@gnu.org; Sat, 24 Sep 2022 09:46:28 -0400 Original-Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:44792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oc5UB-0004N2-6u for guile-devel@gnu.org; Sat, 24 Sep 2022 09:46:28 -0400 Original-Received: by mail-pg1-x52c.google.com with SMTP id c7so2673729pgt.11 for ; Sat, 24 Sep 2022 06:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=eotWnwoHkDskCUYeAPXqlzK33nQqwjVRIWI740kM4yg=; b=QQkmuIVj3zjUGubQZTRgxjeFHpN+v1lUV6fLfxUhDleAK1jLNlVPNEMH8zKTv5PS4O GzOwzEqSs5hfpgTsSqGchYW1OyBZTPb0JnQkAUFSkraYQCb3wG/WVlAv9rk9XpUC7FvP llrMU0C/AZyWE9WCf5IBT+/pjGTb88BKDJHQ7+kEEycPt3LOQzgll2pu2YnrR+fNFC/t CjJMMxPsUgn1Rv14jAVzsxFW6+g1KirZzpQDT1OnbOAk1hecrn931CVVhDYDhSXPSq1j dNYAfNQOn6ocHJhI+lOXaHB2JqBQL8BkdVQZd9OA5ywj7fcpriBXCb+GTRxLVYXmfsmP 2BPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=eotWnwoHkDskCUYeAPXqlzK33nQqwjVRIWI740kM4yg=; b=zSELtnOPkFihXPp8zz14A/dYpqOWtCfc5oDwvEuet3eoUlfxl4gpauTzfUfs7fdJqO jOQYr0vIdj2papXHMZa1223btEWIngvfY8pSkJEBOcG54vDA+FqBq3mRkoHQ4XDjjuwo f/FhOjqcWYRcTzNszKYdhlT5L+ZMWw2vXuLTgSCZGxz7osK4Mgrp73diap1Ru3Ti8jrL JAxZTzuPwoPbW33lsVQymZYypIJr99sESXjZizlL0cQTfQ0b4NgG63xNZxFg270CxQ7y bvjHV8G8MucofmuLX2mrJDFY8lbTnBpMgs2q9/nYOlCAnC1rT60wck4TLv5M0jNTmZ8I 3rOg== X-Gm-Message-State: ACrzQf0lEL7C3Zoas0tito2aH6Rw8TwSjxDOTFxXeOvS7d/dx4iwJRi/ +lEyXVqxIun/U5borDnIqKH/rH3R8to= X-Google-Smtp-Source: AMsMyM60djRC7JZ6/szvEWbqsBBtxKFcIIcT0tzkD8FFtkH7WGmSud7OIE13zH20F1Psw7qoeOCGyw== X-Received: by 2002:a62:6085:0:b0:53e:7874:5067 with SMTP id u127-20020a626085000000b0053e78745067mr14467775pfb.4.1664027185063; Sat, 24 Sep 2022 06:46:25 -0700 (PDT) Original-Received: from fumo.fritz.box (eft1854679.lnk.telstra.net. [101.187.131.186]) by smtp.gmail.com with ESMTPSA id v11-20020a17090ad58b00b001fd77933fb3sm3438535pju.17.2022.09.24.06.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 06:46:23 -0700 (PDT) X-Mailer: git-send-email 2.37.3 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=whatson@gmail.com; helo=mail-pg1-x52c.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:21367 Archived-At: These would have caught . * 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/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 ++ 4 files changed, 41 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/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