* [PATCH] Add tests for warning locations.
@ 2022-09-24 13:46 Andrew Whatson
2022-09-24 21:15 ` Maxime Devos
2022-09-24 22:34 ` [PATCH v2] " Andrew Whatson
0 siblings, 2 replies; 7+ messages in thread
From: Andrew Whatson @ 2022-09-24 13:46 UTC (permalink / raw)
To: guile-devel; +Cc: Andrew Whatson
These would have caught <https://bugs.gnu.org/56493>.
* 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Add tests for warning locations.
2022-09-24 13:46 [PATCH] Add tests for warning locations Andrew Whatson
@ 2022-09-24 21:15 ` Maxime Devos
2022-09-24 22:34 ` [PATCH v2] " Andrew Whatson
1 sibling, 0 replies; 7+ messages in thread
From: Maxime Devos @ 2022-09-24 21:15 UTC (permalink / raw)
To: Andrew Whatson, guile-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 1138 bytes --]
On 24-09-2022 15:46, Andrew Whatson wrote:
> 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
I would expect they need to be registered in some Makefile.am (as
dist_noinst_... or was it noinst_dinst?) such that they are included in
the tarball generated by "make dist", but otherwise these seem a nice
set of tests to me.
Greetings,
Maxime.
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] Add tests for warning locations.
2022-09-24 13:46 [PATCH] Add tests for warning locations Andrew Whatson
2022-09-24 21:15 ` Maxime Devos
@ 2022-09-24 22:34 ` Andrew Whatson
2022-10-12 20:40 ` Ludovic Courtès
2022-11-29 18:11 ` [PATCH v3] " lloda
1 sibling, 2 replies; 7+ messages in thread
From: Andrew Whatson @ 2022-09-24 22:34 UTC (permalink / raw)
To: guile-devel; +Cc: Andrew Whatson
These would have caught <https://bugs.gnu.org/56493>.
* 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] Add tests for warning locations.
2022-09-24 22:34 ` [PATCH v2] " Andrew Whatson
@ 2022-10-12 20:40 ` Ludovic Courtès
2022-10-13 3:12 ` [PATCH v3] " Andrew Whatson
2022-10-13 3:18 ` [PATCH v2] " Andrew Whatson
2022-11-29 18:11 ` [PATCH v3] " lloda
1 sibling, 2 replies; 7+ messages in thread
From: Ludovic Courtès @ 2022-10-12 20:40 UTC (permalink / raw)
To: Andrew Whatson; +Cc: guile-devel
Hi,
Andrew Whatson <whatson@gmail.com> skribis:
> These would have caught <https://bugs.gnu.org/56493>.
>
> * 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.
The test looks great, thanks a lot!
One minor nitpick and then we’re ready to go:
> + (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")))))
Can we avoid the separate files and instead do something like:
(call-with-input-string " (foo)"
(lambda (port)
(set-port-filename! port "test-error-location.scm")
(read-and-compile port #:opts … #:to 'cps)))
?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] Add tests for warning locations.
2022-10-12 20:40 ` Ludovic Courtès
@ 2022-10-13 3:12 ` Andrew Whatson
2022-10-13 3:18 ` [PATCH v2] " Andrew Whatson
1 sibling, 0 replies; 7+ messages in thread
From: Andrew Whatson @ 2022-10-13 3:12 UTC (permalink / raw)
To: guile-devel; +Cc: Andrew Whatson
These would have caught <https://bugs.gnu.org/56493>.
* 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] Add tests for warning locations.
2022-10-12 20:40 ` Ludovic Courtès
2022-10-13 3:12 ` [PATCH v3] " Andrew Whatson
@ 2022-10-13 3:18 ` Andrew Whatson
1 sibling, 0 replies; 7+ messages in thread
From: Andrew Whatson @ 2022-10-13 3:18 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guile-devel
Ludovic Courtès <ludo@gnu.org> wrote:
>
> One minor nitpick and then we’re ready to go:
>
> > + (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")))))
>
> Can we avoid the separate files and instead do something like:
>
> (call-with-input-string " (foo)"
> (lambda (port)
> (set-port-filename! port "test-error-location.scm")
> (read-and-compile port #:opts … #:to 'cps)))
>
> ?
That cleans things up nicely! I've sent v3 of the patch incorporating
this change.
Thanks for the review!
Cheers,
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] Add tests for warning locations.
2022-09-24 22:34 ` [PATCH v2] " Andrew Whatson
2022-10-12 20:40 ` Ludovic Courtès
@ 2022-11-29 18:11 ` lloda
1 sibling, 0 replies; 7+ messages in thread
From: lloda @ 2022-11-29 18:11 UTC (permalink / raw)
To: Andrew Whatson; +Cc: guile-devel
Pushed to 02f69c1d84126c35900c5743a712b1e7d07e449d.
Thank you!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-29 18:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-24 13:46 [PATCH] Add tests for warning locations Andrew Whatson
2022-09-24 21:15 ` Maxime Devos
2022-09-24 22:34 ` [PATCH v2] " Andrew Whatson
2022-10-12 20:40 ` Ludovic Courtès
2022-10-13 3:12 ` [PATCH v3] " Andrew Whatson
2022-10-13 3:18 ` [PATCH v2] " Andrew Whatson
2022-11-29 18:11 ` [PATCH v3] " lloda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).