aboutsummaryrefslogtreecommitdiffstats
path: root/t/resolve.t
blob: 13016c4b41c6e6097e6969fafdf01e0711f2d6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/perl

use strict ;
use warnings ;
use Test::More tests => 6;
use URPM;

chdir 't' if -d 't';

my $urpm;
my $db;

END {
    if($db) {
    	$db = URPM::DB::close($db);
    }
    system("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);
}