diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2006-11-30 17:57:43 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2006-11-30 17:57:43 +0000 |
commit | 62c1446f09cc16428431510218e5e4f1e06271f3 (patch) | |
tree | a0a3601c5138ac60d2a92752b196ab6bea6c4008 /t/helper.pm | |
parent | 981c22ad5c1752789bbccd1e09302c2123d930d2 (diff) | |
download | urpmi-62c1446f09cc16428431510218e5e4f1e06271f3.tar urpmi-62c1446f09cc16428431510218e5e4f1e06271f3.tar.gz urpmi-62c1446f09cc16428431510218e5e4f1e06271f3.tar.bz2 urpmi-62c1446f09cc16428431510218e5e4f1e06271f3.tar.xz urpmi-62c1446f09cc16428431510218e5e4f1e06271f3.zip |
more tests, clean some others, enhance helper.pm
Diffstat (limited to 't/helper.pm')
-rw-r--r-- | t/helper.pm | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/t/helper.pm b/t/helper.pm index 334700e8..7c8d29b6 100644 --- a/t/helper.pm +++ b/t/helper.pm @@ -1,6 +1,13 @@ package helper; use Test::More; +use base 'Exporter'; +our @EXPORT = qw(need_root_and_prepare + start_httpd httpd_port + urpmi_addmedia urpmi_removemedia + urpmi urpme + system_ + ); my $using_root; sub need_root_and_prepare() { @@ -17,17 +24,40 @@ sub need_root_and_prepare() { $using_root = 1; } +my $server_pid; +sub httpd_port { 6969 } +sub start_httpd() { + $server_pid = fork(); + if ($server_pid == 0) { + mkdir 'tmp'; + exec './simple-httpd', $pwd, "$pwd/tmp", httpd_port(); + exit 1; + } + 'http://localhost:' . httpd_port(); +} + +chdir 't' if -d 't'; + chomp($::pwd = `pwd`); -my $urpmi_debug_opt = '-q';#'-v --debug'; +my $urpmi_debug_opt = '-q'; +#$urpmi_debug_opt = '-v --debug'; sub urpmi_addmedia { my ($para) = @_; system_("perl -I.. ../urpmi.addmedia $urpmi_debug_opt --urpmi-root $::pwd/root $para"); } +sub urpmi_removemedia { + my ($para) = @_; + system_("perl -I.. ../urpmi.removemedia $urpmi_debug_opt --urpmi-root $::pwd/root $para"); +} sub urpmi { my ($para) = @_; system_("perl -I.. ../urpmi $urpmi_debug_opt --urpmi-root $::pwd/root --ignoresize $para"); } +sub urpme { + my ($para) = @_; + system_("perl -I.. ../urpme --urpmi-root $::pwd/root $para"); +} sub system_ { my ($cmd) = @_; @@ -35,6 +65,10 @@ sub system_ { ok($? == 0, $cmd); } -END { $using_root and system('rm -rf root') } +END { + $using_root and system('rm -rf root'); + $server_pid and kill(9, $server_pid); + system('rm -rf tmp'); +} 1; |