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

DRAFT: Add support for --without-test and --with-test #667

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions App-cpanminus/Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
See http://github.com/miyagawa/cpanminus/ for the latest development.

{{$NEXT}}
[New Features]
- Support --with-test and --without-test (dboehmer) #651

1.7907 2018-04-26 04:36:02 PDT
[New Features]
Expand Down
16 changes: 16 additions & 0 deletions App-cpanminus/script/cpanm.PL
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ architecture you've already tested to make sure it builds fine.
Defaults to false, and you can say C<--no-notest> to override when it
is set in the default options in C<PERL_CPANM_OPT>.

Not to be confused with C<--without-test>!

=item --test-only

Run the tests only, and do not install the specified module or
Expand Down Expand Up @@ -345,6 +347,20 @@ C<cpanfile> when used with C<--installdeps>. Defaults to false.
B<EXPERIMENTAL>: Installs configure phase dependencies in C<cpanfile>
when used with C<--installdeps>. Defaults to false.

=item --with-test, --without-test

B<EXPERIMENTAL>: Installs C<test> phase dependencies in C<cpanfile>.
Not to be confused with C<--notest>!
Defaults to the value of C<--notest> if no other flags are given.
C<--scandeps> and C<--showdeps> override this value to C<--with-test>.
With C<--notest> and C<--installdeps> dependencies are installed
without test but for the C<cpanfile> or given distribution their
test dependencies are installed as well. You can override this by
setting C<--without-test> to skip their test dependencies as well.

There's C<--with-test> to override a C<--without-test> in
C<PERL_CPANM_OPT>.

=item --with-feature, --without-feature, --with-all-features

B<EXPERIMENTAL>: Specifies the feature to enable, if a module supports
Expand Down
15 changes: 15 additions & 0 deletions App-cpanminus/xt/cpanfile.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ use xt::Run;
like last_build_log, qr/installed Module-Build-Tiny/;
}

{
run_L "--installdeps", "--notest", "./testdist/cpanfile_app";

like last_build_log, qr/Checking if you have Hash::MultiValue .* Yes \(0\.10\)/;
like last_build_log, qr/Checking if you have Try::Tiny .* Yes \(0\.11\)/;
like last_build_log, qr/Checking if you have Test::Warn/;
}

{
run_L "--installdeps", "--without-test", "./testdist/cpanfile_app";

like last_build_log, qr/Checking if you have Hash::MultiValue .* Yes \(0\.10\)/;
like last_build_log, qr/Checking if you have Try::Tiny .* Yes \(0\.11\)/;
unlike last_build_log, qr/Test::Warn/;
}

{
run "--installdeps", "./testdist/cpanfile_bad_app";
Expand Down
21 changes: 16 additions & 5 deletions Menlo-Legacy/lib/Menlo/CLI/Compat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ sub parse_options {
'without-develop' => sub { $self->{with_develop} = 0 },
'with-configure' => \$self->{with_configure},
'without-configure' => sub { $self->{with_configure} = 0 },
'with-test' => \$self->{with_test},
'without-test' => sub { $self->{with_test} = 0 },
'with-feature=s' => sub { $self->{features}{$_[1]} = 1 },
'without-feature=s' => sub { $self->{features}{$_[1]} = 0 },
'with-all-features' => sub { $self->{features}{__all} = 1 },
Expand Down Expand Up @@ -1977,13 +1979,22 @@ sub build_stuff {
}

# install direct 'test' dependencies for --installdeps, even with --notest
# except --without-test is given
# TODO: remove build dependencies for static install
my $deps_only = $self->deps_only($depth);
$dist->{want_phases} = $self->{notest} && !$self->deps_only($depth)
? [qw( build runtime )] : [qw( build test runtime )];
{
my @want_phases = qw( build runtime );

if( defined $self->{with_test} ) {
push @want_phases, 'test' if $self->{with_test};
}
else {
push @want_phases, 'test' if !$self->{notest} || $self->deps_only($depth);
}

push @{$dist->{want_phases}}, 'develop' if $self->{with_develop} && $depth == 0;
push @{$dist->{want_phases}}, 'configure' if $self->{with_configure} && $depth == 0;
push @want_phases, 'develop' if $self->{with_develop} && $depth == 0;
push @want_phases, 'configure' if $self->{with_configure} && $depth == 0;
$dist->{want_phases} = \@want_phases;
}

my @deps = $self->find_prereqs($dist);
my $module_name = $self->find_module_name($configure_state) || $dist->{meta}{name};
Expand Down
Loading