summaryrefslogtreecommitdiffstats
path: root/t/superuser--prefer.t
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-08-11 16:25:18 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-08-11 16:25:18 +0000
commit57ce115d84224fe8dd75f19490f788fe8acf198c (patch)
treeb66cbe8793ca5291d0e7ea7f73bba593296fe949 /t/superuser--prefer.t
parentf0c0ba3c176af4afd6659f532541043c7143e0e8 (diff)
downloadurpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar.gz
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar.bz2
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar.xz
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.zip
- urpmi
o handle preferred choices (through --prefer, /etc/urpmi/prefer.list and /etc/urpmi/prefer.vendor.list)
Diffstat (limited to 't/superuser--prefer.t')
-rw-r--r--t/superuser--prefer.t72
1 files changed, 72 insertions, 0 deletions
diff --git a/t/superuser--prefer.t b/t/superuser--prefer.t
new file mode 100644
index 00000000..d9b539a9
--- /dev/null
+++ b/t/superuser--prefer.t
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+
+use strict;
+use lib '.', 't';
+use helper;
+use Expect;
+use urpm::util;
+use Test::More 'no_plan';
+
+need_root_and_prepare();
+
+my $medium_name = 'prefer';
+
+urpmi_addmedia("$medium_name $::pwd/media/$medium_name");
+
+urpmi("--auto --prefer b a");
+check_installed_and_remove('a', 'b');
+
+urpmi("--auto --prefer c a");
+check_installed_and_remove('a', 'c');
+
+test('/foo/', 'foo');
+test('a,a_foo', '^(a|a_foo)$');
+
+
+sub test {
+ my ($prefer, $regexp) = @_;
+
+ my $options = "--prefer '$prefer' a";
+ my @expected = (
+ [ 'What is your choice', "\n" ],
+ [ 'Proceed with the installation of the 2 packages?', "\n" ],
+ );
+
+ if (0) {
+ #- try it interactively for debugging
+ system_(urpm_cmd('urpmi', '-d') . " $options");
+ return;
+ }
+
+ my $cmd = urpmi_cmd() . " $options";
+ print "# $cmd\n";
+ my $expect = Expect->spawn($cmd);
+
+ my $choices;
+ foreach (@expected) {
+ my ($msg, $to_send) = @$_;
+
+ my $ok = $expect->expect(2, # timeout in seconds
+ [ $msg => sub { $choices ||= $expect->before; $expect->send($to_send); } ]);
+ print "$to_send";
+ ok($ok, qq(expecting "$msg"));
+ $ok or return;
+ }
+ my @choices = grep { s/^\s*\d+- (.*?)-.*?:.*/$1/ } split("\n", $choices);
+ is(int(@choices), 4, "4 choices in $choices");
+ my $other = '';
+ foreach (@choices) {
+ if (/$regexp/) {
+ ok(!$other, "line $_ must be before $other line");
+ } else {
+ $other = $_;
+ }
+ }
+
+ $expect->expect(2, [ 'eof' => sub {} ]);
+
+ $expect->soft_close;
+ is($expect->exitstatus, 0, $cmd);
+
+ check_installed_and_remove('a', $choices[0]);
+}