| 1 | package Test::Perl::Dist; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use 5.008001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Test::More 0.88 import => ['!done_testing']; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Test::Builder; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use parent qw( Exporter ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use English qw( -no_match_vars ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use Scalar::Util qw( blessed ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use LWP::Online qw( :skip_all ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | ▶ | use File::Spec::Functions qw( :ALL ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 1 | ▶ | use File::Path qw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 1 | ▶ | use File::Remove qw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 0 | ▶ | use Win32 qw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 16 | use URI qw(); | ||
| 17 | |||
| 18 | our @EXPORT = | ||
| 19 | qw(test_run_dist test_verify_files_short test_verify_files_medium | ||
| 20 | test_verify_files_long test_verify_portability test_cleanup); | ||
| 21 | push @EXPORT, @Test::More::EXPORT; | ||
| 22 | |||
| 23 | our $VERSION = '0.300'; | ||
| 24 | $VERSION =~ s/_//ms; | ||
| 25 | |||
| 26 | my $tests_completed = 0; | ||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | ##################################################################### | ||
| 31 | # Default Paths | ||
| 32 | |||
| 33 | sub _make_path { | ||
| 34 | my $dir = rel2abs( catdir( curdir(), @_ ) ); | ||
| 35 | if ( not -d $dir ) { | ||
| 36 | File::Path::mkpath($dir); | ||
| 37 | } | ||
| 38 | ok( -d $dir, 'Created ' . $dir ); | ||
| 39 | $tests_completed++; | ||
| 40 | return $dir; | ||
| 41 | } | ||
| 42 | |||
| 43 | sub _remake_path { | ||
| 44 | my $dir = rel2abs( catdir( curdir(), @_ ) ); | ||
| 45 | if ( -d $dir ) { | ||
| 46 | File::Remove::remove( \1, $dir ); | ||
| 47 | } | ||
| 48 | File::Path::mkpath($dir); | ||
| 49 | ok( -d $dir, 'Created ' . $dir ); | ||
| 50 | $tests_completed++; | ||
| 51 | return $dir; | ||
| 52 | } | ||
| 53 | |||
| 54 | sub _paths { | ||
| 55 | my $class = shift; | ||
| 56 | my $subpath = shift || q{}; | ||
| 57 | my $testpath = shift || 't'; | ||
| 58 | |||
| 59 | # Create base and download directory so we can do a | ||
| 60 | # GetShortPathName on it. | ||
| 61 | my $basedir = rel2abs( catdir( $testpath, "tmp$subpath" ) ); | ||
| 62 | my $download = rel2abs( catdir( $testpath, 'download' ) ); | ||
| 63 | |||
| 64 | if ( $basedir =~ m{\s}sm ) { | ||
| 65 | plan( skip_all => | ||
| 66 | 'Cannot test successfully in a test directory with spaces' ); | ||
| 67 | } | ||
| 68 | |||
| 69 | if ( not -d $basedir ) { | ||
| 70 | File::Path::mkpath($basedir); | ||
| 71 | } | ||
| 72 | if ( not -d $download ) { | ||
| 73 | File::Path::mkpath($download); | ||
| 74 | } | ||
| 75 | diag("Test base directory: $basedir"); | ||
| 76 | |||
| 77 | # Make or remake the subpaths | ||
| 78 | my $output_dir = _remake_path( catdir( $basedir, 'output' ) ); | ||
| 79 | my $image_dir = _remake_path( catdir( $basedir, 'image' ) ); | ||
| 80 | my $download_dir = _make_path($download); | ||
| 81 | my $fragment_dir = _remake_path( catdir( $basedir, 'fragments' ) ); | ||
| 82 | my $build_dir = _remake_path( catdir( $basedir, 'build' ) ); | ||
| 83 | my $tempenv_dir = _remake_path( catdir( $basedir, 'tempdir' ) ); | ||
| 84 | return ( | ||
| 85 | output_dir => $output_dir, | ||
| 86 | image_dir => $image_dir, | ||
| 87 | download_dir => $download_dir, | ||
| 88 | build_dir => $build_dir, | ||
| 89 | fragment_dir => $fragment_dir, | ||
| 90 | temp_dir => $basedir, | ||
| 91 | tempenv_dir => $tempenv_dir, | ||
| 92 | ); | ||
| 93 | } ## end sub _paths | ||
| 94 | |||
| 95 | sub _cpan_release { | ||
| 96 | my $class = shift; | ||
| 97 | if ( defined $ENV{PERL_RELEASE_TEST_PERLDIST_CPAN} ) { | ||
| 98 | return ( | ||
| 99 | cpan => URI->new( $ENV{PERL_RELEASE_TEST_PERLDIST_CPAN} ) ); | ||
| 100 | } else { | ||
| 101 | return (); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | sub _forceperl { | ||
| 106 | my $class = shift; | ||
| 107 | if ( defined $ENV{PERL_RELEASE_TEST_FORCEPERL} ) { | ||
| 108 | return ( forceperl => 1 ); | ||
| 109 | } else { | ||
| 110 | return (); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | sub _force { | ||
| 115 | my $class = shift; | ||
| 116 | if ( defined $ENV{PERL_RELEASE_TEST_FORCE} ) { | ||
| 117 | return ( force => 1 ); | ||
| 118 | } else { | ||
| 119 | return (); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | |||
| 124 | |||
| 125 | sub new_test_class_short { | ||
| 126 | my $self = shift; | ||
| 127 | my $test_number = shift; | ||
| 128 | my $test_version = shift; | ||
| 129 | my $class_to_test = shift; | ||
| 130 | my $testpath = shift; | ||
| 131 | |||
| 132 | if ( $OSNAME ne 'MSWin32' ) { | ||
| 133 | plan( skip_all => 'Not on Win32' ); | ||
| 134 | } | ||
| 135 | if ( rel2abs( curdir() ) =~ m{[.]}ms ) { | ||
| 136 | plan( skip_all => | ||
| 137 | 'Cannot be tested in a directory with an extension.' ); | ||
| 138 | } | ||
| 139 | |||
| 140 | my $test_class = | ||
| 141 | $self->_create_test_class_short( $test_number, $test_version, | ||
| 142 | $class_to_test ); | ||
| 143 | my $test_object = eval { | ||
| 144 | my $obj = | ||
| 145 | $test_class->new( $self->_paths( $test_number, $testpath ), | ||
| 146 | $self->_cpan_release(), $self->_forceperl(), $self->_force(), | ||
| 147 | @_ ); | ||
| 148 | return $obj; | ||
| 149 | }; | ||
| 150 | if ($EVAL_ERROR) { | ||
| 151 | if ( blessed($EVAL_ERROR) | ||
| 152 | && $EVAL_ERROR->isa('Exception::Class::Base') ) | ||
| 153 | { | ||
| 154 | diag( $EVAL_ERROR->as_string ); | ||
| 155 | } else { | ||
| 156 | diag($EVAL_ERROR); | ||
| 157 | } | ||
| 158 | |||
| 159 | # Time to get out. | ||
| 160 | BAIL_OUT('Error in test object creation.'); | ||
| 161 | } ## end if ($EVAL_ERROR) | ||
| 162 | |||
| 163 | isa_ok( $test_object, $class_to_test ); | ||
| 164 | $tests_completed++; | ||
| 165 | |||
| 166 | return $test_object; | ||
| 167 | } ## end sub new_test_class_short | ||
| 168 | |||
| 169 | |||
| 170 | |||
| 171 | sub new_test_class_medium { | ||
| 172 | my $self = shift; | ||
| 173 | my $test_number = shift; | ||
| 174 | my $test_version = shift; | ||
| 175 | my $class_to_test = shift; | ||
| 176 | my $testpath = shift; | ||
| 177 | |||
| 178 | if ( $OSNAME ne 'MSWin32' ) { | ||
| 179 | plan( skip_all => 'Not on Win32' ); | ||
| 180 | } | ||
| 181 | if ( not -d 'blib') { | ||
| 182 | plan( skip_all => 'Perl::Dist::WiX::Toolchain has problems if ' . | ||
| 183 | 'dmake or Build has not been ran before testing.' ); | ||
| 184 | } | ||
| 185 | if ( rel2abs( curdir() ) =~ m{[.]}ms ) { | ||
| 186 | plan( skip_all => | ||
| 187 | 'Cannot be tested in a directory with an extension.' ); | ||
| 188 | } | ||
| 189 | |||
| 190 | my $test_class = | ||
| 191 | $self->_create_test_class_medium( $test_number, $test_version, | ||
| 192 | $class_to_test ); | ||
| 193 | my $test_object = eval { | ||
| 194 | $test_class->new( $self->_paths( $test_number, $testpath ), | ||
| 195 | $self->_cpan_release(), $self->_forceperl(), $self->_force(), | ||
| 196 | @_ ); | ||
| 197 | }; | ||
| 198 | |||
| 199 | if ($EVAL_ERROR) { | ||
| 200 | if ( blessed($EVAL_ERROR) | ||
| 201 | && $EVAL_ERROR->isa('Exception::Class::Base') ) | ||
| 202 | { | ||
| 203 | diag( $EVAL_ERROR->as_string() ); | ||
| 204 | } else { | ||
| 205 | diag($EVAL_ERROR); | ||
| 206 | } | ||
| 207 | |||
| 208 | # Time to get out. | ||
| 209 | BAIL_OUT('Error in test object creation.'); | ||
| 210 | } ## end if ($EVAL_ERROR) | ||
| 211 | |||
| 212 | isa_ok( $test_object, $class_to_test ); | ||
| 213 | $tests_completed++; | ||
| 214 | |||
| 215 | return $test_object; | ||
| 216 | } ## end sub new_test_class_medium | ||
| 217 | |||
| 218 | |||
| 219 | |||
| 220 | sub new_test_class_long { | ||
| 221 | my $self = shift; | ||
| 222 | my $test_number = shift; | ||
| 223 | my $test_version = shift; | ||
| 224 | my $class_to_test = shift; | ||
| 225 | my $testpath = shift; | ||
| 226 | |||
| 227 | if ( $OSNAME ne 'MSWin32' ) { | ||
| 228 | plan( skip_all => 'Not on Win32' ); | ||
| 229 | } | ||
| 230 | if ( not -d 'blib') { | ||
| 231 | plan( skip_all => 'Perl::Dist::WiX::Toolchain has problems if ' . | ||
| 232 | 'dmake or Build has not been ran before testing.' ); | ||
| 233 | } | ||
| 234 | if ( rel2abs( curdir() ) =~ m{[.]}ms ) { | ||
| 235 | plan( skip_all => | ||
| 236 | 'Cannot be tested in a directory with an extension.' ); | ||
| 237 | } | ||
| 238 | |||
| 239 | my $test_class = | ||
| 240 | $self->_create_test_class_long( $test_number, $test_version, | ||
| 241 | $class_to_test ); | ||
| 242 | my $test_object = eval { | ||
| 243 | $test_class->new( $self->_paths( $test_number, $testpath ), | ||
| 244 | $self->_cpan_release(), $self->_forceperl(), $self->_force(), | ||
| 245 | @_ ); | ||
| 246 | }; | ||
| 247 | |||
| 248 | if ($EVAL_ERROR) { | ||
| 249 | if ( blessed($EVAL_ERROR) | ||
| 250 | && $EVAL_ERROR->isa('Exception::Class::Base') ) | ||
| 251 | { | ||
| 252 | diag( $EVAL_ERROR->as_string ); | ||
| 253 | } else { | ||
| 254 | diag($EVAL_ERROR); | ||
| 255 | } | ||
| 256 | |||
| 257 | # Time to get out. | ||
| 258 | BAIL_OUT('Error in test object creation.'); | ||
| 259 | } ## end if ($EVAL_ERROR) | ||
| 260 | |||
| 261 | isa_ok( $test_object, $class_to_test ); | ||
| 262 | $tests_completed++; | ||
| 263 | |||
| 264 | return $test_object; | ||
| 265 | } ## end sub new_test_class_long | ||
| 266 | |||
| 267 | |||
| 268 | |||
| 269 | sub test_run_dist { | ||
| 270 | my $dist = shift; | ||
| 271 | |||
| 272 | # Run the dist object, and ensure everything we expect was created | ||
| 273 | my $time = scalar localtime; | ||
| 274 | my $class = ref $dist; | ||
| 275 | if ( $class !~ m/::Short/msx ) { | ||
| 276 | diag("Building test dist @ $time."); | ||
| 277 | if ( $class =~ m/::Long/msx ) { | ||
| 278 | diag('Building may take several hours... (sorry)'); | ||
| 279 | } else { | ||
| 280 | diag('Building may take an hour or two... (sorry)'); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | ok( eval { $dist->run; 1; }, '->run ok' ); | ||
| 284 | if ($EVAL_ERROR) { | ||
| 285 | if ( blessed($EVAL_ERROR) | ||
| 286 | && $EVAL_ERROR->isa('Exception::Class::Base') ) | ||
| 287 | { | ||
| 288 | diag( $EVAL_ERROR->as_string ); | ||
| 289 | } else { | ||
| 290 | diag($EVAL_ERROR); | ||
| 291 | } | ||
| 292 | BAIL_OUT('Could not run test object.'); | ||
| 293 | } | ||
| 294 | $time = scalar localtime; | ||
| 295 | if ( $class !~ m/::Short/msx ) { | ||
| 296 | diag("Test dist finished @ $time."); | ||
| 297 | } | ||
| 298 | $tests_completed++; | ||
| 299 | |||
| 300 | return; | ||
| 301 | } ## end sub test_run_dist | ||
| 302 | |||
| 303 | |||
| 304 | |||
| 305 | sub test_verify_files_short { | ||
| 306 | my $test_number = shift; | ||
| 307 | my $testpath = shift || 't'; | ||
| 308 | my $test_dir = | ||
| 309 | catdir( $testpath, "tmp$test_number", qw{ image c bin } ); | ||
| 310 | |||
| 311 | ok( -f catfile( $test_dir, qw{ dmake.exe } ), 'Found dmake.exe' ); | ||
| 312 | |||
| 313 | ok( -f catfile( $test_dir, qw{ startup Makefile.in } ), | ||
| 314 | 'Found startup' ); | ||
| 315 | |||
| 316 | $tests_completed += 2; | ||
| 317 | |||
| 318 | return; | ||
| 319 | } ## end sub test_verify_files_short | ||
| 320 | |||
| 321 | |||
| 322 | |||
| 323 | sub test_verify_files_medium { | ||
| 324 | my $test_number = shift; | ||
| 325 | my $dll_version = shift; | ||
| 326 | my $testpath = shift || 't'; | ||
| 327 | |||
| 328 | my $dll_file = "perl${dll_version}.dll"; | ||
| 329 | my $test_dir = catdir( $testpath, "tmp$test_number", 'image' ); | ||
| 330 | |||
| 331 | # C toolchain files | ||
| 332 | ok( -f catfile( $test_dir, qw{ c bin dmake.exe } ), 'Found dmake.exe', | ||
| 333 | ); | ||
| 334 | ok( -f catfile( $test_dir, qw{ c bin startup Makefile.in } ), | ||
| 335 | 'Found startup', | ||
| 336 | ); | ||
| 337 | ok( -f catfile( $test_dir, qw{ c bin pexports.exe } ), | ||
| 338 | 'Found pexports', | ||
| 339 | ); | ||
| 340 | |||
| 341 | # Perl core files | ||
| 342 | ok( -f catfile( $test_dir, qw{ perl bin perl.exe } ), | ||
| 343 | 'Found perl.exe', | ||
| 344 | ); | ||
| 345 | |||
| 346 | if ( -f catfile( $test_dir, qw{ image portable.perl } ) ) { | ||
| 347 | |||
| 348 | # Toolchain files | ||
| 349 | ok( -f catfile( $test_dir, qw{ perl site lib LWP.pm } ), | ||
| 350 | 'Found LWP.pm', ); | ||
| 351 | |||
| 352 | # Custom installed file | ||
| 353 | ok( -f catfile( $test_dir, qw{ perl site lib Config Tiny.pm } ), | ||
| 354 | 'Found Config::Tiny', | ||
| 355 | ); | ||
| 356 | } else { | ||
| 357 | |||
| 358 | # Toolchain files | ||
| 359 | ok( -f catfile( $test_dir, qw{ perl vendor lib LWP.pm } ), | ||
| 360 | 'Found LWP.pm', ); | ||
| 361 | |||
| 362 | # Custom installed file | ||
| 363 | ok( -f catfile( $test_dir, qw{ perl vendor lib Config Tiny.pm } ), | ||
| 364 | 'Found Config::Tiny', | ||
| 365 | ); | ||
| 366 | } | ||
| 367 | |||
| 368 | # Did we build Perl correctly? | ||
| 369 | ok( -f catfile( $test_dir, qw{ perl bin }, $dll_file ), | ||
| 370 | 'Found Perl DLL', | ||
| 371 | ); | ||
| 372 | |||
| 373 | $tests_completed += 7; | ||
| 374 | |||
| 375 | return; | ||
| 376 | } ## end sub test_verify_files_medium | ||
| 377 | |||
| 378 | |||
| 379 | |||
| 380 | sub _create_test_class_short { | ||
| 381 | my $self = shift; | ||
| 382 | my $test_number = shift; | ||
| 383 | my $test_version = shift; | ||
| 384 | my $test_class = shift; | ||
| 385 | my $answer = "Test::Perl::Dist::Short$test_number"; | ||
| 386 | |||
| 387 | my $code = <<"EOF"; | ||
| 388 | require $test_class; | ||
| 389 | |||
| 390 | \@${answer}::ISA = ( "$test_class" ); | ||
| 391 | |||
| 392 | ############################################################### | ||
| 393 | # Configuration | ||
| 394 | |||
| 395 | |||
| 396 | ############################################################### | ||
| 397 | # Main Methods | ||
| 398 | |||
| 399 | sub ${answer}::new { | ||
| 400 | return shift->${test_class}::new( | ||
| 401 | perl_version => $test_version, | ||
| 402 | trace => 1, | ||
| 403 | build_number => 1, | ||
| 404 | app_publisher_url => 'http://vanillaperl.org', | ||
| 405 | tasklist => [qw(final_initialization install_dmake)], | ||
| 406 | app_ver_name => 'Test Perl 1 alpha 1', | ||
| 407 | app_name => 'Test Perl', | ||
| 408 | app_publisher => 'Vanilla Perl Project', | ||
| 409 | app_id => 'testperl', | ||
| 410 | \@_, | ||
| 411 | ); | ||
| 412 | } | ||
| 413 | EOF | ||
| 414 | |||
| 415 | eval $code; | ||
| 416 | return $answer; | ||
| 417 | } ## end sub _create_test_class_short | ||
| 418 | |||
| 419 | |||
| 420 | |||
| 421 | sub _create_test_class_medium { | ||
| 422 | my $self = shift; | ||
| 423 | my $test_number = shift; | ||
| 424 | my $test_version = shift; | ||
| 425 | my $test_class = shift; | ||
| 426 | my $answer = "Test::Perl::Dist::Medium$test_number"; | ||
| 427 | |||
| 428 | eval <<"EOF"; | ||
| 429 | require $test_class; | ||
| 430 | |||
| 431 | \@${answer}::ISA = ( "$test_class" ); | ||
| 432 | |||
| 433 | ############################################################### | ||
| 434 | # Main Methods | ||
| 435 | |||
| 436 | sub ${answer}::new { | ||
| 437 | return shift->${test_class}::new( | ||
| 438 | perl_version => $test_version, | ||
| 439 | trace => 1, | ||
| 440 | build_number => 1, | ||
| 441 | app_publisher_url => 'http://vanillaperl.org', | ||
| 442 | app_name => 'Test Perl', | ||
| 443 | app_ver_name => 'Test Perl 1 alpha 1', | ||
| 444 | app_publisher => 'Vanilla Perl Project', | ||
| 445 | app_id => 'testperl', | ||
| 446 | tasklist => [ qw( | ||
| 447 | final_initialization | ||
| 448 | install_c_toolchain | ||
| 449 | install_perl | ||
| 450 | install_perl_toolchain | ||
| 451 | test_distro | ||
| 452 | regenerate_fragments | ||
| 453 | write | ||
| 454 | )], | ||
| 455 | \@_, | ||
| 456 | ); | ||
| 457 | } | ||
| 458 | |||
| 459 | sub ${answer}::test_distro { | ||
| 460 | my \$self = shift; | ||
| 461 | if (\$self->portable()) { | ||
| 462 | \$self->install_distribution( | ||
| 463 | name => 'ADAMK/Config-Tiny-2.12.tar.gz', | ||
| 464 | mod_name => 'Config::Tiny', | ||
| 465 | makefilepl_param => ['INSTALLDIRS=site'], | ||
| 466 | ); | ||
| 467 | } else { | ||
| 468 | \$self->install_distribution( | ||
| 469 | name => 'ADAMK/Config-Tiny-2.12.tar.gz', | ||
| 470 | mod_name => 'Config::Tiny', | ||
| 471 | makefilepl_param => ['INSTALLDIRS=vendor'], | ||
| 472 | ); | ||
| 473 | } | ||
| 474 | return 1; | ||
| 475 | } | ||
| 476 | EOF | ||
| 477 | |||
| 478 | return $answer; | ||
| 479 | } ## end sub _create_test_class_medium | ||
| 480 | |||
| 481 | |||
| 482 | |||
| 483 | sub _create_test_class_long { | ||
| 484 | my $self = shift; | ||
| 485 | my $test_number = shift; | ||
| 486 | my $test_version = shift; | ||
| 487 | my $test_class = shift; | ||
| 488 | my $answer = "Test::Perl::Dist::Long$test_number"; | ||
| 489 | |||
| 490 | eval <<"EOF"; | ||
| 491 | require $test_class; | ||
| 492 | |||
| 493 | \@${answer}::ISA = ( "$test_class" ); | ||
| 494 | |||
| 495 | ############################################################### | ||
| 496 | # Main Methods | ||
| 497 | |||
| 498 | sub ${answer}::new { | ||
| 499 | return shift->${test_class}::new( | ||
| 500 | perl_version => $test_version, | ||
| 501 | trace => 1, | ||
| 502 | build_number => 1, | ||
| 503 | app_publisher_url => 'http://vanillaperl.org', | ||
| 504 | app_name => 'Test Perl', | ||
| 505 | app_ver_name => 'Test Perl 1 alpha 1', | ||
| 506 | app_publisher => 'Vanilla Perl Project', | ||
| 507 | app_id => 'testperl', | ||
| 508 | \@_, | ||
| 509 | ); | ||
| 510 | } | ||
| 511 | |||
| 512 | sub ${answer}::install_cpan_upgrades { | ||
| 513 | my \$self = shift; | ||
| 514 | \$self->${test_class}::install_cpan_upgrades(); | ||
| 515 | if (\$self->portable()) { | ||
| 516 | \$self->install_distribution( | ||
| 517 | name => 'ADAMK/Config-Tiny-2.12.tar.gz', | ||
| 518 | mod_name => 'Config::Tiny', | ||
| 519 | makefilepl_param => ['INSTALLDIRS=site'], | ||
| 520 | ); | ||
| 521 | } else { | ||
| 522 | \$self->install_distribution( | ||
| 523 | name => 'ADAMK/Config-Tiny-2.12.tar.gz', | ||
| 524 | mod_name => 'Config::Tiny', | ||
| 525 | makefilepl_param => ['INSTALLDIRS=vendor'], | ||
| 526 | ); | ||
| 527 | } | ||
| 528 | return 1; | ||
| 529 | } | ||
| 530 | EOF | ||
| 531 | |||
| 532 | return $answer; | ||
| 533 | } ## end sub _create_test_class_long | ||
| 534 | |||
| 535 | |||
| 536 | |||
| 537 | sub test_verify_files_long { | ||
| 538 | my $test_number = shift; | ||
| 539 | my $dll_version = shift; | ||
| 540 | my $testpath = shift || 't'; | ||
| 541 | |||
| 542 | my $dll_file = "perl${dll_version}.dll"; | ||
| 543 | my $test_dir = catdir( $testpath, "tmp$test_number", 'image' ); | ||
| 544 | |||
| 545 | # C toolchain files | ||
| 546 | ok( -f catfile( $test_dir, qw{ c bin dmake.exe } ), 'Found dmake.exe', | ||
| 547 | ); | ||
| 548 | |||
| 549 | ok( -f catfile( $test_dir, qw{ c bin startup startup.mk } ), | ||
| 550 | 'Found startup', | ||
| 551 | ); | ||
| 552 | ok( -f catfile( $test_dir, qw{ c bin pexports.exe } ), | ||
| 553 | 'Found pexports', | ||
| 554 | ); | ||
| 555 | |||
| 556 | # Perl core files | ||
| 557 | ok( -f catfile( $test_dir, qw{ perl bin perl.exe } ), | ||
| 558 | 'Found perl.exe', | ||
| 559 | ); | ||
| 560 | |||
| 561 | if ( -f catfile( $test_dir, qw{ image portable.perl } ) ) { | ||
| 562 | |||
| 563 | # Toolchain files | ||
| 564 | ok( -f catfile( $test_dir, qw{ perl site lib LWP.pm } ), | ||
| 565 | 'Found LWP.pm', ); | ||
| 566 | |||
| 567 | # Custom installed file | ||
| 568 | ok( -f catfile( $test_dir, qw{ perl site lib Config Tiny.pm } ), | ||
| 569 | 'Found Config::Tiny', | ||
| 570 | ); | ||
| 571 | } else { | ||
| 572 | |||
| 573 | # Toolchain files | ||
| 574 | ok( -f catfile( $test_dir, qw{ perl vendor lib LWP.pm } ), | ||
| 575 | 'Found LWP.pm', ); | ||
| 576 | |||
| 577 | # Custom installed file | ||
| 578 | ok( -f catfile( $test_dir, qw{ perl vendor lib Config Tiny.pm } ), | ||
| 579 | 'Found Config::Tiny', | ||
| 580 | ); | ||
| 581 | } | ||
| 582 | |||
| 583 | # Did we build Perl correctly? | ||
| 584 | ok( -f catfile( $test_dir, qw{ perl bin }, $dll_file ), | ||
| 585 | 'Found Perl DLL', | ||
| 586 | ); | ||
| 587 | |||
| 588 | $tests_completed += 7; | ||
| 589 | |||
| 590 | return; | ||
| 591 | } ## end sub test_verify_files_long | ||
| 592 | |||
| 593 | |||
| 594 | |||
| 595 | sub test_verify_portability { | ||
| 596 | my $test_number = shift; | ||
| 597 | my $base_filename = shift; | ||
| 598 | my $testpath = shift || 't'; | ||
| 599 | |||
| 600 | my $test_dir = catdir( 't', "tmp$test_number" ); | ||
| 601 | |||
| 602 | # Did we build the zip file? | ||
| 603 | ok( -f catfile( $test_dir, 'output', "${base_filename}.zip" ), | ||
| 604 | 'Found zip file', | ||
| 605 | ); | ||
| 606 | |||
| 607 | # Did we build it portable? | ||
| 608 | ok( -f catfile( $test_dir, qw{ image portable.perl } ), | ||
| 609 | 'Found portable file', | ||
| 610 | ); | ||
| 611 | ok( -f catfile( $test_dir, qw{ image perl site lib Portable.pm } ), | ||
| 612 | 'Found Portable.pm', | ||
| 613 | ); | ||
| 614 | |||
| 615 | $tests_completed += 3; | ||
| 616 | |||
| 617 | return; | ||
| 618 | } ## end sub test_verify_portability | ||
| 619 | |||
| 620 | |||
| 621 | |||
| 622 | sub test_cleanup { | ||
| 623 | my $test_number = shift; | ||
| 624 | my $testpath = shift || 't'; | ||
| 625 | |||
| 626 | if ( Test::Builder->new()->is_passing() ) { | ||
| 627 | |||
| 628 | diag('Removing build files on successful test.'); | ||
| 629 | my $dir = catdir( $testpath, "tmp$test_number" ); | ||
| 630 | File::Remove::remove( \1, $dir ); | ||
| 631 | } else { | ||
| 632 | diag('Did not pass, so not removing files.'); | ||
| 633 | } | ||
| 634 | |||
| 635 | return; | ||
| 636 | } ## end sub test_cleanup | ||
| 637 | |||
| 638 | |||
| 639 | |||
| 640 | sub done_testing { | ||
| 641 | my $additional_tests = shift || 0; | ||
| 642 | |||
| 643 | return Test::More::done_testing( $tests_completed + $additional_tests ); | ||
| 644 | } | ||
| 645 | |||
| 646 | 1; | ||
| 647 | |||
| 648 | __END__ | ||