summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/lib/Test/CanThread.pm
diff options
context:
space:
mode:
authorChad Granum <chad.granum@dreamhost.com>2014-11-23 16:24:50 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-23 17:41:32 -0800
commit2e52a9b8712c6c0077b2c34feaedc8404f7af7d5 (patch)
tree7f61bd12287163da13918f5c762df3f6b6276e72 /cpan/Test-Simple/lib/Test/CanThread.pm
parente41e9865be5555602763ac0cf98065a8f3f38189 (diff)
downloadperl-2e52a9b8712c6c0077b2c34feaedc8404f7af7d5.tar.gz
Update Test-Simple to Alpha 078
Diffstat (limited to 'cpan/Test-Simple/lib/Test/CanThread.pm')
-rw-r--r--cpan/Test-Simple/lib/Test/CanThread.pm103
1 files changed, 103 insertions, 0 deletions
diff --git a/cpan/Test-Simple/lib/Test/CanThread.pm b/cpan/Test-Simple/lib/Test/CanThread.pm
new file mode 100644
index 0000000000..a9d6aeb106
--- /dev/null
+++ b/cpan/Test-Simple/lib/Test/CanThread.pm
@@ -0,0 +1,103 @@
+package Test::CanThread;
+use strict;
+use warnings;
+
+use Config;
+
+if ($] == 5.010000) {
+ require Test::More;
+ Test::More::plan(skip_all => "Threads are broken on 5.10.0");
+ exit 0;
+}
+
+my $works = 1;
+$works &&= $] >= 5.008001;
+$works &&= $Config{'useithreads'};
+$works &&= eval { require threads; 'threads'->import; 1 };
+
+unless ($works) {
+ require Test::More;
+ Test::More::plan(skip_all => "Skip no working threads");
+ exit 0;
+}
+
+if ($INC{'Devel/Cover.pm'}) {
+ require Test::More;
+ Test::More::plan(skip_all => "Devel::Cover does not work with threads yet");
+ exit 0;
+}
+
+sub import {
+ my $class = shift;
+ while(my $var = shift(@_)) {
+ next if $ENV{$var};
+
+ require Test::More;
+ Test::More::plan(skip_all => "This threaded test will only run when the '$var' environment variable is set.");
+ exit 0;
+ }
+
+ unshift @_ => 'threads';
+ goto &threads::import;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::CanThread - Only run tests when threading is supported, optionally conditioned on ENV vars.
+
+=head1 DESCRIPTION
+
+Use this first thing in a test that should be skipped when threading is not
+supported. You can also specify that the test should be skipped when specific
+environment variables are not set.
+
+=head1 SYNOPSYS
+
+Skip the test if threading is unsupported:
+
+ use Test::CanThread;
+ use Test::More;
+ ...
+
+Skip the test if threading is unsupported, or any of the specified env vars are
+not set:
+
+ use Test::CanThread qw/AUTHOR_TESTING RUN_PROBLEMATIC_TESTS .../;
+ use Test::More;
+ ...
+
+=head1 SOURCE
+
+The source code repository for Test::More can be found at
+F<http://github.com/Test-More/test-more/>.
+
+=head1 MAINTAINER
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 AUTHORS
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright 2014 Chad Granum E<lt>exodist7@gmail.comE<gt>.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+See F<http://www.perl.com/perl/misc/Artistic.html>
+
+=cut