Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Fixes for running a clean minitest (at least in OS X) #13746

Closed
p5pRT opened this issue Apr 19, 2014 · 8 comments
Closed

[PATCH] Fixes for running a clean minitest (at least in OS X) #13746

p5pRT opened this issue Apr 19, 2014 · 8 comments
Labels

Comments

@p5pRT
Copy link

p5pRT commented Apr 19, 2014

Migrated from rt.perl.org#121688 (status was 'resolved')

Searchable as RT121688$

@p5pRT
Copy link
Author

p5pRT commented Apr 19, 2014

From @jhi

- detect POSIX locale support differently
- detect PerlIO​::scalar differently (plus bail out earlier if no dscl)
- avoid wide character warning


  t/op/lc.t | 6 +++++-
  t/op/pwent.t | 11 ++++++++---
  t/op/tr.t | 2 +-
  t/uni/fold.t | 9 +++++++--
  4 files changed, 21 insertions(+), 7 deletions(-)

Patch attached.

@p5pRT
Copy link
Author

p5pRT commented Apr 19, 2014

From @jhi

0001-Fixes-for-running-a-clean-minitest-at-least-in-OS-X.patch
From 64ec79eb964e81a6b07bf105b8cb5d917fddf616 Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Sat, 19 Apr 2014 15:38:40 -0400
Subject: [PATCH] Fixes for running a clean minitest (at least in OS X). -
 detect POSIX locale support differently - detect PerlIO::scalar differently
 (plus bail out earlier if no dscl) - avoid wide character warning

---
 t/op/lc.t    |  6 +++++-
 t/op/pwent.t | 11 ++++++++---
 t/op/tr.t    |  2 +-
 t/uni/fold.t |  9 +++++++--
 4 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/t/op/lc.t b/t/op/lc.t
