aboutsummaryrefslogtreecommitdiffstats
path: root/t/resolve.t
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2011-01-08 02:18:55 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2011-01-08 02:18:55 +0000
commite6aaf4fd7971f354b9e10bc700ac0ddd9eaacdea (patch)
tree87f0f269c1cb104a21376ceb2c16dcda2bc33e57 /t/resolve.t
parent4e3cd9489085923fcb20993f62f59632cedb03f3 (diff)
downloadperl-URPM-e6aaf4fd7971f354b9e10bc700ac0ddd9eaacdea.tar
perl-URPM-e6aaf4fd7971f354b9e10bc700ac0ddd9eaacdea.tar.gz
perl-URPM-e6aaf4fd7971f354b9e10bc700ac0ddd9eaacdea.tar.bz2
perl-URPM-e6aaf4fd7971f354b9e10bc700ac0ddd9eaacdea.tar.xz
perl-URPM-e6aaf4fd7971f354b9e10bc700ac0ddd9eaacdea.zip
merge rpm5 branch
Diffstat (limited to 't/resolve.t')
-rw-r--r--t/resolve.t71
1 files changed, 71 insertions, 0 deletions
diff --git a/t/resolve.t b/t/resolve.t
new file mode 100644
index 0000000..15649e9
--- /dev/null
+++ b/t/resolve.t
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+
+use strict ;
+use warnings ;
+use Test::More tests => 6;
+use URPM;
+
+chdir 't' if -d 't';
+
+my $urpm;
+my $db;
+
+# There's currently not implemented any way for closing the rpmdb, so we cannot
+# delete it from perl itself, as the rpmdb won't close before perl exists,
+# which will give us errors when trying to close the rpmdb after it's been
+# deleted. Therefore we just fork a shell in the background which deletes it
+# after a 1 sec delay, which should give perl time to exit and close the
+# rpmdb before.
+END {
+ system('sh -c "sleep 1; rm -rf tmp" &');
+}
+
+sub solve_check {
+ my ($pkg, $pkgtotal, $suggest, $write) = @_;
+ my $cand_pkgs = $urpm->find_candidate_packages($pkg);
+ my @pkgs;
+ my $out;
+ my $in = "";
+ my $file = "res/$pkg.resolve";
+ if ($suggest) {
+ @pkgs = $urpm->resolve_requested($db, undef, $cand_pkgs);
+ $file .= ".suggests";
+ } else {
+ @pkgs = $urpm->resolve_requested__no_suggests_($db, undef, $cand_pkgs);
+ $file .= ".nosuggests";
+ }
+ foreach (@pkgs) {
+ $out .= $_->fullname() . "\n";
+ }
+ if ($write) {
+ open FILE, ">$file";
+
+ print FILE $out;
+ close FILE;
+ } else {
+ open(my $diff, "echo -n '$out' | diff -pu $file - |") or die $!;
+ while(<$diff>) {
+ $in .= <$diff>;
+
+ }
+ close($diff);
+ }
+ is($in, "", "$file comparision");
+
+ is(int @pkgs, $pkgtotal, "$pkg total number of packages");
+}
+
+SKIP: {
+ my $synthesis = "res/synthesis.hdlist.xz";
+
+ if (!(-r $synthesis)) {
+ skip "$synthesis missing, only found in svn", 6;
+ }
+ $db = URPM::DB::open("tmp", 1);
+ $urpm = new URPM;
+ $urpm->parse_synthesis($synthesis);
+
+ solve_check("basesystem-minimal", 141, 0, 0);
+ solve_check("basesystem", 527, 1, 0);
+ solve_check("task-kde4", 2059, 1, 0);
+}