App-Fetchware
view release on metacpan or search on metacpan
t/bin-fetchware-run.t view on Meta::CPAN
# 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);
verbose_on();
{
local @ARGV = ('install', $test_dist_path);
fork_ok(sub { run() },
'Checked run() test-dist install success');
}
ok(-e catfile(fetchware_database_path(), 'test-dist-1.00.fpkg'),
'checked test-dist install copied to fetchware db.');
# Now uninstall the useless test dist.
ok(cmd_uninstall('test-dist-1.00'),
'checked cmd_install() clean up installed test-dist.');
t/bin-fetchware-run.t view on Meta::CPAN
my $test_dist_path = make_test_dist(file_name => 'test-dist',
ver_num => '1.00', append_option => q{stay_root 'On'});
ok(-e $test_dist_path, 'checked run() test-dist created.');
my $test_dist_md5 = md5sum_file($test_dist_path);
ok(-e $test_dist_md5, 'checked run() test-dist md5 created.');
verbose_on();
{
# Run with --keep-temp option.
local @ARGV = ('--keep-temp', 'install', $test_dist_path);
fork_ok(sub { print "TMP[$ENV{TMPDIR}]"; run() },
'Checked run() test-dist install success');
}
ok(-e catfile(fetchware_database_path(), 'test-dist-1.00.fpkg'),
'checked test-dist install copied to fetchware db.');
# Check that there's fetchware-test-$$ directory in TMPDIR.
ok(chdir("$ENV{TMPDIR}"),
'checked run() chdir()d to TMPDIR.');
t/bin-fetchware-run.t view on Meta::CPAN
# And then test if the install was successful.
ok(grep /test-dist-1.00/, glob(catfile(fetchware_database_path(), '*')),
'check cmd_install(Fetchware) test setup success.');
# Clear internal %CONFIG variable, because I have to parse a Fetchwarefile
# twice, and it's only supported once.
__clear_CONFIG();
{
local @ARGV = ('uninstall', 'test-dist-1.00');
fork_ok(sub { run() },
'Checked run() uninstall test-dist success.');
}
ok(unlink($test_dist_path, $test_dist_md5),
'checked cmd_uninstall() clean up.');
};
##BROKEN## Even t/bin-fetchware-new.t does not actually test new completly yet,
t/bin-fetchware-run.t view on Meta::CPAN
# decent desktop system.
sleep 2;
my $new_test_dist_path = make_test_dist(file_name => 'test-dist',
ver_num => '1.01', destination_directory => $upgrade_temp_dir);
my $new_test_dist_path_md5 = md5sum_file($new_test_dist_path);
{
local @ARGV = ('upgrade', 'test-dist');
fork_ok(sub { run() },
'Checked run() @ARGV upgrade success');
}
print_ok(sub {cmd_list()},
sub {grep({$_ =~ /test-dist-1\.01/} (split "\n", $_[0]))},
'check cmd_upgrade() success.');
# Test for when cmd_upgrade() determines that the latest version is
# installed.
# Clear internal %CONFIG variable, because I have to pare a Fetchwarefile
# twice, and it's only supported once.
__clear_CONFIG();
{
local @ARGV = ('upgrade', 'test-dist');
fork_ok(sub { run() },
'Checked run() @ARGV upgrade version already installed');
}
# Clean up upgrade path.
ok(unlink($old_test_dist_path, $old_test_dist_path_md5,
$new_test_dist_path, $new_test_dist_path_md5),
'checked cmd_upgrade() delete temp upgrade files');
# Clean up installed and upgraded test-dist!
t/bin-fetchware-run.t view on Meta::CPAN
ver_num => '1.01', destination_directory => $upgrade_temp_dir);
my $new_another_dist_path = make_test_dist(file_name => 'another-dist',
ver_num => '1.01', destination_directory => $upgrade_temp_dir);
my $new_test_dist_path_md5 = md5sum_file($new_test_dist_path);
my $new_another_dist_path_md5 = md5sum_file($new_another_dist_path);
# Upgrade all installed fetchware packages.
{
local @ARGV = ('upgrade-all');
fork_ok(sub { run() },
'Checked run() @ARGV upgrade-all success. ');
}
print_ok(sub {cmd_list()},
sub {grep({$_ =~ /(test|another)-dist-1\.01/} (split "\n", $_[0]))},
'check cmd_upgrade_all() success.');
# Test for when cmd_upgrade() determines that the latest version is
t/bin-fetchware-run.t view on Meta::CPAN
# First install a test package to make sure there is something for cmd_list()
# to find.
my $test_dist_path = make_test_dist(file_name => 'test-dist',
ver_num => '1.00');
my $test_dist_md5 = md5sum_file($test_dist_path);
ok(cmd_install($test_dist_path),
'checked cmd_list() by installing a test-dist to list');
{
local @ARGV = ('list');
fork_ok(sub {
print_ok(sub {run()}, qr/test-dist-1\.00/,
'checked cmd_list() success.');
},
'Checked run() @ARGV list success');
}
# Annoyingly clean up CONFIG. Shouln't end() do this!!!!:)
__clear_CONFIG();
t/bin-fetchware-run.t view on Meta::CPAN
'checked cmd_list() delete temp files.');
};
subtest 'test run() look' => sub {
my $test_dist_path = make_test_dist(file_name => 'test-dist',
ver_num => '1.00');
my $test_dist_md5 = md5sum_file($test_dist_path);
{
local @ARGV = ('look', $test_dist_path);
fork_ok(sub {run()},
'checked run() look success.');
}
# Cleanup the test-dist crap.
ok(unlink($test_dist_path, $test_dist_md5),
'checked cmd_list() delete temp files.');
};
t/bin-fetchware-run.t view on Meta::CPAN
my $fetchware_tempdir = tempdir("fetchware-$$-XXXXXXXXX",
DIR => $testing_tempdir, CLEANUP => 1);
my $fetchwarefile_tempdir = tempdir("Fetchwarefile-$$-XXXXXXXXX",
DIR => $testing_tempdir, CLEANUP => 1);
ok(-e $fetchware_tempdir, 'checked creating fetchware temporary directory.');
ok(-e $fetchwarefile_tempdir, 'checked creating Fetchwarefile temporary directory.');
# Delete newly created tempfiles.
{
local @ARGV = ('clean', $testing_tempdir);
fork_ok(sub {run()},
'checked run() clean success.');
}
ok(! -e $fetchware_tempdir,
'checked deleting fetchware temporary directory success.');
ok(! -e $fetchwarefile_tempdir,
'checked deleting Fetchwarefile temporary directory success.');
};
# Tests run() when @ARGV's first value is *not* one of fetchware's allowable
# commands.
subtest 'test run() default' => sub {
{
local @ARGV = ();
fork_ok(sub {
print_ok(sub {run()},
qr/fetchware is a package manager for source code distributions. It gives you the/,
'Checked run() @ARGV = help with print_ok().');
},
'Checked run() with an empty @ARGV.');
}
# Now test that the same else is hit if an unrecognized command is
# specified.
{
local @ARGV = ('unrecognized');
fork_ok(sub {
print_ok(sub {run()},
qr/fetchware is a package manager for source code distributions. It gives you the/,
'Checked run() @ARGV = help with print_ok().');
},
'Checked run() with an unrecognized @ARGV.');
}
};
# Tests run() when @ARGV's first value is *not* one of fetchware's allowable
# commands.
subtest 'test run() help' => sub {
{
local @ARGV = ('help');
fork_ok(sub {
print_ok(sub {run()},
qr/fetchware is a package manager for source code distributions. It gives you the/,
'Checked run() @ARGV = help with print_ok().');
},
'Checked run() @ARGV = help.');
}
};
subtest 'test run() command line options' => sub {
{
local @ARGV = '-h';
fork_ok(sub {
print_ok(sub {run()},
qr/fetchware is a package manager for source code distributions. It gives you the/,
'Checked run() @ARGV = -h with print_ok().');
},
'checked run() -h success.');
}
{
local @ARGV = '-?';
fork_ok(sub {
print_ok(sub {run()},
qr/fetchware is a package manager for source code distributions. It gives you the/,
'Checked run() @ARGV = -? with print_ok().');
},
'checked run() -? success.');
}
{
local @ARGV = '--help';
fork_ok(sub {
print_ok(sub {run()},
qr/fetchware is a package manager for source code distributions. It gives you the/,
'Checked run() @ARGV = --help with print_ok().');
},
'checked run() --help success.');
}
{
local @ARGV = '-V';
fork_ok(sub {
print_ok(sub {run()},
qr/Fetchware version \d.\d\d\d/,
'checked run() -V option success with print_ok().');
},
'Checked run() -V option success.');
}
{
local @ARGV = '--version';
fork_ok(sub {
print_ok(sub {run()},
qr/Fetchware version \d.\d\d\d/,
'checked run() --version option success with print_ok().');
},
'Checked run() --version option success.');
}
};
( run in 0.968 second using v1.01-cache-2.11-cpan-49f99fa48dc )