[PATCH] lint: Display result of checkers on stdout.

  • Done
  • quality assurance status badge
Details
3 participants
  • Brice Waegeneire
  • Christopher Baines
  • Tobias Geerinckx-Rice
Owner
unassigned
Submitted by
Brice Waegeneire
Severity
normal
B
B
Brice Waegeneire wrote on 1 Apr 2020 09:38
(address . guix-patches@gnu.org)
20200401073835.5890-1-brice@waegenei.re
* guix/scripts/lint.scm (run-checkers): Replace 'current-error-port' by
'current-output-port'.
---
guix/scripts/lint.scm | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)

Toggle diff (49 lines)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 8d08c484f5..87705ef6d5 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -55,19 +56,21 @@
(define (run-checkers package checkers)
"Run the given CHECKERS on PACKAGE."
- (let ((tty? (isatty? (current-error-port))))
- (for-each (lambda (checker)
- (when tty?
- (format (current-error-port) "checking ~a@~a [~a]...\x1b[K\r"
- (package-name package) (package-version package)
- (lint-checker-name checker))
- (force-output (current-error-port)))
- (emit-warnings
- ((lint-checker-check checker) package)))
- checkers)
- (when tty?
- (format (current-error-port) "\x1b[K")
- (force-output (current-error-port)))))
+ (parameterize
+ ((guix-warning-port (current-output-port)))
+ (let ((tty? (isatty? (current-output-port))))
+ (for-each (lambda (checker)
+ (when tty?
+ (format #t "checking ~a@~a [~a]...\x1b[K\r"
+ (package-name package) (package-version package)
+ (lint-checker-name checker))
+ (force-output))
+ (emit-warnings
+ ((lint-checker-check checker) package)))
+ checkers)
+ (when tty?
+ (format #t "\x1b[K")
+ (force-output)))))
(define (list-checkers-and-exit checkers)
;; Print information about all available checkers and exit.
--
2.25.1
T
T
Tobias Geerinckx-Rice wrote on 1 Apr 2020 14:25
(address . 40367@debbugs.gnu.org)
877dyzjstr.fsf@nckx
Brice,

Thanks! As discussed on IRC, I agree stdout is better. These are
reports, not run-time errors.

Brice Waegeneire ???
Toggle quote (4 lines)
> * guix/scripts/lint.scm (run-checkers): Replace
> 'current-error-port' by
> 'current-output-port'.

It should still print *progress* messages (and any run-time
warnings & errors) to stderr, though:

$ guix lint sl >toot
checking sl@5.02[cve]...

$ guix lint sl >toot
guix lint: error: something bad happened

This includes reverting to (isatty? (current-error-port));
stdout's ttyness doesn't matter.

Please also rebase your revisions onto current master
(particularly 57e12aa).

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEfo+u0AlEeO9y5k0W2Imw8BjFSTwFAl6EiFAACgkQ2Imw8BjF
STwAyw/+IdsLVUqwaqAQlrqCVANHozUGT24ceAacWo/4VFnisPfuHxLDKsGI2469
t+RN/40oCdWcGzDWw/piT8MeTjkAK8cNb3gnZq7abJFrtRJgL859Mtw0k0ewCCwO
mJofes7mphLYFKm+DAxAhXeJ6i4/BQimAaYwnNuIgPS2HUuR7Ke/FG92mUEaYcg9
rl1McTAcy+OW+KSXyHO/bl2t7DiLbSsYmDnv616UqdzUJyOKHSt3ZrqIhjzqcI5l
nd6gW50GYeY0QgDViWteAW0x1eA6wYnMkN7hIyxamQGGhay3QPkkwg5TJRii5yy0
cu0WGtN1Q/wJHHCGgrIkeZYToi7mwYI0DRmcW0PQ4sLTsrlTFWaba9h61mvOX3Dx
vcoRpJ/aX4iUoaJTxf3EQKZsoKOCah2nZmXFzxBN2bMm0c9AVpbOb4OCvR4ugwQQ
D7cgCiacJZRN0izHIEp0DgtP1/lPgSMRtnJvmfmg6Q2BADl6kT0ft5cbpiTCUL3P
o4vcGukGxA73KEpD4Q+gviAgljF5w39I4WBaYNuAaQqApmeynPNgWMDUWPw3xtzD
vi8+5jzE7jSlTYFJDr+gAro0eRazuEVxhYHxp4dsYyvcXvrsKYoMxl2Rrufn/og9
BQoJfWvU/Vw9wyiKvwixAVWeCZPOCmQqova5RaxoRn2WTedg2Bo=
=h8l7
-----END PGP SIGNATURE-----

B
B
Brice Waegeneire wrote on 1 Apr 2020 15:19
[PATCH v2] lint: Display result of checkers on stdout.
(address . guix-patches@gnu.org)
20200401131925.8532-1-brice@waegenei.re
* guix/scripts/lint.scm (emit-warnings): Use 'current-output-port'
instead of 'current-error-port'.
---

This version is rebased on top of master and only change the output port to
stdout for the result of the checkers, not for the progress or any run-time
errors.

guix/scripts/lint.scm | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

Toggle diff (39 lines)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 97ffd57301..28b4db656c 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -46,13 +47,17 @@
;; given, the location of PACKAGE otherwise, the full name of PACKAGE and the
;; provided MESSAGE.
(for-each
- (lambda (lint-warning)
- (let ((package (lint-warning-package lint-warning))
- (loc (lint-warning-location lint-warning)))
- (info loc (G_ "~a@~a: ~a~%")
- (package-name package) (package-version package)
- (lint-warning-message lint-warning))))
- warnings))
+ (lambda (lint-warning)
+ (let* ((package (lint-warning-package lint-warning))
+ (name (package-name package))
+ (version (package-version package))
+ (loc (lint-warning-location lint-warning))
+ (message (lint-warning-message lint-warning)))
+ (parameterize
+ ((guix-warning-port (current-output-port)))
+ (info loc (G_ "~a@~a: ~a~%")
+ name version message) )))
+ warnings))
(define* (run-checkers package checkers #:key store)
"Run the given CHECKERS on PACKAGE."
--
2.25.1
B
B
Brice Waegeneire wrote on 1 Apr 2020 15:21
Re: [bug#40367] [PATCH] lint: Display result of checkers on stdout.
a37332d6b2987bbfa2955daf07c5ad74@waegenei.re
Hello Tobias,

On 2020-04-01 12:25, Tobias Geerinckx-Rice via Guix-patches via wrote:
Toggle quote (15 lines)
> It should still print *progress* messages (and any run-time warnings &
> errors) to stderr, though:
>
> $ guix lint sl >toot
> checking sl@5.02[cve]...
>
> $ guix lint sl >toot
> guix lint: error: something bad happened
>
> This includes reverting to (isatty? (current-error-port)); stdout's
> ttyness doesn't matter.
>
> Please also rebase your revisions onto current master (particularly
> 57e12aa).

I have take into account all of your suggestions in v2.

Thanks for the review,
- Brice
B
B
Brice Waegeneire wrote on 21 Apr 2020 10:58
b31f64295a52806f3a3ffd466e799566@waegenei.re
Ping?
B
B
Brice Waegeneire wrote on 21 May 2020 21:08
[PATCH v3] lint: Display result of checkers on stdout.
(address . guix-patches@gnu.org)
20200521190838.29736-1-brice@waegenei.re
* guix/scripts/lint.scm (emit-warnings): Use 'current-output-port'
instead of 'current-error-port'.
---

This version remove an extra space and correctly indent the patch.

guix/scripts/lint.scm | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

Toggle diff (35 lines)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 97ffd57301..5445645b53 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -47,11 +48,15 @@
;; provided MESSAGE.
(for-each
(lambda (lint-warning)
- (let ((package (lint-warning-package lint-warning))
- (loc (lint-warning-location lint-warning)))
- (info loc (G_ "~a@~a: ~a~%")
- (package-name package) (package-version package)
- (lint-warning-message lint-warning))))
+ (let* ((package (lint-warning-package lint-warning))
+ (name (package-name package))
+ (version (package-version package))
+ (loc (lint-warning-location lint-warning))
+ (message (lint-warning-message lint-warning)))
+ (parameterize
+ ((guix-warning-port (current-output-port)))
+ (info loc (G_ "~a@~a: ~a~%")
+ name version message))))
warnings))
(define* (run-checkers package checkers #:key store)
--
2.26.2
C
C
Christopher Baines wrote on 21 Nov 2020 11:24
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 40367-done@debbugs.gnu.org)
87blfrhusb.fsf@cbaines.net
Brice Waegeneire <brice@waegenei.re> writes:

Toggle quote (43 lines)
> * guix/scripts/lint.scm (emit-warnings): Use 'current-output-port'
> instead of 'current-error-port'.
> ---
>
> This version remove an extra space and correctly indent the patch.
>
> guix/scripts/lint.scm | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
> index 97ffd57301..5445645b53 100644
> --- a/guix/scripts/lint.scm
> +++ b/guix/scripts/lint.scm
> @@ -10,6 +10,7 @@
> ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
> ;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
> ;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
> +;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -47,11 +48,15 @@
> ;; provided MESSAGE.
> (for-each
> (lambda (lint-warning)
> - (let ((package (lint-warning-package lint-warning))
> - (loc (lint-warning-location lint-warning)))
> - (info loc (G_ "~a@~a: ~a~%")
> - (package-name package) (package-version package)
> - (lint-warning-message lint-warning))))
> + (let* ((package (lint-warning-package lint-warning))
> + (name (package-name package))
> + (version (package-version package))
> + (loc (lint-warning-location lint-warning))
> + (message (lint-warning-message lint-warning)))
> + (parameterize
> + ((guix-warning-port (current-output-port)))
> + (info loc (G_ "~a@~a: ~a~%")
> + name version message))))
> warnings))
>
> (define* (run-checkers package checkers #:key store)

Thanks, and apologies in the delay in looking at this again.

I've pushed it to master as becfa42ea79feb402fe6bc5922da2019ef021e88.q

Thanks again,

Chris
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl+46uRfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XdaeA//TQChYqjA1hDqIGgSLOSOH5KUWad5BjEb
Q9b1Zcf1wQOVR0Dt05Rw/LRO5oBR7WRKLlWy5rGicSwCx2cmTiLONZ4n75MbMRsY
ZiPHN7nI7WlYeIV5tjyOYvHtfhK7+eTA91bmhbQTceD3fNB3MJjrc92lUjKeacoy
x5J3cto5wJy3D0WWW+YNR0DgNGakeNGfCagVsRftvmmv5yzk6FdrKW3dfQPJoN94
e5gwdvHR0HqJRPKvLdtzV5+AO/f47jb/ao+aPxnnB6jxVd+7XoSb9KEpJorQ3sYJ
ZwGfsKuKHIG98JlAefsURYQPP6vOM3vlVzWpwK54/eNktcfBTyifsdiLQ4cT5sLb
o44LWCab3vHaWH6BrDRGOSdqePAsBJUTBQORMU/qQ5pkBa81rIi73o6tVSGldtzM
UUlLQ8uxIO9QBV7XhVbbTUgOhbJVYfwrHkKSoPNqSKasjfrwGA2LI5bx9f5z2zO2
+NGHESBZDPFCQGc/AKwlYarxnhcawfH6y1CUnQSTix988FO09lBtlGTcz1K2SwMO
6npVJo/ItokXX7OCQjip4qV1Jia81bnqPYkcZSFVVwMuZGk6HVUNKDxVjA6x7bC/
FKQtqLThPyVLbsgEA+Lx560cxmTxLG++KVPjYWXivt+d8aEp9gcbNR6uv/zlv5cQ
n117n3J8W4o=
=SPSa
-----END PGP SIGNATURE-----

Closed
?