tests: Relax expectations for the 'home-page' checker.
authorLudovic Courtès <ludo@gnu.org>
Sat, 17 Aug 2019 13:34:24 +0000 (15:34 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sat, 17 Aug 2019 14:23:05 +0000 (16:23 +0200)
Fixes a regression introduced in
50fc2384feb3bb2677d074f8f0deb5ae3c56b4d8.

* tests/lint.scm (warning-contains?): New procedure.
("home-page: host not found"): Use 'warning-contains?' instead of
testing for equality, as was the case before commit 50fc2384feb.
This handles the case where the 'getaddrinfo' error is not "Name or
service not known" but instead something like "System error" or
"Servname not supported for ai_socktype", as is the case in the build
environment.

tests/lint.scm

index 8a9023a..db6dd6d 100644 (file)
     (((and (? lint-warning?) warning))
      (lint-warning-message warning))))
 
+(define (warning-contains? str warnings)
+  "Return true if WARNINGS is a singleton with a warning that contains STR."
+  (match warnings
+    (((? lint-warning? warning))
+     (string-contains (lint-warning-message warning) str))))
+
 \f
 (test-begin "lint")
 
     (single-lint-warning-message
      (check-home-page pkg))))
 
-(test-equal "home-page: host not found"
-  "URI http://does-not-exist domain not found: Name or service not known"
+(test-assert "home-page: host not found"
   (let ((pkg (package
                (inherit (dummy-package "x"))
                (home-page "http://does-not-exist"))))
-    (single-lint-warning-message
-     (check-home-page pkg))))
+    (warning-contains? "domain not found" (check-home-page pkg))))
 
 (test-skip (if (http-server-can-listen?) 0 1))
 (test-equal "home-page: Connection refused"