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 v3] Add tests for warning locations. Date: Thu, 13 Oct 2022 13:12:08 +1000 Message-ID: <20221013031207.12583-1-whatson@gmail.com> References: <875ygovkqt.fsf@gnu.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19152"; 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 Thu Oct 13 05:13:42 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 1oiofF-0004ns-Na for guile-devel@m.gmane-mx.org; Thu, 13 Oct 2022 05:13:41 +0200 Original-Received: from localhost ([::1]:57652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiofE-0008L6-51 for guile-devel@m.gmane-mx.org; Wed, 12 Oct 2022 23:13:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiof1-0008Kj-7D for guile-devel@gnu.org; Wed, 12 Oct 2022 23:13:27 -0400 Original-Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:37404) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oioez-00018P-8i for guile-devel@gnu.org; Wed, 12 Oct 2022 23:13:26 -0400 Original-Received: by mail-pf1-x42e.google.com with SMTP id 3so792994pfw.4 for ; Wed, 12 Oct 2022 20:13:21 -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 :message-id:reply-to; bh=/YyTeMaFcUY397JFT033RZ6vOwFqADmpsbzNeN9gjek=; b=cpcUBzcKom/OJ/x+FFJt9XIXDG80uqlC0MbUjJZC4/SO38ULn+gLzAPweETY1jQxqZ YeKuF2QxpNri88f4ysib2BOp+7xnwMXJ8EWKaVnf7KjAiBDN3HHCbNlESTkogdO/iFo6 2vvKVrGySc5MagTmlwDxLS2M946ZszCvM79Ki5TocwCWlrDkCs7VEfE8gC4X81iK0k0D j4R+6wO1mBS3TpUuG1tT1aOegI1zwTLy4GHL8Sq1kuOYiQ3fJuFk/b3vSgF9FuzKUL3P tuCTBsZV/hOyrm9AXqWcstDpU6bCQOXcLLRW4I54vcYRsB9CX4WAZPEor5cI7UySIDEj IWRw== 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:message-id:reply-to; bh=/YyTeMaFcUY397JFT033RZ6vOwFqADmpsbzNeN9gjek=; b=QswNgfQrC78LY2NHmdGzZwRBIwqD8W81BXyO8LOwB5DM/o4X7mF+YCsEIrE3m6/Qlx v8t7BGEmBLJvLGWBi5874x1dTpy0EtddzHPUmGATRoKQancI5cH6BCAxzp1xisMRmQIV MJxe1iLsk4NNd3c+iOufGh/7IZd0J8kBuwzRTuD5Bo/nZqjwAXV9q7qnhMetIXheaOt8 lckJw0FbGjeJ6kaeYyb7r+z9jpwt6cCPtdY1sl4U5/V2PKycTKFwnLE1rZscQykKEyh6 5wIP4A9NXlKUDMC28k22eMakiSZdQJFiaMTMPm+LIb/WnZ4/H3ENov1UCmWq0to1WLPS 2ApA== X-Gm-Message-State: ACrzQf3a9wOHbGZSL1dYWm+Fpd+BUak0qD2Qje0D6v3xoidlvsgS4iQ/ ISETMGo8815GNa+ANZSpPEjHlmJsFK/pUw== X-Google-Smtp-Source: AMsMyM5kVjt62rLSaxW2SqWLU9nZnIeGEaoWEZXuqMgA3v7EjPhHlgNKUDwpIa/vrWExrzFHK62qEw== X-Received: by 2002:a05:6a00:24cb:b0:563:5499:b73 with SMTP id d11-20020a056a0024cb00b0056354990b73mr20726612pfv.44.1665630800155; Wed, 12 Oct 2022 20:13:20 -0700 (PDT) Original-Received: from fumo.fritz.box (124-148-103-155.tpgi.com.au. [124.148.103.155]) by smtp.gmail.com with ESMTPSA id i72-20020a639d4b000000b0044ed37dbca8sm10245592pgd.2.2022.10.12.20.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 20:13:19 -0700 (PDT) X-Mailer: git-send-email 2.38.0 In-Reply-To: <875ygovkqt.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=whatson@gmail.com; helo=mail-pf1-x42e.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:21417 Archived-At: These would have caught . * test-suite/tests/tree-il.test ("warnings")("location")["unused variable", "unbound variable (spaces)", "unbound variable (tabs)"]: New tests. --- test-suite/tests/tree-il.test | 48 ++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test index 686eab9d2..b296be336 100644 --- a/test-suite/tests/tree-il.test +++ b/test-suite/tests/tree-il.test @@ -1519,7 +1519,53 @@ #:to 'cps))))) (and (= (length w) 1) (number? (string-contains (car w) - "cannot be meaningfully compared"))))))) + "cannot be meaningfully compared")))))) + + (with-test-prefix "location" + (define (call-with-fake-input-file filename contents thunk) + (call-with-input-string contents + (lambda (port) + (set-port-filename! port filename) + (thunk port)))) + + (pass-if "unused variable" + (let ((w (call-with-warnings + (lambda () + (call-with-fake-input-file + "unused-variable.scm" + "\ +(lambda (x) + (let ((y (+ x 2))) + x))" + (lambda (port) + (read-and-compile port #:opts %opts-w-unused #:to 'cps))))))) + (and (= (length w) 1) + (number? (string-contains (car w) "unused variable `y'")) + (number? (string-contains (car w) "unused-variable.scm:2:2"))))) + + (pass-if "unbound variable (spaces)" + (let ((w (call-with-warnings + (lambda () + (call-with-fake-input-file + "unbound-spaces.scm" + " (foo)" + (lambda (port) + (read-and-compile port #:opts %opts-w-unbound #:to 'cps))))))) + (and (= (length w) 1) + (number? (string-contains (car w) "unbound variable `foo'")) + (number? (string-contains (car w) "unbound-spaces.scm:1:3"))))) + + (pass-if "unbound variable (tabs)" + (let ((w (call-with-warnings + (lambda () + (call-with-fake-input-file + "unbound-tabs.scm" + "\t\t(foo)" + (lambda (port) + (read-and-compile port #:opts %opts-w-unbound #:to 'cps))))))) + (and (= (length w) 1) + (number? (string-contains (car w) "unbound variable `foo'")) + (number? (string-contains (car w) "unbound-tabs.scm:1:17"))))))) ;; Local Variables: ;; eval: (put 'pass-if-primitives-resolved 'scheme-indent-function 1) -- 2.38.0