Commit | Line | Data |
---|---|---|
b4f5e0e8 CR |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com> | |
50f5c46d | 3 | ;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org> |
c74f0cb2 | 4 | ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> |
052d53df | 5 | ;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org> |
b4f5e0e8 CR |
6 | ;;; |
7 | ;;; This file is part of GNU Guix. | |
8 | ;;; | |
9 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
10 | ;;; under the terms of the GNU General Public License as published by | |
11 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
12 | ;;; your option) any later version. | |
13 | ;;; | |
14 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
15 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | ;;; GNU General Public License for more details. | |
18 | ;;; | |
19 | ;;; You should have received a copy of the GNU General Public License | |
20 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
c74f0cb2 LC |
22 | ;; Avoid interference. |
23 | (unsetenv "http_proxy") | |
24 | ||
4e7b6b48 | 25 | (define-module (test-lint) |
8b385969 | 26 | #:use-module (guix tests) |
754e5be2 | 27 | #:use-module (guix download) |
50f5c46d | 28 | #:use-module (guix git-download) |
b4f5e0e8 CR |
29 | #:use-module (guix build-system gnu) |
30 | #:use-module (guix packages) | |
31 | #:use-module (guix scripts lint) | |
32 | #:use-module (guix ui) | |
33 | #:use-module (gnu packages) | |
34 | #:use-module (gnu packages pkg-config) | |
907c98ac LC |
35 | #:use-module (web server) |
36 | #:use-module (web server http) | |
37 | #:use-module (web response) | |
38 | #:use-module (ice-9 threads) | |
39 | #:use-module (srfi srfi-9 gnu) | |
b4f5e0e8 CR |
40 | #:use-module (srfi srfi-64)) |
41 | ||
42 | ;; Test the linter. | |
43 | ||
907c98ac LC |
44 | (define %http-server-port |
45 | ;; TCP port to use for the stub HTTP server. | |
46 | 9999) | |
47 | ||
48 | (define %local-url | |
49 | ;; URL to use for 'home-page' tests. | |
50 | (string-append "http://localhost:" (number->string %http-server-port) | |
51 | "/foo/bar")) | |
52 | ||
950d2ea4 LC |
53 | (define %null-sha256 |
54 | ;; SHA256 of the empty string. | |
55 | (base32 | |
56 | "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73")) | |
57 | ||
907c98ac LC |
58 | (define %http-server-socket |
59 | ;; Socket used by the Web server. | |
60 | (catch 'system-error | |
61 | (lambda () | |
62 | (let ((sock (socket PF_INET SOCK_STREAM 0))) | |
63 | (setsockopt sock SOL_SOCKET SO_REUSEADDR 1) | |
64 | (bind sock | |
65 | (make-socket-address AF_INET INADDR_LOOPBACK | |
66 | %http-server-port)) | |
67 | sock)) | |
68 | (lambda args | |
69 | (let ((err (system-error-errno args))) | |
70 | (format (current-error-port) | |
71 | "warning: cannot run Web server for tests: ~a~%" | |
72 | (strerror err)) | |
73 | #f)))) | |
74 | ||
75 | (define (http-write server client response body) | |
76 | "Write RESPONSE." | |
77 | (let* ((response (write-response response client)) | |
78 | (port (response-port response))) | |
79 | (cond | |
80 | ((not body)) ;pass | |
81 | (else | |
82 | (write-response-body response body))) | |
83 | (close-port port) | |
84 | (quit #t) ;exit the server thread | |
85 | (values))) | |
86 | ||
4655005e LC |
87 | ;; Mutex and condition variable to synchronize with the HTTP server. |
88 | (define %http-server-lock (make-mutex)) | |
89 | (define %http-server-ready (make-condition-variable)) | |
90 | ||
91 | (define (http-open . args) | |
92 | "Start listening for HTTP requests and signal %HTTP-SERVER-READY." | |
93 | (with-mutex %http-server-lock | |
94 | (let ((result (apply (@@ (web server http) http-open) args))) | |
95 | (signal-condition-variable %http-server-ready) | |
96 | result))) | |
97 | ||
907c98ac LC |
98 | (define-server-impl stub-http-server |
99 | ;; Stripped-down version of Guile's built-in HTTP server. | |
4655005e | 100 | http-open |
907c98ac LC |
101 | (@@ (web server http) http-read) |
102 | http-write | |
103 | (@@ (web server http) http-close)) | |
104 | ||
105 | (define (call-with-http-server code thunk) | |
106 | "Call THUNK with an HTTP server running and returning CODE on HTTP | |
107 | requests." | |
108 | (define (server-body) | |
109 | (define (handle request body) | |
110 | (values (build-response #:code code | |
111 | #:reason-phrase "Such is life") | |
112 | "Hello, world.")) | |
113 | ||
114 | (catch 'quit | |
115 | (lambda () | |
116 | (run-server handle stub-http-server | |
117 | `(#:socket ,%http-server-socket))) | |
118 | (const #t))) | |
119 | ||
4655005e LC |
120 | (with-mutex %http-server-lock |
121 | (let ((server (make-thread server-body))) | |
122 | (wait-condition-variable %http-server-ready %http-server-lock) | |
123 | ;; Normally SERVER exits automatically once it has received a request. | |
124 | (thunk)))) | |
907c98ac LC |
125 | |
126 | (define-syntax-rule (with-http-server code body ...) | |
127 | (call-with-http-server code (lambda () body ...))) | |
128 | ||
b4f5e0e8 CR |
129 | \f |
130 | (test-begin "lint") | |
131 | ||
b4f5e0e8 | 132 | (define (call-with-warnings thunk) |
b002e9d0 LC |
133 | (let ((port (open-output-string))) |
134 | (parameterize ((guix-warning-port port)) | |
135 | (thunk)) | |
136 | (get-output-string port))) | |
b4f5e0e8 | 137 | |
4fbf4ca5 LC |
138 | (define-syntax-rule (with-warnings body ...) |
139 | (call-with-warnings (lambda () body ...))) | |
140 | ||
20be23c3 LC |
141 | (test-assert "description: not a string" |
142 | (->bool | |
143 | (string-contains (with-warnings | |
144 | (let ((pkg (dummy-package "x" | |
145 | (description 'foobar)))) | |
146 | (check-description-style pkg))) | |
147 | "invalid description"))) | |
148 | ||
334c43e3 EB |
149 | (test-assert "description: not empty" |
150 | (->bool | |
4fbf4ca5 LC |
151 | (string-contains (with-warnings |
152 | (let ((pkg (dummy-package "x" | |
153 | (description "")))) | |
154 | (check-description-style pkg))) | |
334c43e3 EB |
155 | "description should not be empty"))) |
156 | ||
3500e659 ML |
157 | (test-assert "description: valid Texinfo markup" |
158 | (->bool | |
159 | (string-contains | |
160 | (with-warnings | |
161 | (check-description-style (dummy-package "x" (description "f{oo}b@r")))) | |
162 | "Texinfo markup in description is invalid"))) | |
163 | ||
8202a513 CR |
164 | (test-assert "description: does not start with an upper-case letter" |
165 | (->bool | |
4fbf4ca5 LC |
166 | (string-contains (with-warnings |
167 | (let ((pkg (dummy-package "x" | |
168 | (description "bad description.")))) | |
169 | (check-description-style pkg))) | |
8202a513 CR |
170 | "description should start with an upper-case letter"))) |
171 | ||
903581f9 | 172 | (test-assert "description: may start with a digit" |
b1e66683 | 173 | (string-null? |
4fbf4ca5 LC |
174 | (with-warnings |
175 | (let ((pkg (dummy-package "x" | |
176 | (description "2-component library.")))) | |
177 | (check-description-style pkg))))) | |
903581f9 | 178 | |
3c42965b | 179 | (test-assert "description: may start with lower-case package name" |
b1e66683 | 180 | (string-null? |
4fbf4ca5 LC |
181 | (with-warnings |
182 | (let ((pkg (dummy-package "x" | |
183 | (description "x is a dummy package.")))) | |
184 | (check-description-style pkg))))) | |
3c42965b | 185 | |
574e847b EB |
186 | (test-assert "description: two spaces after end of sentence" |
187 | (->bool | |
4fbf4ca5 LC |
188 | (string-contains (with-warnings |
189 | (let ((pkg (dummy-package "x" | |
190 | (description "Bad. Quite bad.")))) | |
191 | (check-description-style pkg))) | |
574e847b EB |
192 | "sentences in description should be followed by two spaces"))) |
193 | ||
194 | (test-assert "description: end-of-sentence detection with abbreviations" | |
b1e66683 | 195 | (string-null? |
4fbf4ca5 LC |
196 | (with-warnings |
197 | (let ((pkg (dummy-package "x" | |
198 | (description | |
199 | "E.g. Foo, i.e. Bar resp. Baz (a.k.a. DVD).")))) | |
200 | (check-description-style pkg))))) | |
574e847b | 201 | |
20be23c3 LC |
202 | (test-assert "synopsis: not a string" |
203 | (->bool | |
204 | (string-contains (with-warnings | |
205 | (let ((pkg (dummy-package "x" | |
206 | (synopsis #f)))) | |
207 | (check-synopsis-style pkg))) | |
208 | "invalid synopsis"))) | |
209 | ||
574e847b EB |
210 | (test-assert "synopsis: not empty" |
211 | (->bool | |
4fbf4ca5 LC |
212 | (string-contains (with-warnings |
213 | (let ((pkg (dummy-package "x" | |
214 | (synopsis "")))) | |
215 | (check-synopsis-style pkg))) | |
574e847b EB |
216 | "synopsis should not be empty"))) |
217 | ||
8202a513 CR |
218 | (test-assert "synopsis: does not start with an upper-case letter" |
219 | (->bool | |
4fbf4ca5 LC |
220 | (string-contains (with-warnings |
221 | (let ((pkg (dummy-package "x" | |
222 | (synopsis "bad synopsis.")))) | |
223 | (check-synopsis-style pkg))) | |
8202a513 CR |
224 | "synopsis should start with an upper-case letter"))) |
225 | ||
903581f9 | 226 | (test-assert "synopsis: may start with a digit" |
b1e66683 | 227 | (string-null? |
4fbf4ca5 LC |
228 | (with-warnings |
229 | (let ((pkg (dummy-package "x" | |
230 | (synopsis "5-dimensional frobnicator")))) | |
231 | (check-synopsis-style pkg))))) | |
903581f9 | 232 | |
b4f5e0e8 CR |
233 | (test-assert "synopsis: ends with a period" |
234 | (->bool | |
4fbf4ca5 LC |
235 | (string-contains (with-warnings |
236 | (let ((pkg (dummy-package "x" | |
237 | (synopsis "Bad synopsis.")))) | |
238 | (check-synopsis-style pkg))) | |
b4f5e0e8 CR |
239 | "no period allowed at the end of the synopsis"))) |
240 | ||
241 | (test-assert "synopsis: ends with 'etc.'" | |
4fbf4ca5 LC |
242 | (string-null? (with-warnings |
243 | (let ((pkg (dummy-package "x" | |
244 | (synopsis "Foo, bar, etc.")))) | |
245 | (check-synopsis-style pkg))))) | |
b4f5e0e8 CR |
246 | |
247 | (test-assert "synopsis: starts with 'A'" | |
248 | (->bool | |
4fbf4ca5 LC |
249 | (string-contains (with-warnings |
250 | (let ((pkg (dummy-package "x" | |
251 | (synopsis "A bad synopŝis")))) | |
252 | (check-synopsis-style pkg))) | |
b4f5e0e8 CR |
253 | "no article allowed at the beginning of the synopsis"))) |
254 | ||
255 | (test-assert "synopsis: starts with 'An'" | |
256 | (->bool | |
4fbf4ca5 LC |
257 | (string-contains (with-warnings |
258 | (let ((pkg (dummy-package "x" | |
259 | (synopsis "An awful synopsis")))) | |
260 | (check-synopsis-style pkg))) | |
b4f5e0e8 CR |
261 | "no article allowed at the beginning of the synopsis"))) |
262 | ||
a00ffdaa CR |
263 | (test-assert "synopsis: starts with 'a'" |
264 | (->bool | |
4fbf4ca5 LC |
265 | (string-contains (with-warnings |
266 | (let ((pkg (dummy-package "x" | |
267 | (synopsis "a bad synopsis")))) | |
268 | (check-synopsis-style pkg))) | |
a00ffdaa CR |
269 | "no article allowed at the beginning of the synopsis"))) |
270 | ||
271 | (test-assert "synopsis: starts with 'an'" | |
272 | (->bool | |
4fbf4ca5 LC |
273 | (string-contains (with-warnings |
274 | (let ((pkg (dummy-package "x" | |
275 | (synopsis "an awful synopsis")))) | |
276 | (check-synopsis-style pkg))) | |
a00ffdaa CR |
277 | "no article allowed at the beginning of the synopsis"))) |
278 | ||
5622953d CR |
279 | (test-assert "synopsis: too long" |
280 | (->bool | |
4fbf4ca5 LC |
281 | (string-contains (with-warnings |
282 | (let ((pkg (dummy-package "x" | |
283 | (synopsis (make-string 80 #\x))))) | |
284 | (check-synopsis-style pkg))) | |
5622953d CR |
285 | "synopsis should be less than 80 characters long"))) |
286 | ||
3c762a13 CR |
287 | (test-assert "synopsis: start with package name" |
288 | (->bool | |
4fbf4ca5 LC |
289 | (string-contains (with-warnings |
290 | (let ((pkg (dummy-package "x" | |
291 | (name "foo") | |
292 | (synopsis "foo, a nice package")))) | |
293 | (check-synopsis-style pkg))) | |
3c762a13 CR |
294 | "synopsis should not start with the package name"))) |
295 | ||
17854ef9 LC |
296 | (test-assert "synopsis: start with package name prefix" |
297 | (string-null? | |
4fbf4ca5 LC |
298 | (with-warnings |
299 | (let ((pkg (dummy-package "arb" | |
300 | (synopsis "Arbitrary precision")))) | |
301 | (check-synopsis-style pkg))))) | |
17854ef9 | 302 | |
15a6d433 LC |
303 | (test-assert "synopsis: start with abbreviation" |
304 | (string-null? | |
4fbf4ca5 LC |
305 | (with-warnings |
306 | (let ((pkg (dummy-package "uucp" | |
307 | ;; Same problem with "APL interpreter", etc. | |
308 | (synopsis "UUCP implementation") | |
309 | (description "Imagine this is Taylor UUCP.")))) | |
310 | (check-synopsis-style pkg))))) | |
15a6d433 | 311 | |
b4f5e0e8 CR |
312 | (test-assert "inputs: pkg-config is probably a native input" |
313 | (->bool | |
314 | (string-contains | |
4fbf4ca5 LC |
315 | (with-warnings |
316 | (let ((pkg (dummy-package "x" | |
317 | (inputs `(("pkg-config" ,pkg-config)))))) | |
318 | (check-inputs-should-be-native pkg))) | |
b4f5e0e8 CR |
319 | "pkg-config should probably be a native input"))) |
320 | ||
321 | (test-assert "patches: file names" | |
322 | (->bool | |
323 | (string-contains | |
4fbf4ca5 LC |
324 | (with-warnings |
325 | (let ((pkg (dummy-package "x" | |
326 | (source | |
052d53df | 327 | (dummy-origin |
4fbf4ca5 | 328 | (patches (list "/path/to/y.patch"))))))) |
56b1b74c | 329 | (check-patch-file-names pkg))) |
907c98ac LC |
330 | "file names of patches should start with the package name"))) |
331 | ||
b210b35d LC |
332 | (test-assert "patches: not found" |
333 | (->bool | |
334 | (string-contains | |
335 | (with-warnings | |
336 | (let ((pkg (dummy-package "x" | |
337 | (source | |
052d53df | 338 | (dummy-origin |
b210b35d LC |
339 | (patches |
340 | (list (search-patch "this-patch-does-not-exist!")))))))) | |
341 | (check-patch-file-names pkg))) | |
342 | "patch not found"))) | |
343 | ||
002c57c6 LC |
344 | (test-assert "derivation: invalid arguments" |
345 | (->bool | |
346 | (string-contains | |
347 | (with-warnings | |
348 | (let ((pkg (dummy-package "x" | |
349 | (arguments | |
350 | '(#:imported-modules (invalid-module)))))) | |
351 | (check-derivation pkg))) | |
352 | "failed to create derivation"))) | |
353 | ||
52b9efe3 LC |
354 | (test-assert "license: invalid license" |
355 | (string-contains | |
356 | (with-warnings | |
357 | (check-license (dummy-package "x" (license #f)))) | |
358 | "invalid license")) | |
359 | ||
907c98ac LC |
360 | (test-assert "home-page: wrong home-page" |
361 | (->bool | |
362 | (string-contains | |
4fbf4ca5 LC |
363 | (with-warnings |
364 | (let ((pkg (package | |
365 | (inherit (dummy-package "x")) | |
366 | (home-page #f)))) | |
367 | (check-home-page pkg))) | |
907c98ac LC |
368 | "invalid"))) |
369 | ||
370 | (test-assert "home-page: invalid URI" | |
371 | (->bool | |
372 | (string-contains | |
4fbf4ca5 LC |
373 | (with-warnings |
374 | (let ((pkg (package | |
375 | (inherit (dummy-package "x")) | |
376 | (home-page "foobar")))) | |
377 | (check-home-page pkg))) | |
907c98ac LC |
378 | "invalid home page URL"))) |
379 | ||
380 | (test-assert "home-page: host not found" | |
381 | (->bool | |
382 | (string-contains | |
4fbf4ca5 LC |
383 | (with-warnings |
384 | (let ((pkg (package | |
385 | (inherit (dummy-package "x")) | |
386 | (home-page "http://does-not-exist")))) | |
387 | (check-home-page pkg))) | |
907c98ac LC |
388 | "domain not found"))) |
389 | ||
390 | (test-skip (if %http-server-socket 0 1)) | |
391 | (test-assert "home-page: Connection refused" | |
392 | (->bool | |
393 | (string-contains | |
4fbf4ca5 LC |
394 | (with-warnings |
395 | (let ((pkg (package | |
396 | (inherit (dummy-package "x")) | |
397 | (home-page %local-url)))) | |
398 | (check-home-page pkg))) | |
907c98ac LC |
399 | "Connection refused"))) |
400 | ||
401 | (test-skip (if %http-server-socket 0 1)) | |
402 | (test-equal "home-page: 200" | |
403 | "" | |
4fbf4ca5 LC |
404 | (with-warnings |
405 | (with-http-server 200 | |
406 | (let ((pkg (package | |
407 | (inherit (dummy-package "x")) | |
408 | (home-page %local-url)))) | |
409 | (check-home-page pkg))))) | |
907c98ac LC |
410 | |
411 | (test-skip (if %http-server-socket 0 1)) | |
412 | (test-assert "home-page: 404" | |
413 | (->bool | |
414 | (string-contains | |
4fbf4ca5 LC |
415 | (with-warnings |
416 | (with-http-server 404 | |
417 | (let ((pkg (package | |
418 | (inherit (dummy-package "x")) | |
419 | (home-page %local-url)))) | |
420 | (check-home-page pkg)))) | |
907c98ac | 421 | "not reachable: 404"))) |
b4f5e0e8 | 422 | |
50f5c46d EB |
423 | (test-assert "source-file-name" |
424 | (->bool | |
425 | (string-contains | |
426 | (with-warnings | |
427 | (let ((pkg (dummy-package "x" | |
428 | (version "3.2.1") | |
429 | (source | |
430 | (origin | |
431 | (method url-fetch) | |
432 | (uri "http://www.example.com/3.2.1.tar.gz") | |
433 | (sha256 %null-sha256)))))) | |
434 | (check-source-file-name pkg))) | |
435 | "file name should contain the package name"))) | |
436 | ||
437 | (test-assert "source-file-name: v prefix" | |
438 | (->bool | |
439 | (string-contains | |
440 | (with-warnings | |
441 | (let ((pkg (dummy-package "x" | |
442 | (version "3.2.1") | |
443 | (source | |
444 | (origin | |
445 | (method url-fetch) | |
446 | (uri "http://www.example.com/v3.2.1.tar.gz") | |
447 | (sha256 %null-sha256)))))) | |
448 | (check-source-file-name pkg))) | |
449 | "file name should contain the package name"))) | |
450 | ||
451 | (test-assert "source-file-name: bad checkout" | |
452 | (->bool | |
453 | (string-contains | |
454 | (with-warnings | |
455 | (let ((pkg (dummy-package "x" | |
456 | (version "3.2.1") | |
457 | (source | |
458 | (origin | |
459 | (method git-fetch) | |
460 | (uri (git-reference | |
461 | (url "http://www.example.com/x.git") | |
462 | (commit "0"))) | |
463 | (sha256 %null-sha256)))))) | |
464 | (check-source-file-name pkg))) | |
465 | "file name should contain the package name"))) | |
466 | ||
467 | (test-assert "source-file-name: good checkout" | |
468 | (not | |
469 | (->bool | |
470 | (string-contains | |
471 | (with-warnings | |
472 | (let ((pkg (dummy-package "x" | |
473 | (version "3.2.1") | |
474 | (source | |
475 | (origin | |
476 | (method git-fetch) | |
477 | (uri (git-reference | |
478 | (url "http://git.example.com/x.git") | |
479 | (commit "0"))) | |
480 | (file-name (string-append "x-" version)) | |
481 | (sha256 %null-sha256)))))) | |
482 | (check-source-file-name pkg))) | |
483 | "file name should contain the package name")))) | |
484 | ||
485 | (test-assert "source-file-name: valid" | |
486 | (not | |
487 | (->bool | |
488 | (string-contains | |
489 | (with-warnings | |
490 | (let ((pkg (dummy-package "x" | |
491 | (version "3.2.1") | |
492 | (source | |
493 | (origin | |
494 | (method url-fetch) | |
495 | (uri "http://www.example.com/x-3.2.1.tar.gz") | |
496 | (sha256 %null-sha256)))))) | |
497 | (check-source-file-name pkg))) | |
498 | "file name should contain the package name")))) | |
499 | ||
950d2ea4 LC |
500 | (test-skip (if %http-server-socket 0 1)) |
501 | (test-equal "source: 200" | |
502 | "" | |
503 | (with-warnings | |
504 | (with-http-server 200 | |
505 | (let ((pkg (package | |
506 | (inherit (dummy-package "x")) | |
507 | (source (origin | |
508 | (method url-fetch) | |
509 | (uri %local-url) | |
510 | (sha256 %null-sha256)))))) | |
511 | (check-source pkg))))) | |
512 | ||
513 | (test-skip (if %http-server-socket 0 1)) | |
514 | (test-assert "source: 404" | |
515 | (->bool | |
516 | (string-contains | |
517 | (with-warnings | |
518 | (with-http-server 404 | |
519 | (let ((pkg (package | |
520 | (inherit (dummy-package "x")) | |
521 | (source (origin | |
522 | (method url-fetch) | |
523 | (uri %local-url) | |
524 | (sha256 %null-sha256)))))) | |
525 | (check-source pkg)))) | |
526 | "not reachable: 404"))) | |
527 | ||
5432734b LC |
528 | (test-assert "cve" |
529 | (mock ((guix scripts lint) package-vulnerabilities (const '())) | |
530 | (string-null? | |
531 | (with-warnings (check-vulnerabilities (dummy-package "x")))))) | |
532 | ||
533 | (test-assert "cve: one vulnerability" | |
534 | (mock ((guix scripts lint) package-vulnerabilities | |
535 | (lambda (package) | |
536 | (list (make-struct (@@ (guix cve) <vulnerability>) 0 | |
537 | "CVE-2015-1234" | |
538 | (list (cons (package-name package) | |
539 | (package-version package))))))) | |
540 | (string-contains | |
541 | (with-warnings | |
542 | (check-vulnerabilities (dummy-package "pi" (version "3.14")))) | |
543 | "vulnerable to CVE-2015-1234"))) | |
544 | ||
4e70fe4d LC |
545 | (test-assert "cve: one patched vulnerability" |
546 | (mock ((guix scripts lint) package-vulnerabilities | |
547 | (lambda (package) | |
548 | (list (make-struct (@@ (guix cve) <vulnerability>) 0 | |
549 | "CVE-2015-1234" | |
550 | (list (cons (package-name package) | |
551 | (package-version package))))))) | |
552 | (string-null? | |
553 | (with-warnings | |
554 | (check-vulnerabilities | |
555 | (dummy-package "pi" | |
556 | (version "3.14") | |
557 | (source | |
558 | (dummy-origin | |
559 | (patches | |
560 | (list "/a/b/pi-CVE-2015-1234.patch")))))))))) | |
561 | ||
e0566f12 LC |
562 | (test-assert "formatting: lonely parentheses" |
563 | (string-contains | |
564 | (with-warnings | |
565 | (check-formatting | |
566 | ( | |
567 | dummy-package "ugly as hell!" | |
568 | ) | |
569 | )) | |
570 | "lonely")) | |
571 | ||
40a7d4e5 LC |
572 | (test-assert "formatting: tabulation" |
573 | (string-contains | |
574 | (with-warnings | |
575 | (check-formatting (dummy-package "leave the tab here: "))) | |
576 | "tabulation")) | |
577 | ||
578 | (test-assert "formatting: trailing white space" | |
579 | (string-contains | |
580 | (with-warnings | |
581 | ;; Leave the trailing white space on the next line! | |
582 | (check-formatting (dummy-package "x"))) | |
583 | "trailing white space")) | |
584 | ||
585 | (test-assert "formatting: long line" | |
586 | (string-contains | |
587 | (with-warnings | |
588 | (check-formatting | |
589 | (dummy-package "x" ;here is a stupid comment just to make a long line | |
590 | ))) | |
591 | "too long")) | |
592 | ||
593 | (test-assert "formatting: alright" | |
594 | (string-null? | |
595 | (with-warnings | |
596 | (check-formatting (dummy-package "x"))))) | |
597 | ||
b4f5e0e8 CR |
598 | (test-end "lint") |
599 | ||
907c98ac LC |
600 | ;; Local Variables: |
601 | ;; eval: (put 'with-http-server 'scheme-indent-function 1) | |
4fbf4ca5 | 602 | ;; eval: (put 'with-warnings 'scheme-indent-function 0) |
907c98ac | 603 | ;; End: |