App-prepare4release

 view release on metacpan or  search on metacpan

t/coverage-deep.t  view on Meta::CPAN

{
	my $v =
		App::prepare4release->min_perl_version_from_pm_content('use v5.8.8;');
	ok( defined $v, 'min perl from use v5.8.8' );
}

# --- file_uses_legacy_assertion_framework Test::Most -------------------------

{
	my $tmp = tempdir( CLEANUP => 1 );
	my $f = File::Spec->catfile( $tmp, 'm.t' );
	open my $fh, '>', $f or die $!;
	print {$fh} "use Test::Most;\n";
	close $fh;
	ok( App::prepare4release->file_uses_legacy_assertion_framework($f),
		'detect Test::Most' );
}

# --- git_default_branch ------------------------------------------------------

{
	is( App::prepare4release->git_default_branch( { git => { default_branch => 'devel' } } ),
		'devel', 'git_default_branch from config' );
}

# --- new() ------------------------------------------------------------------

{
	my $o = App::prepare4release->new(
		config => { a => 1 },
		opts   => { github => 1 },
		identity => { module_name => 'M' },
	);
	is( $o->{config}{a}, 1, 'new() stores config' );
	is( $o->{opts}{github}, 1, 'new() stores opts' );
}

# --- resolve_identity from lib/**/*.pm only ----------------------------------

{
	my $tmp = tempdir( CLEANUP => 1 );
	make_path( File::Spec->catfile( $tmp, 'lib' ) );
	my $pm = File::Spec->catfile( $tmp, 'lib', 'Only.pm' );
	open my $fh, '>', $pm or die $!;
	print {$fh} <<'PM';
package Only::Lib;
our $VERSION = 3;
1;
PM
	close $fh;

	my $id = App::prepare4release->resolve_identity(
		$tmp,
		{},
		{}
	);
	is( $id->{module_name}, 'Only::Lib', 'resolve_identity from first lib pm' );
	ok( $id->{version_from_path}, 'version_from_path from scan' );
}

# --- ensure_xt_author_tests writes eol.t list -------------------------------

{
	my $tmp = tempdir( CLEANUP => 1 );
	make_path( File::Spec->catfile( $tmp, 'lib' ) );
	open my $pm, '>', File::Spec->catfile( $tmp, 'lib', 'E.pm' ) or die $!;
	print {$pm} "package E; our \$VERSION=1; 1;\n";
	close $pm;

	App::prepare4release->ensure_xt_author_tests( $tmp, 0 );
	my $eol = File::Spec->catfile( $tmp, 'xt', 'author', 'eol.t' );
	ok( -e $eol, 'eol.t created' );
	open my $in, '<', $eol or die $!;
	local $/;
	my $b = <$in>;
	like( $b, qr/lib\/E\.pm/, 'eol.t lists scanned files' );
}

# --- integration: run --gitlab --------------------------------------------

sub _write_dist_gitlab {
	my ($root) = @_;
	open my $fj, '>:encoding(UTF-8)', File::Spec->catfile( $root, 'prepare4release.json' );
	print {$fj} qq({"git":{"repo":"group/gitlab-proj"},"dependencies":{"skip":true}}\n);
	close $fj;
	open my $fm, '>:encoding(UTF-8)', File::Spec->catfile( $root, 'Makefile.PL' );
	print {$fm} <<'MK';
use 5.010;
use ExtUtils::MakeMaker;
WriteMakefile(
    NAME => 'G::Lab',
    VERSION_FROM => 'lib/G/Lab.pm',
    LICENSE => 'perl',
    MIN_PERL_VERSION => '5.010001',
);
MK
	close $fm;
	make_path( File::Spec->catfile( $root, 'lib', 'G' ) );
	open my $fp, '>:encoding(UTF-8)', File::Spec->catfile( $root, 'lib', 'G', 'Lab.pm' );
	print {$fp} <<'PM';
package G::Lab;
our $VERSION = '0.01';
use v5.10;
1;
__END__
=head1 N
=cut
PM
	close $fp;
	make_path( File::Spec->catfile( $root, 't' ) );
	open my $ft, '>', File::Spec->catfile( $root, 't', 'x.t' );
	print {$ft} "use Test2::V1; ok 1; done_testing;\n";
	close $ft;
	open my $fr, '>', File::Spec->catfile( $root, 'README.md' );
	print {$fr} "# G::Lab\n";
	close $fr;
}

{
	my $tmp  = tempdir( CLEANUP => 1 );
	my $here = getcwd;
	_write_dist_gitlab($tmp);
	my $blib = File::Spec->catfile( $here, 'lib' );
	local $ENV{PREPARE4RELEASE_PERL_MAX} = '5.18';

	require Config;
	my $exit_code;
	if ( $Config::Config{d_fork} ) {
		my $pid = fork;
		die "fork: $!" unless defined $pid;
		if ( !$pid ) {
			chdir $tmp or exit 126;
			exec $^X, '-I', $blib, '-MApp::prepare4release', '-e',
				'exit App::prepare4release->run(@ARGV)', '--',
				'--verbose', '--gitlab', '--cpan'
				or exit 127;



( run in 0.636 second using v1.01-cache-2.11-cpan-98e64b0badf )