Commit ec336711 authored by Johan Ouwerkerk's avatar Johan Ouwerkerk

Remove the hack for prioritising non-KDE modules when sorting modules in build order.

See also issue: #26
Depends on Phabricator diff D20279: https://phabricator.kde.org/D20279
parent 2ca16048
......@@ -744,15 +744,6 @@ sub _compareBuildOrder
{
my ($moduleGraph, $a, $b) = @_;
#
# Always build non-KDE modules first
#
my $bIsKDE = $moduleGraph->{$b}->{module}->isKDEProject();
my $aIsKDE = $moduleGraph->{$a}->{module}->isKDEProject();
my $nonKDE = $bIsKDE ? ($aIsKDE ? 0 : -1) : ($aIsKDE ? 1 : 0);
return $nonKDE if $nonKDE;
#
# Enforce a strict dependency ordering.
# The case where both are true should never happen, since that would
......
......@@ -8,58 +8,27 @@ use Test::More;
use ksb::DependencyResolver;
# Redefine ksb::Module to stub isKDEProject() results
package ksb::Module {
no warnings 'redefine';
sub new
{
my ($class, $kde) = @_;
my $self = {
kde => $kde
};
bless $self, $class;
return $self;
}
sub isKDEProject
{
my $self = shift;
return $self->{kde};
}
};
my $graph1 = {
'a' => {
votes => {
'b' => 1,
'd' => 1
},
module => new ksb::Module(1)
module => 1
},
'b' => {
votes => {},
module => new ksb::Module(1)
module => 1
},
'c' => {
votes => {
'd' => 1
},
module => new ksb::Module(1)
module => 1
},
'd' => {
votes => {},
module => new ksb::Module(1)
},
'e' => {
votes => {},,
module => new ksb::Module(0)
},
'f' => => {
votes => {},,
module => new ksb::Module(0)
module => 1
}
};
......@@ -67,42 +36,20 @@ is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'a', 'a'), 0, "'a' shou
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'a', 'b'), -1, "'a' should be sorted before 'b' by dependency ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'a', 'c'), -1, "'a' should be sorted before 'c' by vote ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'a', 'd'), -1, "'a' should be sorted before 'd' by dependency ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'a', 'e'), 1, "'a' should be sorted after 'e' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'a', 'f'), 1, "'a' should be sorted after 'f' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'b', 'a'), 1, "'b' should be sorted after 'a' by dependency ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'b', 'b'), 0, "'b' should be sorted at the same position as itself");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'b', 'c'), 1, "'b' should be sorted after 'c' by vote ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'b', 'd'), -1, "'b' should be sorted before 'd' by lexicographic ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'b', 'e'), 1, "'b' should be sorted after 'e' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'b', 'f'), 1, "'b' should be sorted after 'f' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'c', 'a'), 1, "'c' should be sorted after 'c' by vote ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'c', 'b'), -1, "'c' should be sorted before 'b' by vote ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'c', 'c'), 0, "'c' should be sorted at the same position as itself");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'c', 'd'), -1, "'c' should be sorted before 'd' by dependency ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'c', 'e'), 1, "'c' should be sorted after 'e' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'c', 'f'), 1, "'c' should be sorted after 'f' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'd', 'a'), 1, "'d' should be sorted after 'a' by dependency ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'd', 'b'), 1, "'d' should be sorted after 'b' by lexicographic ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'd', 'c'), 1, "'d' should be sorted after 'c' by dependency ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'd', 'd'), 0, "'d' should be sorted at the same position as itself");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'd', 'e'), 1, "'d' should be sorted after 'e' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'd', 'f'), 1, "'d' should be sorted after 'f' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'e', 'a'), -1, "'e' should be sorted before 'a' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'e', 'b'), -1, "'e' should be sorted before 'b' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'e', 'c'), -1, "'e' should be sorted before 'c' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'e', 'd'), -1, "'e' should be sorted before 'd' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'e', 'e'), 0, "'e' should be sorted at the same position as itself");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'e', 'f'), -1, "'e' should be sorted before 'f' by lexicographic ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'f', 'a'), -1, "'f' should be sorted before 'a' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'f', 'b'), -1, "'f' should be sorted before 'b' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'f', 'c'), -1, "'f' should be sorted before 'c' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'f', 'd'), -1, "'f' should be sorted before 'd' by prioritising non-KDE modules over KDE ones");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'f', 'e'), 1, "'f' should be sorted after 'e' by lexicographic ordering");
is(ksb::DependencyResolver::_compareBuildOrder($graph1, 'f', 'f'), 0, "'f' should be sorted at the same position as itself");
done_testing();
......@@ -8,36 +8,6 @@ use Test::More;
use ksb::DependencyResolver;
# Redefine ksb::Module to stub isKDEProject() results
package ksb::Module {
no warnings 'redefine';
sub new
{
my ($class, $kde, $name) = @_;
my $self = {
kde => $kde,
name => $name
};
bless $self, $class;
return $self;
}
sub isKDEProject
{
my $self = shift;
return $self->{kde};
}
sub name
{
my $self = shift;
return $self->{name};
}
};
my $graph1 = {
'a' => {
votes => {
......@@ -45,40 +15,30 @@ my $graph1 = {
'd' => 1
},
build => 1,
module => new ksb::Module(1, 'a')
module => 'a'
},
'b' => {
votes => {},
build => 1,
module => new ksb::Module(1, 'b')
module => 'b'
},
'c' => {
votes => {
'd' => 1
},
build => 1,
module => new ksb::Module(1, 'c')
module => 'c'
},
'd' => {
votes => {},
build => 1,
module => new ksb::Module(1, 'd')
},
'e' => {
votes => {},
build => 1,
module => new ksb::Module(0, 'e')
},
'f' => {
votes => {},
build => 1,
module => new ksb::Module(0, 'f')
module => 'd'
}
};
my @expected1 = ('e', 'f', 'a', 'c', 'b', 'd');
my @actual1 = map { $_->name() } (ksb::DependencyResolver::sortModulesIntoBuildOrder($graph1));
my @expected1 = ('a', 'c', 'b', 'd');
my @actual1 = ksb::DependencyResolver::sortModulesIntoBuildOrder($graph1);
is_deeply(\@actual1, \@expected1, "should sort modules into the proper build order");
......@@ -90,12 +50,12 @@ my $graph2 = {
'd' => 1
},
build => 1,
module => new ksb::Module(1, 'c')
module => 'c'
},
'lexical1' => {
votes => {},
build => 1,
module => new ksb::Module(1, 'b')
module => 'b'
},
'nllfmvrb' => {
votes => {
......@@ -103,27 +63,17 @@ my $graph2 = {
'd' => 1
},
build => 1,
module => new ksb::Module(1, 'a')
module => 'a'
},
'lexical2' => {
votes => {},
build => 1,
module => new ksb::Module(1, 'd')
},
'non-KDE-f' => {
votes => {},
build => 1,
module => new ksb::Module(0, 'f')
},
'non-KDE-e' => {
votes => {},
build => 1,
module => new ksb::Module(0, 'e')
module => 'd'
}
};
my @expected2 = ('e', 'f', 'a', 'c', 'b', 'd');
my @actual2 = map { $_->name() } (ksb::DependencyResolver::sortModulesIntoBuildOrder($graph2));
my @expected2 = ('a', 'c', 'b', 'd');
my @actual2 = ksb::DependencyResolver::sortModulesIntoBuildOrder($graph2);
is_deeply(\@actual2, \@expected2, "key order should not matter for build order");
......@@ -134,7 +84,7 @@ my $graph3 = {
'd' => 1
},
build => 0,
module => new ksb::Module(1, 'a')
module => 'a'
},
'b' => {
votes => {},
......@@ -146,17 +96,17 @@ my $graph3 = {
'd' => 1
},
build => 1,
module => new ksb::Module(1, 'c')
module => 'c'
},
'd' => {
votes => {},
build => 1,
module => new ksb::Module(1, 'd')
module => 'd'
}
};
my @expected3 = ('c', 'd');
my @actual3 = map { $_->name() } (ksb::DependencyResolver::sortModulesIntoBuildOrder($graph3));
my @actual3 = ksb::DependencyResolver::sortModulesIntoBuildOrder($graph3);
is_deeply(\@actual3, \@expected3, "modules that are not to be built should be omitted");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment