From 3ef994375ad4c50369e151e0ccae7725b74bfea6 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 18 Mar 2008 09:12:33 +0000 Subject: add a test for "should-restart" --- MANIFEST | 11 +++++++++++ t/data/SPECS/should-restart/a.spec | 14 ++++++++++++++ t/data/SPECS/should-restart/b.spec | 13 +++++++++++++ t/data/SPECS/should-restart/c.spec | 14 ++++++++++++++ t/superuser--should-restart.t | 29 +++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 t/data/SPECS/should-restart/a.spec create mode 100644 t/data/SPECS/should-restart/b.spec create mode 100644 t/data/SPECS/should-restart/c.spec create mode 100644 t/superuser--should-restart.t diff --git a/MANIFEST b/MANIFEST index 6b3b9baf..553945fd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -185,6 +185,9 @@ t/data/SPECS/rpm-query-in-scriptlet.spec t/data/SPECS/rpmnew/a-1.spec t/data/SPECS/rpmnew/a-2.spec t/data/SPECS/rpmnew/a-3.spec +t/data/SPECS/should-restart/a.spec +t/data/SPECS/should-restart/b.spec +t/data/SPECS/should-restart/c.spec t/data/SPECS/split-transactions--conflict-1/a.spec t/data/SPECS/split-transactions--conflict-1/b.spec t/data/SPECS/split-transactions--conflict-1/c.spec @@ -216,10 +219,17 @@ t/data/SPECS/split-transactions--strict-require-1/b.spec t/data/SPECS/split-transactions--strict-require-1/c.spec t/data/SPECS/split-transactions--strict-require-1/d.spec t/data/SPECS/split-transactions--strict-require-1/dd.spec +t/data/SPECS/split-transactions--strict-require-1/e.spec +t/data/SPECS/split-transactions--strict-require-1/f.spec +t/data/SPECS/split-transactions--strict-require-1/g.spec t/data/SPECS/split-transactions--strict-require-2/a.spec t/data/SPECS/split-transactions--strict-require-2/c.spec t/data/SPECS/split-transactions--strict-require-2/d.spec t/data/SPECS/split-transactions--strict-require-2/dd.spec +t/data/SPECS/split-transactions--strict-require-2/e.spec +t/data/SPECS/split-transactions--strict-require-2/f.spec +t/data/SPECS/split-transactions--strict-require-2/g.spec +t/data/SPECS/split-transactions--strict-require-2/h.spec t/data/SPECS/split-transactions--strict-require-and-obsolete-1/a.spec t/data/SPECS/split-transactions--strict-require-and-obsolete-1/bb.spec t/data/SPECS/split-transactions--strict-require-and-obsolete-1/c-1.spec @@ -267,6 +277,7 @@ t/superuser--provide-and-no-obsolete.t t/superuser--README-urpmi.t t/superuser--rpm.t t/superuser--rpmnew.t +t/superuser--should-restart.t t/superuser--specify-media.t t/superuser--split-transactions--conflict.t t/superuser--split-transactions--promote.t diff --git a/t/data/SPECS/should-restart/a.spec b/t/data/SPECS/should-restart/a.spec new file mode 100644 index 00000000..1c65ba1d --- /dev/null +++ b/t/data/SPECS/should-restart/a.spec @@ -0,0 +1,14 @@ +Summary: x +Name: a +Version: 1 +Release: 1 +License: x +Group: x +Url: x +Provides: should-restart = system +BuildRoot: %{_tmppath}/%{name} + +%description +x + +%files diff --git a/t/data/SPECS/should-restart/b.spec b/t/data/SPECS/should-restart/b.spec new file mode 100644 index 00000000..337a7807 --- /dev/null +++ b/t/data/SPECS/should-restart/b.spec @@ -0,0 +1,13 @@ +Summary: x +Name: b +Version: 1 +Release: 1 +License: x +Group: x +Url: x +BuildRoot: %{_tmppath}/%{name} + +%description +x + +%files diff --git a/t/data/SPECS/should-restart/c.spec b/t/data/SPECS/should-restart/c.spec new file mode 100644 index 00000000..4205104a --- /dev/null +++ b/t/data/SPECS/should-restart/c.spec @@ -0,0 +1,14 @@ +Summary: x +Name: c +Version: 1 +Release: 1 +License: x +Group: x +Url: x +Provides: should-restart = system +BuildRoot: %{_tmppath}/%{name} + +%description +x + +%files diff --git a/t/superuser--should-restart.t b/t/superuser--should-restart.t new file mode 100644 index 00000000..a8729712 --- /dev/null +++ b/t/superuser--should-restart.t @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +# "a" provides "should-restart = system" +# "c" provides "should-restart = system" +# +use strict; +use lib '.', 't'; +use helper; +use Test::More 'no_plan'; + +need_root_and_prepare(); + +my $medium_name = 'should-restart'; + +urpmi_addmedia("$medium_name $::pwd/media/$medium_name"); + +test_urpmi('a', 'You should restart system for a'); +test_urpmi('b', ''); +test_urpmi('c', 'You should restart system for a, c'); + +sub test_urpmi { + my ($para, $wanted) = @_; + my $s = run_urpm_cmd("urpmi $para"); + print $s; + + my $msg = $s =~ /^(You should restart .*)/m ? $1 : ''; + + ok($msg eq $wanted, "wanted:$wanted, got:$msg"); +} -- cgit v1.2.1