unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] lint: 'inputs-should-be-native' checks for intltool, itstool and glib:bin.
@ 2016-07-22 17:50 David Craven
  2016-07-24 17:57 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: David Craven @ 2016-07-22 17:50 UTC (permalink / raw)
  To: guix-devel; +Cc: David Craven

* guix/scripts/lint.scm (check-inputs-should-be-native): Warn when intltool,
itstool or glib:bin isn't a native-input.
* tests/lint.scm (inputs: glib:bin is probably a native input): Add test.
---
 guix/scripts/lint.scm | 20 +++++++++++++-------
 tests/lint.scm        | 10 ++++++++++
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index d5e9197..586ae88 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -203,14 +203,20 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
 (define (check-inputs-should-be-native package)
   ;; Emit a warning if some inputs of PACKAGE are likely to belong to its
   ;; native inputs.
-  (let ((inputs (package-inputs package)))
+  (let ((inputs (package-inputs package))
+        (native-inputs '("pkg-config" "glib:bin" "intltool" "itstool")))
     (match inputs
-      (((labels packages . _) ...)
-       (when (member "pkg-config"
-                     (map package-name (filter package? packages)))
-        (emit-warning package
-                      (_ "pkg-config should probably be a native input")
-                      'inputs))))))
+      (((labels packages . outputs) ...)
+        (for-each (lambda (package output)
+          (when (package? package)
+            (let ((input (string-append
+                    (package-name package)
+                    (if (> (length output) 0)
+                      (string-append ":" (car output)) ""))))
+              (when (member input native-inputs)
+                (emit-warning package
+                  (string-append input " should probably be a native input"))))))
+        packages outputs)))))
 
 (define (package-name-regexp package)
   "Return a regexp that matches PACKAGE's name as a word at the beginning of a
diff --git a/tests/lint.scm b/tests/lint.scm
index ce751c4..136a5a6 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -31,6 +31,7 @@
   #:use-module (guix scripts lint)
   #:use-module (guix ui)
   #:use-module (gnu packages)
+  #:use-module (gnu packages glib)
   #:use-module (gnu packages pkg-config)
   #:use-module (web server)
   #:use-module (web server http)
@@ -321,6 +322,15 @@ string) on HTTP requests."
          (check-inputs-should-be-native pkg)))
          "pkg-config should probably be a native input")))
 
+(test-assert "inputs: glib:bin is probably a native input"
+  (->bool
+    (string-contains
+      (with-warnings
+        (let ((pkg (dummy-package "x"
+                     (inputs `(("glib" ,glib "bin"))))))
+          (check-inputs-should-be-native pkg)))
+          "glib:bin should probably be a native input")))
+
 (test-assert "patches: file names"
   (->bool
    (string-contains
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lint: 'inputs-should-be-native' checks for intltool, itstool and glib:bin.
  2016-07-22 17:50 [PATCH] lint: 'inputs-should-be-native' checks for intltool, itstool and glib:bin David Craven
@ 2016-07-24 17:57 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2016-07-24 17:57 UTC (permalink / raw)
  To: David Craven; +Cc: guix-devel

David Craven <david@craven.ch> skribis:

> * guix/scripts/lint.scm (check-inputs-should-be-native): Warn when intltool,
> itstool or glib:bin isn't a native-input.
> * tests/lint.scm (inputs: glib:bin is probably a native input): Add test.

Neat!


[...]

> +      (((labels packages . outputs) ...)
> +        (for-each (lambda (package output)
> +          (when (package? package)
> +            (let ((input (string-append
> +                    (package-name package)
> +                    (if (> (length output) 0)
> +                      (string-append ":" (car output)) ""))))

Identation was misleading, so I’ve fixed that.

> +              (when (member input native-inputs)
> +                (emit-warning package
> +                  (string-append input " should probably be a native input"))))))

Here ‘package’ was referring to the input rather than to the package
being linted, so I’ve fixed that; I also switched to ‘format’ and made
sure the string is internationalized.

Pushed as 99fe215cc1c511a82e326727c6a0d193d246a387, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-24 17:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-22 17:50 [PATCH] lint: 'inputs-should-be-native' checks for intltool, itstool and glib:bin David Craven
2016-07-24 17:57 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).