Skip to content

Commit

Permalink
Make error reporting more like perl-BSSolv
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Apr 13, 2017
1 parent 0980953 commit 2f1ebb4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
17 changes: 8 additions & 9 deletions Build.pm
Expand Up @@ -972,7 +972,7 @@ sub checkconflicts {
}
my @eq = grep {$ins->{$_}} @{$whatprovides->{$r} || addproviders($config, $r)};
next unless @eq;
push @$eq, map {"provider $q conflicts with installed $_"} @eq;
push @$eq, map {"(provider $q conflicts with installed $_)"} @eq;
return 1;
}
return 0;
Expand All @@ -984,7 +984,7 @@ sub checkobsoletes {
for my $r (@r) {
my @eq = grep {$ins->{$_}} nevrmatch($config, $r, @{$whatprovides->{$r} || addproviders($config, $r)});
next unless @eq;
push @$eq, map {"provider $q is obsoleted by installed $_"} @eq;
push @$eq, map {"(provider $q is obsoleted by installed $_)"} @eq;
return 1;
}
return 0;
Expand Down Expand Up @@ -1152,7 +1152,7 @@ sub handlerichcon {
next unless @$cond;
my @notyet = grep{!$installed->{$_}} @$cond;
if (!@notyet) {
push @$error, "$p conflicts with installed ".join(' and ', @$cond);
push @$error, "$p conflicts with installed ".join(' and ', sort(@$cond));
} elsif (@notyet == 1) {
$aconflicts->{$notyet[0]} = "conflicts with installed $p";
}
Expand All @@ -1170,7 +1170,7 @@ sub handlerichcon_notins {
next if @q || !@$cond;
my @notyet = grep{!$installed->{$_}} @$cond;
next if @notyet;
push @$eq, "provider $p conflicts with installed ".join(' and ', @$cond);
push @$eq, "(provider $p conflicts with installed ".join(' and ', sort(@$cond)).")";
return 1;
}
return 0;
Expand Down Expand Up @@ -1237,7 +1237,7 @@ sub expand {
my @eq;
if ((@{$pkgconflicts->{$q[0]} || []} && checkconflicts($config, \%p, $q[0], \@eq, @{$pkgconflicts->{$q[0]}})) ||
(@{$pkgobsoletes->{$q[0]} || []} && checkobsoletes($config, \%p, $q[0], \@eq, @{$pkgobsoletes->{$q[0]}}))) {
return (undef, "conflict for $q[0] (".join(', ', sort(@eq)).")");
return (undef, "conflict for package $q[0]", sort(@eq));
}
}
print "added $q[0] because of $p (direct dep)\n" if $expand_dbg;
Expand Down Expand Up @@ -1302,7 +1302,7 @@ sub expand {
next if grep {$xignore{$_}} @q;
next if grep {$ignore->{"$p:$_"} || $xignore{"$p:$_"}} @q;
}
my @eq = map {"provider $_ $aconflicts{$_}"} grep {$aconflicts{$_}} @q;
my @eq = map {"(provider $_ $aconflicts{$_})"} grep {$aconflicts{$_}} @q;
@q = grep {!$aconflicts{$_}} @q;
if (!$ignoreconflicts) {
for my $q (splice @q) {
Expand All @@ -1313,13 +1313,12 @@ sub expand {
}
}
if (!@q) {
my $eq = @eq ? " (".join(', ', sort(@eq)).")" : '';
my $msg = @eq ? 'conflict for providers of' : 'nothing provides';
if ($r eq $p) {
push @rerror, "$msg $r$eq";
push @rerror, "$msg $r", sort(@eq);
} else {
next if $r =~ /^\// && !@eq;
push @rerror, "$msg $r needed by $p$eq";
push @rerror, "$msg $r needed by $p", sort(@eq);
}
next;
}
Expand Down
8 changes: 4 additions & 4 deletions t/conflicts.t
Expand Up @@ -55,13 +55,13 @@ is_deeply(\@r, [1, 'a', 'c', 'd'], 'install a d');
is_deeply(\@r, [1, 'a', 'b', 'e'], 'install a e');

@r = expand($config, 'a', 'd', 'e');
is_deeply(\@r, [undef, 'conflict for providers of p needed by a (provider b conflicts with installed d, provider c conflicts with installed e)'], 'install a d e');
is_deeply(\@r, [undef, '(provider b conflicts with installed d)', '(provider c conflicts with installed e)', 'conflict for providers of p needed by a'], 'install a d e');

@r = expand($config, 'a', 'f');
is_deeply(\@r, [undef, 'conflict for providers of p needed by a (provider b conflicts with installed f, provider c conflicts with installed f)'], 'install a f');
is_deeply(\@r, [undef, '(provider b conflicts with installed f)', '(provider c conflicts with installed f)', 'conflict for providers of p needed by a'], 'install a f');

@r = expand($config, 'b', 'f');
is_deeply(\@r, [undef, 'conflict for f (provider f conflicts with installed b)'], 'install b f');
is_deeply(\@r, [undef, '(provider f conflicts with installed b)', 'conflict for package f'], 'install b f');

@r = expand($config, 'b', 'h');
is_deeply(\@r, [undef, 'conflict for providers of f needed by h (provider f conflicts with installed b)'], 'install b h');
is_deeply(\@r, [undef, '(provider f conflicts with installed b)', 'conflict for providers of f needed by h'], 'install b h');
2 changes: 1 addition & 1 deletion t/obsoletes.t
Expand Up @@ -53,7 +53,7 @@ is_deeply(\@r, [1, 'a', 'c', 'd'], 'install a d');
is_deeply(\@r, [1, 'a', 'b', 'e'], 'install a e');

@r = expand($config, 'a', 'd', 'e');
is_deeply(\@r, [undef, 'conflict for providers of p needed by a (provider b is obsoleted by installed d, provider c is obsoleted by installed e)'], 'install a d e');
is_deeply(\@r, [undef, '(provider b is obsoleted by installed d)', '(provider c is obsoleted by installed e)', 'conflict for providers of p needed by a'], 'install a d e');

@r = expand($config, 'a', 'f');
is_deeply(\@r, [undef, 'have choice for p needed by a: b c'], 'install a f');
4 changes: 2 additions & 2 deletions t/richdeps.t
Expand Up @@ -71,7 +71,7 @@ is_deeply(\@r, [undef, 'nothing provides n', 'nothing provides o'], 'install (n
is_deeply(\@r, [undef, "nothing provides n needed by n1"], "install n1");

@r = expand($config, "(n2 and d)");
is_deeply(\@r, [undef, "conflict for providers of (n2 and d) (provider d conflicts with installed n2)"], "install (n2 and d)");
is_deeply(\@r, [undef, '(provider d conflicts with installed n2)', "conflict for providers of (n2 and d)"], "install (n2 and d)");

@r = expand($config, "(n2 or d)");
is_deeply(\@r, [undef, "have choice for (n2 or d): d n2"], "install (n2 or d)");
Expand All @@ -80,4 +80,4 @@ is_deeply(\@r, [undef, "have choice for (n2 or d): d n2"], "install (n2 or d)");
is_deeply(\@r, [1, qw{a b c d}], "install a");

@r = expand($config, 'i', 'j');
is_deeply(\@r, [undef, "conflict for providers of k needed by j (provider k conflicts with installed i and j)"], "install i j");
is_deeply(\@r, [undef, '(provider k conflicts with installed i and j)', "conflict for providers of k needed by j"], "install i j");

0 comments on commit 2f1ebb4

Please sign in to comment.