Add testcase for bug 394497 (ignore-modules/include-dependencies).

This adds a testcase that would fail without the bugfix for bug 394497
and now passes.

This did require undoing some of the changes to generateModuleList but
the only real behavior change (beside merging duplicate ignored module
checks) was to move the step that generates module dependencies to occur
earlier so that it can happen before the filter steps

CCBUG:394497
wilder^2
Michael Pyne 8 years ago
parent fe41e0645d
commit ca30f09b51
  1. 89
      modules/ksb/Application.pm
  2. 51
      t/bug-394497-ignore-dep-module.t

@ -53,7 +53,6 @@ sub new
metadata_module => undef, metadata_module => undef,
run_mode => 'build', run_mode => 'build',
modules => undef, modules => undef,
ignored_selectors => [ ],
module_factory => undef, # ref to sub that makes a new Module. module_factory => undef, # ref to sub that makes a new Module.
# See generateModuleList # See generateModuleList
_base_pid => $$, # See finish() _base_pid => $$, # See finish()
@ -323,11 +322,11 @@ DONE
} }
# Generates the build context and module list based on the command line options # Generates the build context and module list based on the command line options
# and module selectors provided, and sets up the module factory. # and module selectors provided, resolves dependencies on those modules if needed,
# filters out ignored or skipped modules, and sets up the module factory.
# #
# After this function is called all module set selectors will have been # After this function is called all module set selectors will have been
# expanded, and we will know if we need to download kde-projects metadata or # expanded, and we will have downloaded kde-projects metadata.
# not. Dependency resolution has not occurred.
# #
# Returns: List of Modules to build. # Returns: List of Modules to build.
sub generateModuleList sub generateModuleList
@ -348,11 +347,9 @@ sub generateModuleList
$self->_readCommandLineOptionsAndSelectors($cmdlineOptions, \@selectors, $self->_readCommandLineOptionsAndSelectors($cmdlineOptions, \@selectors,
$ctx, @argv); $ctx, @argv);
# NOTE these are both listrefs # Convert list to hash for lookup
$self->{ignored_selectors} = $cmdlineGlobalOptions->{'ignore-modules'}; my %ignoredSelectors =
map { $_, 1 } @{$cmdlineGlobalOptions->{'ignore-modules'}};
my %ignoredSelectors;
@ignoredSelectors{@{$self->{ignored_selectors}}} = undef;
my @startProgramAndArgs = @{$cmdlineGlobalOptions->{'start-program'}}; my @startProgramAndArgs = @{$cmdlineGlobalOptions->{'start-program'}};
delete @{$cmdlineGlobalOptions}{qw/ignore-modules start-program/}; delete @{$cmdlineGlobalOptions}{qw/ignore-modules start-program/};
@ -414,8 +411,13 @@ sub generateModuleList
# available. # available.
$ctx->setKDEDependenciesMetadataModuleNeeded(); $ctx->setKDEDependenciesMetadataModuleNeeded();
$ctx->setKDEProjectsMetadataModuleNeeded(); $ctx->setKDEProjectsMetadataModuleNeeded();
ksb::Updater::Git::verifyGitConfig();
$self->_downloadKDEProjectMetadata(); if (!exists $ENV{HARNESS_ACTIVE}) {
# Running in a test harness, avoid downloading metadata which will be
# ignored in the test or making changes to git config
ksb::Updater::Git::verifyGitConfig();
$self->_downloadKDEProjectMetadata();
}
# The user might only want metadata to update to allow for a later # The user might only want metadata to update to allow for a later
# --pretend run, check for that here. # --pretend run, check for that here.
@ -435,7 +437,7 @@ sub generateModuleList
$moduleResolver->setCmdlineOptions($cmdlineOptions); $moduleResolver->setCmdlineOptions($cmdlineOptions);
$moduleResolver->setDeferredOptions($deferredOptions); $moduleResolver->setDeferredOptions($deferredOptions);
$moduleResolver->setInputModulesAndOptions(\@optionModulesAndSets); $moduleResolver->setInputModulesAndOptions(\@optionModulesAndSets);
$moduleResolver->setIgnoredSelectors($self->{ignored_selectors}); $moduleResolver->setIgnoredSelectors([keys %ignoredSelectors]);
$self->_defineNewModuleFactory($moduleResolver); $self->_defineNewModuleFactory($moduleResolver);
@ -456,15 +458,40 @@ sub generateModuleList
ksb::Module->setModuleSource('config'); ksb::Module->setModuleSource('config');
} }
# Check for ignored modules (post-expansion)
@modules = grep { ! exists $ignoredSelectors{$_->name()} } @modules;
# If modules were on the command line then they are effectively forced to # If modules were on the command line then they are effectively forced to
# process unless overridden by command line options as well. If phases # process unless overridden by command line options as well. If phases
# *were* overridden on the command line, then no update pass is required # *were* overridden on the command line, then no update pass is required
# (all modules already have correct phases) # (all modules already have correct phases)
@modules = _updateModulePhases(@modules) unless $commandLineModules; @modules = _updateModulePhases(@modules) unless $commandLineModules;
# TODO: Verify this does anything still
my $metadataModule = $ctx->getKDEDependenciesMetadataModule();
$ctx->addToIgnoreList($metadataModule->scm()->ignoredModules());
# Remove modules that are explicitly blanked out in their branch-group
# i.e. those modules where they *have* a branch-group, and it's set to
# be empty ("").
my $resolver = $ctx->moduleBranchGroupResolver();
my $branchGroup = $ctx->effectiveBranchGroup();
@modules = grep {
my $branch = $_->isKDEProject()
? $resolver->findModuleBranch($_->fullProjectPath(), $branchGroup)
: 1; # Just a placeholder truthy value
whisper ("Removing ", $_->fullProjectPath(), " due to branch-group") if (defined $branch and !$branch);
(!defined $branch or $branch); # This is the actual test
} (@modules);
@modules = $self->_resolveModuleDependencies(@modules);
# Filter --resume-foo options. This might be a second pass, but that should
# be OK since there's nothing different going on from the first pass (in
# resolveSelectorsIntoModules) in that event.
@modules = _applyModuleFilters($ctx, @modules);
# Check for ignored modules (post-expansion)
@modules = grep { ! exists $ignoredSelectors{$_->name()} } @modules;
return @modules; return @modules;
} }
@ -577,41 +604,9 @@ sub runAllModulePhases
{ {
my $self = shift; my $self = shift;
my $ctx = $self->context(); my $ctx = $self->context();
my $metadataModule = $ctx->getKDEDependenciesMetadataModule();
my @modules = $self->modules(); my @modules = $self->modules();
$ctx->addToIgnoreList($metadataModule->scm()->ignoredModules());
# Remove modules that are explicitly blanked out in their branch-group
# i.e. those modules where they *have* a branch-group, and it's set to
# be empty ("").
my $resolver = $ctx->moduleBranchGroupResolver();
my $branchGroup = $ctx->effectiveBranchGroup();
@modules = grep {
my $branch = $_->isKDEProject()
? $resolver->findModuleBranch($_->fullProjectPath(), $branchGroup)
: 1; # Just a placeholder truthy value
whisper ("Removing ", $_->fullProjectPath(), " due to branch-group") if (defined $branch and !$branch);
(!defined $branch or $branch); # This is the actual test
} (@modules);
@modules = $self->_resolveModuleDependencies(@modules);
# Filter --resume-foo options. This might be a second pass, but that should
# be OK since there's nothing different going on from the first pass (in
# resolveSelectorsIntoModules) in that event.
@modules = _applyModuleFilters($ctx, @modules);
# Remove any ignored modules that crept back in as a dependency
do { # new scope
my %ignoredSelectors;
@ignoredSelectors{@{$self->{ignored_selectors}}} = undef;
@modules = grep { ! exists $ignoredSelectors{$_->name()} } @modules;
};
if ($ctx->getOption('print-modules')) { if ($ctx->getOption('print-modules')) {
info (" * Module list", $metadataModule ? " in dependency order" : '');
for my $m (@modules) { for my $m (@modules) {
say ((" " x ($m->getOption('#dependency-level', 'module') // 0)), "$m"); say ((" " x ($m->getOption('#dependency-level', 'module') // 0)), "$m");
} }

@ -0,0 +1,51 @@
use 5.014;
use strict;
use warnings;
# Verify that --ignore-modules works for modules that would be included with
# --include-dependencies in effect.
# See bug 394497 -- https://bugs.kde.org/show_bug.cgi?id=394497
use Test::More;
use ksb::Application;
use ksb::Module;
# Redefine ksb::Application::_resolveModuleDependencies to avoid requiring metadata
# module.
package ksb::Application {
no warnings 'redefine';
sub _resolveModuleDependencies {
my ($self, @modules) = @_;
# simulate effect of --include-dependencies, using ksb::Application's
# built-in module-name to ksb::Module resolver.
my $newModule = $self->{module_factory}->('setmod2');
splice @modules, 1, 0, $newModule;
return @modules;
}
};
my @args = qw(--pretend --rc-file t/data/sample-rc/kdesrc-buildrc --include-dependencies setmod1 setmod3);
{
my $app = ksb::Application->new(@args);
my @moduleList = @{$app->{modules}};
is (scalar @moduleList, 3, 'Right number of modules (include-dependencies)');
is ($moduleList[0]->name(), 'setmod1', 'mod list[0] == setmod1');
is ($moduleList[1]->name(), 'setmod2', 'mod list[1] == setmod2');
is ($moduleList[2]->name(), 'setmod3', 'mod list[2] == setmod3');
}
{
push @args, '--ignore-modules', 'setmod2';
my $app = ksb::Application->new(@args);
my @moduleList = @{$app->{modules}};
is (scalar @moduleList, 2, 'Right number of modules (include-dependencies+ignore-modules)');
is ($moduleList[0]->name(), 'setmod1', 'mod list[0] == setmod1');
is ($moduleList[1]->name(), 'setmod3', 'mod list[1] == setmod3');
}
done_testing();
Loading…
Cancel
Save