Perl-Email-Project / Email-Valid

perl library to validate email addresses
19 stars 19 forks source link

valid.t is failing in version 1.203 #53

Closed perlpunk closed 9 months ago

perlpunk commented 2 years ago

In openSUSE Tumbleweed: https://build.opensuse.org/package/live_build_log/devel:languages:perl:autoupdate/perl-Email-Valid/standard/x86_64

[  169s] # Looks like you planned 40 tests but ran 39.
[  169s] t/valid.t .............. 
[  169s] Dubious, test returned 255 (wstat 65280, 0xff00)
[  169s] Failed 1/40 subtests 
toddr commented 2 years ago

This is because of a bad skip count. The fix is:

diff --git a/Email-Valid/t/valid.t b/Email-Valid/t/valid.t
index 966e1643fb..4283cb4a75 100644
--- a/Email-Valid/t/valid.t
+++ b/Email-Valid/t/valid.t
@@ -128,7 +128,7 @@ ok(
 );

 SKIP: {
-  skip "your dns appears missing or failing to resolve", 3
+  skip "your dns appears missing or failing to resolve", 4
     unless eval { $v->address(-address=> 'devnull@pobox.com', -mxcheck => 1) };

   if (
perlpunk commented 2 years ago

thanks, we are patching this locally now in openSUSE

eserte commented 10 months ago

The skip count is wrong, but there's another problem: if the test system has wildcard DNS records enabled, then it may surprisingly resolve non-existing DNS names. So will-never-exist.pobox.com may become will-never-exist.pobox.com.opensuse.de or so (depending on the setup of the local system).

This can be reproduced like this on Linux and BSD systems:

 $ LOCALDOMAIN=opensuse.de perl -e 'warn((gethostbyname("will-never-exist.pobox.com"))[0])'
 will-never-exist.pobox.com.opensuse.de at -e line 1.

Workaround: use a trailing dot to the non-existing DNS name to avoid expansion. The following should work:

diff --git a/t/valid.t b/t/valid.t
index 966e164..df01d3d 100644
--- a/t/valid.t
+++ b/t/valid.t
@@ -132,7 +132,7 @@ SKIP: {
     unless eval { $v->address(-address=> 'devnull@pobox.com', -mxcheck => 1) };

   if (
-    $v->address(-address => 'blort@will-never-exist.pobox.com', -mxcheck => 1)
+    $v->address(-address => 'blort@will-never-exist.pobox.com.', -mxcheck => 1)
   ) {
     skip "your dns is lying to you; you must not use mxcheck", 3;
   }
@@ -143,7 +143,7 @@ SKIP: {
   );

   ok(
-    !$v->address(-address => 'blort@will-never-exist.pobox.com', -mxcheck => 1),
+    !$v->address(-address => 'blort@will-never-exist.pobox.com.', -mxcheck => 1),
     'blort@will-never-exist.pobox.com, with mxcheck, is invalid',
   ) or diag "was using $Email::Valid::DNS_Method for dns resolution";

(see also https://github.com/tokuhirom/Furl/issues/128 )

rjbs commented 9 months ago

Thanks, I've applied both locally and will make a release.