summaryrefslogtreecommitdiffstats
path: root/t/helper.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-30 13:28:03 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-30 13:28:03 +0000
commit37b66b6b34d29c9e628c4a0bbf5babdb5e1340fe (patch)
tree9847ca49d51ce41e951fcabcd0ed6344a3e5009a /t/helper.pm
parente15d45cca3d34d223927cf37f497de3a9703fb78 (diff)
downloadurpmi-37b66b6b34d29c9e628c4a0bbf5babdb5e1340fe.tar
urpmi-37b66b6b34d29c9e628c4a0bbf5babdb5e1340fe.tar.gz
urpmi-37b66b6b34d29c9e628c4a0bbf5babdb5e1340fe.tar.bz2
urpmi-37b66b6b34d29c9e628c4a0bbf5babdb5e1340fe.tar.xz
urpmi-37b66b6b34d29c9e628c4a0bbf5babdb5e1340fe.zip
using --urpmi-root, create some tests using urpmi.addmedia, urpmi, urpme
one drawback of the superuser--*.t is the need to be root (the rpmlib needs it to install in a root partition), so for now "make test" tests *.t but superuser--*.t are skipped. Then as root, run "sudo make test TEST_FILES='t/superuser--*.t'"
Diffstat (limited to 't/helper.pm')
-rw-r--r--t/helper.pm40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/helper.pm b/t/helper.pm
new file mode 100644
index 00000000..334700e8
--- /dev/null
+++ b/t/helper.pm
@@ -0,0 +1,40 @@
+package helper;
+
+use Test::More;
+
+my $using_root;
+sub need_root_and_prepare() {
+ if ($< != 0) {
+ #- can't test
+ pass();
+ exit(0);
+ }
+ -d 'media' or die "02create_pkgs.t not done\n";
+
+ system('rm -rf root');
+ isnt(-d 'root', "test root dir can not be removed $!");
+ mkdir 'root';
+ $using_root = 1;
+}
+
+chomp($::pwd = `pwd`);
+my $urpmi_debug_opt = '-q';#'-v --debug';
+
+sub urpmi_addmedia {
+ my ($para) = @_;
+ system_("perl -I.. ../urpmi.addmedia $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 system_ {
+ my ($cmd) = @_;
+ system($cmd);
+ ok($? == 0, $cmd);
+}
+
+END { $using_root and system('rm -rf root') }
+
+1;