File Coverage

blib/lib/Dist/Zilla/App/Command/test.pm
Criterion Covered Total %
statement 6 14 42.8
branch 0 14 0.0
condition 0 12 0.0
subroutine 2 5 40.0
pod 3 3 100.0
total 11 48 22.9


line stmt bran cond sub pod time code
1             package Dist::Zilla::App::Command::test 6.029;
2             # ABSTRACT: test your dist
3              
4 4     4   2644 use Dist::Zilla::Pragmas;
  4         11  
  4         28  
5              
6 4     4   28 use Dist::Zilla::App -command;
  4         11  
  4         29  
7              
8             #pod =head1 SYNOPSIS
9             #pod
10             #pod dzil test [ --release ] [ --no-author ] [ --automated ] [ --extended ] [ --all ]
11             #pod
12             #pod =head1 DESCRIPTION
13             #pod
14             #pod This command is a thin wrapper around the L<test|Dist::Zilla::Dist::Builder/test> method in
15             #pod Dist::Zilla. It builds your dist and runs the tests with the AUTHOR_TESTING
16             #pod environment variable turned on, so it's like doing this:
17             #pod
18             #pod export AUTHOR_TESTING=1
19             #pod dzil build --no-tgz
20             #pod cd $BUILD_DIRECTORY
21             #pod perl Makefile.PL
22             #pod make
23             #pod make test
24             #pod
25             #pod A build that fails tests will be left behind for analysis, and F<dzil> will
26             #pod exit a non-zero value. If the tests are successful, the build directory will
27             #pod be removed and F<dzil> will exit with status 0.
28             #pod
29             #pod =cut
30              
31             sub opt_spec {
32 0     0 1   [ 'release' => 'enables the RELEASE_TESTING env variable', { default => 0 } ],
33             [ 'automated' => 'enables the AUTOMATED_TESTING env variable', { default => 0 } ],
34             [ 'extended' => 'enables the EXTENDED_TESTING env variable', { default => 0 } ],
35             [ 'author!' => 'enables the AUTHOR_TESTING env variable (default behavior)', { default => 1 } ],
36             [ 'all' => 'enables the RELEASE_TESTING, AUTOMATED_TESTING, EXTENDED_TESTING and AUTHOR_TESTING env variables', { default => 0 } ],
37             [ 'keep-build-dir|keep' => 'keep the build directory even after a success' ],
38             [ 'jobs|j=i' => 'number of parallel test jobs to run' ],
39             [ 'test-verbose' => 'enables verbose testing (TEST_VERBOSE env variable on Makefile.PL, --verbose on Build.PL', { default => 0 } ],
40             }
41              
42             #pod =head1 OPTIONS
43             #pod
44             #pod =head2 --release
45             #pod
46             #pod This will run the test suite with RELEASE_TESTING=1
47             #pod
48             #pod =head2 --automated
49             #pod
50             #pod This will run the test suite with AUTOMATED_TESTING=1
51             #pod
52             #pod =head2 --extended
53             #pod
54             #pod This will run the test suite with EXTENDED_TESTING=1
55             #pod
56             #pod =head2 --no-author
57             #pod
58             #pod This will run the test suite without setting AUTHOR_TESTING
59             #pod
60             #pod =head2 --all
61             #pod
62             #pod Equivalent to --release --automated --extended --author
63             #pod
64             #pod =cut
65              
66 0     0 1   sub abstract { 'test your dist' }
67              
68             sub execute {
69 0     0 1   my ($self, $opt, $arg) = @_;
70              
71 0 0 0       local $ENV{RELEASE_TESTING} = 1 if $opt->release or $opt->all;
72 0 0 0       local $ENV{AUTHOR_TESTING} = 1 if $opt->author or $opt->all;
73 0 0 0       local $ENV{AUTOMATED_TESTING} = 1 if $opt->automated or $opt->all;
74 0 0 0       local $ENV{EXTENDED_TESTING} = 1 if $opt->extended or $opt->all;
75              
76 0 0         $self->zilla->test({
    0          
    0          
77             $opt->keep_build_dir
78             ? (keep_build_dir => 1)
79             : (),
80             $opt->jobs
81             ? (jobs => $opt->jobs)
82             : (),
83             $opt->test_verbose
84             ? (test_verbose => $opt->test_verbose)
85             : (),
86             });
87             }
88              
89             1;
90              
91             __END__
92              
93             =pod
94              
95             =encoding UTF-8
96              
97             =head1 NAME
98              
99             Dist::Zilla::App::Command::test - test your dist
100              
101             =head1 VERSION
102              
103             version 6.029
104              
105             =head1 SYNOPSIS
106              
107             dzil test [ --release ] [ --no-author ] [ --automated ] [ --extended ] [ --all ]
108              
109             =head1 DESCRIPTION
110              
111             This command is a thin wrapper around the L<test|Dist::Zilla::Dist::Builder/test> method in
112             Dist::Zilla. It builds your dist and runs the tests with the AUTHOR_TESTING
113             environment variable turned on, so it's like doing this:
114              
115             export AUTHOR_TESTING=1
116             dzil build --no-tgz
117             cd $BUILD_DIRECTORY
118             perl Makefile.PL
119             make
120             make test
121              
122             A build that fails tests will be left behind for analysis, and F<dzil> will
123             exit a non-zero value. If the tests are successful, the build directory will
124             be removed and F<dzil> will exit with status 0.
125              
126             =head1 PERL VERSION
127              
128             This module should work on any version of perl still receiving updates from
129             the Perl 5 Porters. This means it should work on any version of perl released
130             in the last two to three years. (That is, if the most recently released
131             version is v5.40, then this module should work on both v5.40 and v5.38.)
132              
133             Although it may work on older versions of perl, no guarantee is made that the
134             minimum required version will not be increased. The version may be increased
135             for any reason, and there is no promise that patches will be accepted to lower
136             the minimum required perl.
137              
138             =head1 OPTIONS
139              
140             =head2 --release
141              
142             This will run the test suite with RELEASE_TESTING=1
143              
144             =head2 --automated
145              
146             This will run the test suite with AUTOMATED_TESTING=1
147              
148             =head2 --extended
149              
150             This will run the test suite with EXTENDED_TESTING=1
151              
152             =head2 --no-author
153              
154             This will run the test suite without setting AUTHOR_TESTING
155              
156             =head2 --all
157              
158             Equivalent to --release --automated --extended --author
159              
160             =head1 AUTHOR
161              
162             Ricardo SIGNES 😏 <cpan@semiotic.systems>
163              
164             =head1 COPYRIGHT AND LICENSE
165              
166             This software is copyright (c) 2022 by Ricardo SIGNES.
167              
168             This is free software; you can redistribute it and/or modify it under
169             the same terms as the Perl 5 programming language system itself.
170              
171             =cut