index 38d2b6b..e01f2b0 100644
--- a/t/op/lc.t
+++ b/t/op/lc.t
@@ -322,6 +322,11 @@ my $utf8_locale = find_utf8_ctype_locale();
 SKIP: {
     skip 'Can\'t find a UTF-8 locale', 4*256 unless defined $utf8_locale;
 
+    eval { require POSIX; import POSIX 'locale_h'; };
+    unless (defined &POSIX::LC_CTYPE) {
+        skip "no POSIX (maybe no Fcntl, or no dynamic loading)", 4*256;
+    }
+
     use feature qw( unicode_strings );
 
     no locale;
@@ -339,7 +344,6 @@ SKIP: {
         push @unicode_ucfirst, ucfirst(chr $i);
     }
 
-    use if $Config{d_setlocale}, qw(POSIX locale_h);
     use locale;
     setlocale(LC_CTYPE, $utf8_locale);
 
diff --git a/t/op/pwent.t b/t/op/pwent.t
index 7562bc0..d632c09 100644
--- a/t/op/pwent.t
+++ b/t/op/pwent.t
@@ -36,7 +36,11 @@ $where //= try_prog('NetInfo passwd', 'passwd .', '/usr/bin/nidump');
 $where //= try_prog('NIS+', 'passwd.org_dir', '/bin/niscat');
 
 # Try dscl
-if (!defined $where && $Config::Config{useperlio}) {
+DSCL: {
+my @dscl = qw(/usr/bin/dscl);
+if (!defined $where && $Config::Config{useperlio} && grep { -x } @dscl) {
+    eval { require PerlIO::Scalar; }; # Beware miniperl.
+    last DSCL if $@;
     # Map dscl items to passwd fields, and provide support for
     # mucking with the dscl output if we need to (and we do).
     my %want = do {
@@ -65,7 +69,7 @@ if (!defined $where && $Config::Config{useperlio}) {
     $want{UniqueID}{mung} = $want{PrimaryGroupID}{mung} = sub {
 	unpack 'L', pack 'l', $_[0]};
 
-    foreach my $dscl (qw(/usr/bin/dscl)) {
+    foreach my $dscl (@dscl) {
 	next unless -x $dscl;
 	next unless open my $fh, '-|', "$dscl . -readall /Users @{[keys %want]} 2>/dev/null";
 	my @lines;
@@ -101,12 +105,13 @@ if (!defined $where && $Config::Config{useperlio}) {
 	    push @lines, join (':', @rec) . "\n";
 	}
 	my $data = join '', @lines;
-	if (open PW, '<', \$data) {
+	if (open PW, '<', \$data) { # Needs PerlIO::scalar.
 	    $where = "dscl . -readall /Users";
 	    last;
 	}
     }
 }
+} # DSCL:
 
 if (not defined $where) {
     # Try local.
diff --git a/t/op/tr.t b/t/op/tr.t
index 55a3438..580d55a 100644
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -522,7 +522,7 @@ SKIP: {
 
     my $x = "Perlα";
     $x =~ tr/αα/βγ/;
-    note $x;
+    { no warnings 'utf8'; print "# $x\n"; } # No note() to avoid wide warning.
     is($x, "Perlβ", "Only first of multiple transliterations is used");
 }
 
diff --git a/t/uni/fold.t b/t/uni/fold.t
index 94090e9..032f382 100644
--- a/t/uni/fold.t
+++ b/t/uni/fold.t
@@ -418,9 +418,14 @@ foreach my $test_ref (@CF) {
 }
 
 
-{
+SKIP: {
     use feature qw( fc unicode_strings );
-    use if $Config{d_setlocale}, qw(POSIX locale_h);
+
+    eval { require POSIX; import POSIX 'locale_h'; };
+    unless (defined &POSIX::LC_ALL) {
+       skip "no POSIX (or no Fcntl, or no dynamic loading)", 256;
+    }
+
     setlocale(&POSIX::LC_ALL, "C") if $Config{d_setlocale};
 
     # This tests both code paths in pp_fc
-- 
1.8.5.2 (Apple Git-48)

@p5pRT
Copy link
Author

p5pRT commented Apr 20, 2014

From @tonycoz

On Sat Apr 19 12​:56​:58 2014, jhi wrote​:

- detect POSIX locale support differently
- detect PerlIO​::scalar differently (plus bail out earlier if no dscl)
- avoid wide character warning

---
t/op/lc.t | 6 +++++-
t/op/pwent.t | 11 ++++++++---
t/op/tr.t | 2 +-
t/uni/fold.t | 9 +++++++--
4 files changed, 21 insertions(+), 7 deletions(-)

Patch attached.

I'll apply this after 5.20 is released.

Tony

@p5pRT
Copy link
Author

p5pRT commented Apr 20, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2014

From @jhi

On Sunday-201404-20, 19​:39, Tony Cook via RT wrote​:

On Sat Apr 19 12​:56​:58 2014, jhi wrote​:

- detect POSIX locale support differently
- detect PerlIO​::scalar differently (plus bail out earlier if no dscl)
- avoid wide character warning

---
t/op/lc.t | 6 +++++-
t/op/pwent.t | 11 ++++++++---
t/op/tr.t | 2 +-
t/uni/fold.t | 9 +++++++--
4 files changed, 21 insertions(+), 7 deletions(-)

Patch attached.

I'll apply this after 5.20 is released.

More diddling (nicer test message and nicer commit message),
please discard the earlier 0001 patch, and use the attached one instead.

@p5pRT
Copy link
Author

p5pRT commented Apr 21, 2014

From @jhi

0001-Fixes-for-running-a-clean-minitest-at-least-in-OS-X.patch
From fc4eb24f91500087c2793ae94609bbbec4ab66f1 Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Sat, 19 Apr 2014 15:38:40 -0400
Subject: [PATCH] Fixes for running a clean minitest (at least in OS X). -
 detect POSIX locale support differently: t/op/lc.t, t/uni/fold.t - detect
 PerlIO::scalar differently: t/op/pwent.t - bail out earlier if no dscl:
 t/op/op/pwent.t - avoid wide character warning: t/op/tr.t

---
 t/op/lc.t    |  6 +++++-
 t/op/pwent.t | 14 +++++++++++---
 t/op/tr.t    |  2 +-
 t/uni/fold.t |  9 +++++++--
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/t/op/lc.t b/t/op/lc.t
index 38d2b6b..e01f2b0 100644
--- a/t/op/lc.t
+++ b/t/op/lc.t
@@ -322,6 +322,11 @@ my $utf8_locale = find_utf8_ctype_locale();
 SKIP: {
     skip 'Can\'t find a UTF-8 locale', 4*256 unless defined $utf8_locale;
 
+    eval { require POSIX; import POSIX 'locale_h'; };
+    unless (defined &POSIX::LC_CTYPE) {
+        skip "no POSIX (maybe no Fcntl, or no dynamic loading)", 4*256;
+    }
+
     use feature qw( unicode_strings );
 
     no locale;
@@ -339,7 +344,6 @@ SKIP: {
         push @unicode_ucfirst, ucfirst(chr $i);
     }
 
-    use if $Config{d_setlocale}, qw(POSIX locale_h);
     use locale;
     setlocale(LC_CTYPE, $utf8_locale);
 
diff --git a/t/op/pwent.t b/t/op/pwent.t
index 7562bc0..f4cc8ec 100644
--- a/t/op/pwent.t
+++ b/t/op/pwent.t
@@ -36,7 +36,14 @@ $where //= try_prog('NetInfo passwd', 'passwd .', '/usr/bin/nidump');
 $where //= try_prog('NIS+', 'passwd.org_dir', '/bin/niscat');
 
 # Try dscl
-if (!defined $where && $Config::Config{useperlio}) {
+DSCL: {
+my @dscl = qw(/usr/bin/dscl);
+if (!defined $where && $Config::Config{useperlio} && grep { -x } @dscl) {
+    eval { require PerlIO::scalar; }; # Beware miniperl.
+    if ($@) {
+        print "# No PerlIO::scalar, will not try dscl\n";
+        last DSCL;
+    }
     # Map dscl items to passwd fields, and provide support for
     # mucking with the dscl output if we need to (and we do).
     my %want = do {
@@ -65,7 +72,7 @@ if (!defined $where && $Config::Config{useperlio}) {
     $want{UniqueID}{mung} = $want{PrimaryGroupID}{mung} = sub {
 	unpack 'L', pack 'l', $_[0]};
 
-    foreach my $dscl (qw(/usr/bin/dscl)) {
+    foreach my $dscl (@dscl) {
 	next unless -x $dscl;
 	next unless open my $fh, '-|', "$dscl . -readall /Users @{[keys %want]} 2>/dev/null";
 	my @lines;
@@ -101,12 +108,13 @@ if (!defined $where && $Config::Config{useperlio}) {
 	    push @lines, join (':', @rec) . "\n";
 	}
 	my $data = join '', @lines;
-	if (open PW, '<', \$data) {
+	if (open PW, '<', \$data) { # Needs PerlIO::scalar.
 	    $where = "dscl . -readall /Users";
 	    last;
 	}
     }
 }
+} # DSCL:
 
 if (not defined $where) {
     # Try local.
diff --git a/t/op/tr.t b/t/op/tr.t
index 55a3438..580d55a 100644
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -522,7 +522,7 @@ SKIP: {
 
     my $x = "Perlα";
     $x =~ tr/αα/βγ/;
-    note $x;
+    { no warnings 'utf8'; print "# $x\n"; } # No note() to avoid wide warning.
     is($x, "Perlβ", "Only first of multiple transliterations is used");
 }
 
diff --git a/t/uni/fold.t b/t/uni/fold.t
index 94090e9..032f382 100644
--- a/t/uni/fold.t
+++ b/t/uni/fold.t
@@ -418,9 +418,14 @@ foreach my $test_ref (@CF) {
 }
 
 
-{
+SKIP: {
     use feature qw( fc unicode_strings );
-    use if $Config{d_setlocale}, qw(POSIX locale_h);
+
+    eval { require POSIX; import POSIX 'locale_h'; };
+    unless (defined &POSIX::LC_ALL) {
+       skip "no POSIX (or no Fcntl, or no dynamic loading)", 256;
+    }
+
     setlocale(&POSIX::LC_ALL, "C") if $Config{d_setlocale};
 
     # This tests both code paths in pp_fc
-- 
1.8.5.2 (Apple Git-48)

@p5pRT
Copy link
Author

p5pRT commented May 29, 2014

From @tonycoz

On Sat Apr 19 12​:56​:58 2014, jhi wrote​:

- detect POSIX locale support differently
- detect PerlIO​::scalar differently (plus bail out earlier if no dscl)
- avoid wide character warning

---
t/op/lc.t | 6 +++++-
t/op/pwent.t | 11 ++++++++---
t/op/tr.t | 2 +-
t/uni/fold.t | 9 +++++++--
4 files changed, 21 insertions(+), 7 deletions(-)

Patch attached.

Thanks, applied as baacc34.

Tony

@p5pRT
Copy link
Author

p5pRT commented May 29, 2014

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant