I cooked up this patch after an IRC discussion with mst. It's effectively a very stripped down equivalent of Devel::Hide.
From 01bc1c688cf6a329444b4fbfe425f9406d5ad33a Mon Sep 17 00:00:00 2001
From: David Golden <xdg@xdg.me>
Date: Sun, 19 Jun 2016 11:09:44 -0400
Subject: [PATCH] Remove test dependency on Test::Without::Module
---
Makefile.PL | 1 -
t/legacy.t | 7 ++++++-
t/none.t | 14 ++++++++------
t/pp.t | 7 ++++++-
t/xs.t | 7 ++++++-
5 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 9ff02cc..1fae27b 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -56,7 +56,6 @@ my %WriteMakefileArgs = (
},
test => {
requires => {
- 'Test::Without::Module' => '0.17',
'Test::More' => '0.88',
},
},
diff --git a/t/legacy.t b/t/legacy.t
index 20223ec..fb5cc19 100644
--- a/t/legacy.t
+++ b/t/legacy.t
@@ -1,7 +1,12 @@
use strict;
use warnings;
-use Test::Without::Module 'Cpanel::JSON::XS';
+# hide Cpanel::JSON::XS
+use lib map {
+ my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} );
+ sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh }
+} qw{Cpanel/JSON/XS.pm};
+
use Test::More 0.88;
use JSON::MaybeXS qw/:legacy/;
diff --git a/t/none.t b/t/none.t
index c3d350a..12faf52 100644
--- a/t/none.t
+++ b/t/none.t
@@ -1,16 +1,18 @@
use strict;
use warnings;
-use Test::Without::Module 'Cpanel::JSON::XS';
-use Test::Without::Module 'JSON::XS';
-use Test::Without::Module 'JSON::PP';
+
+# hide Cpanel::JSON::XS, JSON::XS, JSON::PP
+use lib map {
+ my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} );
+ sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh }
+} qw{Cpanel/JSON/XS.pm JSON/XS.pm JSON/PP.pm};
+
use Test::More 0.88;
ok(!eval { require JSON::MaybeXS; 1 }, 'Class failed to load');
-# Test::Without::Module always causes 'did not return a true value' errors
-
like(
- $@, qr{Cpanel/JSON/XS.pm did not.*JSON/XS.pm did not.*JSON/PP.pm did not}s,
+ $@, qr{Can't locate Cpanel/JSON/XS\.pm.*Can't locate JSON/XS\.pm.*Can't locate JSON/PP\.pm}s,
'All errors reported'
);
diff --git a/t/pp.t b/t/pp.t
index 1d213fb..9aa020f 100644
--- a/t/pp.t
+++ b/t/pp.t
@@ -1,7 +1,12 @@
use strict;
use warnings;
-use Test::Without::Module 'Cpanel::JSON::XS', 'JSON::XS';
+# hide Cpanel::JSON::XS, JSON::XS
+use lib map {
+ my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} );
+ sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh }
+} qw{Cpanel/JSON/XS.pm JSON/XS.pm};
+
use if !eval { require JSON::PP; 1; }, 'Test::More', skip_all => 'No JSON::PP';
use Test::More 0.88;
use JSON::MaybeXS;
diff --git a/t/xs.t b/t/xs.t
index d57a030..8caa2ad 100644
--- a/t/xs.t
+++ b/t/xs.t
@@ -1,7 +1,12 @@
use strict;
use warnings;
-use Test::Without::Module 'Cpanel::JSON::XS';
+# hide Cpanel::JSON::XS
+use lib map {
+ my ( $m, $c ) = ( $_, qq{die "Can't locate $_ (hidden)\n"} );
+ sub { return unless $_[1] eq $m; open my $fh, "<", \$c; return $fh }
+} qw{Cpanel/JSON/XS.pm};
+
use Test::More 0.88;
use JSON::MaybeXS;
--
2.8.3