summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/data/SPECS/prefer/a.spec14
-rw-r--r--t/data/SPECS/prefer/b.spec14
-rw-r--r--t/data/SPECS/prefer/b_foo.spec14
-rw-r--r--t/data/SPECS/prefer/c.spec14
-rw-r--r--t/data/SPECS/prefer/c_foo.spec14
-rw-r--r--t/superuser--prefer.t72
6 files changed, 142 insertions, 0 deletions
diff --git a/t/data/SPECS/prefer/a.spec b/t/data/SPECS/prefer/a.spec
new file mode 100644
index 00000000..30e61f63
--- /dev/null
+++ b/t/data/SPECS/prefer/a.spec
@@ -0,0 +1,14 @@
+Summary: x
+Name: a
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Requires: virtual1
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/prefer/b.spec b/t/data/SPECS/prefer/b.spec
new file mode 100644
index 00000000..e7d79d76
--- /dev/null
+++ b/t/data/SPECS/prefer/b.spec
@@ -0,0 +1,14 @@
+Summary: x
+Name: b
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Provides: virtual1
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/prefer/b_foo.spec b/t/data/SPECS/prefer/b_foo.spec
new file mode 100644
index 00000000..e0cb9d02
--- /dev/null
+++ b/t/data/SPECS/prefer/b_foo.spec
@@ -0,0 +1,14 @@
+Summary: x
+Name: b_foo
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Provides: virtual1
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/prefer/c.spec b/t/data/SPECS/prefer/c.spec
new file mode 100644
index 00000000..88ee35c4
--- /dev/null
+++ b/t/data/SPECS/prefer/c.spec
@@ -0,0 +1,14 @@
+Summary: x
+Name: c
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Provides: virtual1
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
diff --git a/t/data/SPECS/prefer/c_foo.spec b/t/data/SPECS/prefer/c_foo.spec
new file mode 100644
index 00000000..b57f899e
--- /dev/null
+++ b/t/data/SPECS/prefer/c_foo.spec
@@ -0,0 +1,14 @@
+Summary: x
+Name: c_foo
+Version: 1
+Release: 1
+License: x
+Group: x
+Url: x
+Provides: virtual1
+BuildRoot: %{_tmppath}/%{name}
+
+%description
+x
+
+%files
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]);
+}