App-Fetchware

 view release on metacpan or  search on metacpan

t/bin-fetchware-install.t  view on Meta::CPAN

        : fail("Failed to cp [$fetchware_package_path] to cwd os error [$!].");

    # Steal the *.fpkg that was created in the previous step!
    my $new_fetchware_package_path
        =
        cmd_install(
            catfile($temp_dir, ( splitpath($fetchware_package_path) )[2] )
        );

    is($new_fetchware_package_path, $fetchware_package_path,
        'checked cmd_install(*.fpkg) success.');
};


subtest 'test test-dist.fpkg cmd_install' => sub {
    # Clear App::Fetchware's internal configuration information, which I must do
    # if I parse more than one Fetchwarefile in a running of fetchware.
    __clear_CONFIG();

    my $test_dist_path = make_test_dist(file_name => 'test-dist',
        ver_num => '1.00');
    my $test_dist_md5 = md5sum_file($test_dist_path);


    my $install_success = cmd_install($test_dist_path);
    note("IS[$install_success]");

    ok($install_success,
        'check test-dist.fpkg cmd_install');

    # Now uninstall the useless test dist.
    ok(cmd_uninstall('test-dist-1.00'),
        'checked cmd_install() clean up installed test-dist.');

    ok(unlink($test_dist_path, $test_dist_md5),
        'checked cmd_install() delete temp files.');
};


subtest 'test cmd_install() failure using fail-dist' => sub {
	# Must skip this test unless release testing, because it leaves an orfaned
    # fetchware directory sitting in your system temporary directory. I could
    # have fetchware clean clean this directory up, or try to parse the output
    # to determine the path this directory is in, but that's brittle and
    # ridiculous.
    skip_all_unless_release_testing();
    # Now test cmd_install() failure. Make use of make_test_dist()'s configure
    # option to create a test-dist whoose ./configure will always fail causing
    # build() to fail, which will allow me to test to see if the temp dir stays
    # around, so that when build's fail you can debug them easily.
    my $fail_test_dist = make_test_dist(file_name => 'fail-dist',
        ver_num => '1.00', configure => <<EOF);
# A test ./configure for testing cmd_install() failing

echo "fetchware: ./configure failed!"
# Return failure exit status to truly indicate failure.
exit 1
EOF
    my $fail_dist_md5 = md5sum_file($fail_test_dist);

	fork_not_ok(sub {cmd_install($fail_test_dist)},
		'checked cmd_install() failure.');
};



subtest 'test cmd_install(else)' => sub {
    eval_ok(sub {cmd_install()}, <<EOE, 'checked cmd_install() no args');
fetchware: You called fetchware install incorrectly. You must also specify
either a Fetchwarefile or a fetchware package that ends with [.fpkg].
EOE

    eval_ok(sub {cmd_install('fetchware-test' . rand(3739929293))},
        <<EOE, 'checked cmd_install() file existence');
fetchware: You called fetchware install incorrectly. You must also specify
either a Fetchwarefile or a fetchware package that ends with [.fpkg].
EOE


};


# Remove this or comment it out, and specify the number of tests, because doing
# so is more robust than using this, but this is better than no_plan.
#done_testing();



( run in 1.898 second using v1.01-cache-2.11-cpan-39bf76dae61 )