Commit 1b9db4e0 authored by Michael Pyne's avatar Michael Pyne
Browse files

tests: Update test suite for fix-recursing commit.

Unfortunately there are now 4 tests expected to fail, though it is a
known bug with module overriding.
parent 5d638aca
......@@ -14,7 +14,6 @@ use warnings;
use 5.010;
use Getopt::Long;
use Scalar::Util qw(blessed);
use Storable qw(freeze);
use FindBin qw($RealBin $Bin);
# Control whether we actually try to svn checkouts, possibly more later.
......@@ -43,9 +42,22 @@ use ksb::BuildContext;
use ksb::Module;
use ksb::l10nSystem;
# is_deeply does not work under blessed references i.e. it will not verify
# the contents of blessed array references are actually equal, which causes
# some tests to spuriously pass in my experience :(
# Instead we compare the canonical in-memory representations of data structures
# which should have identical contents. This means we should use ok() instead
# of is() since we don't want the expected value dumped to tty.
$Storable::canonical = 1;
# From kdesrc-build
our %ENV_VARS;
# List util functions from List::Util
sub all { $_ || return 0 for @_; 1 }
sub none { $_ && return 0 for @_; 1 }
sub notall { $_ || return 1 for @_; 0 }
# Base directory name to use for any needed filesystem tests.
my $testSourceDirName =
tempdir('kdesrc-build-test-XXXXXX',
......@@ -133,17 +145,21 @@ $ctx->setOption('source-dir', $testSourceDirName);
SKIP: {
skip 'No XML testing', 1 unless $fullRun;
my $fh = ensure_projects_xml_present($ctx);
ok($fh, 'Valid filehandle from ensure_projects_xml_present');
my $fh = $ctx->getKDEProjectMetadataFilehandle();
isa_ok($fh, 'IO::File');
my $metadataModuleSet = ksb::Module->new($ctx, 'kde-build-metadata');
isa_ok($metadataModuleSet, 'ksb::Module');
$metadataModuleSet->setScmType('proj');
my $moduleSet = ksb::ModuleSet::KDEProjects->new($ctx, '<autotest :)>');
$moduleSet->setModulesToFind('kdesrc-build');
my @buildMetadataModule = expandXMLModules($ctx, $metadataModuleSet);
my $metadataModule = shift @buildMetadataModule;
is($metadataModule->scmType(), 'metadata', 'expandXMLModules adds kde-build-metadata');
my ($metadataModule, @modules) = expandModuleSets($ctx, $moduleSet);
isa_ok($metadataModule, 'ksb::Module');
isnt ($metadataModule->moduleSet(), $moduleSet, 'kde-build-metadata has autogenerated module-set');
isa_ok($metadataModule->moduleSet(), 'ksb::ModuleSet::KDEProjects');
is ($modules[0]->name(), 'kdesrc-build', 'Found module had right name');
is ($modules[0]->moduleSet(), $moduleSet, 'Found module inherited correct module set');
is ($modules[0]->getOption('#xml-full-path', 'module'), 'extragear/utils/kdesrc-build', 'XML Reader found right full path');
is($metadataModule->scmType(), 'metadata', 'expandModuleSet adds kde-build-metadata');
$metadataModule->scm()->updateInternal();
}
......@@ -322,14 +338,21 @@ my $resetContext = sub {
$kdelibsModule->setOption('no-build', 1);
my $backupModuleCopy = dclone(\@Modules);
updateModulePhases(@Modules);
is_deeply(\@Modules, $backupModuleCopy, 'Ensure objects not modified through references to them');
$kdelibsModule->deleteOption('no-build');
# Now test --no-src/--no-build/etc.
is_deeply([process_arguments($ctx, {}, @modules)], \@Modules, 'testing process_arguments return value for passed module names');
is_deeply(
[map { $_->name() } process_arguments($ctx, {}, @modules)],
\@modules,
'testing process_arguments return value for passed module names');
$_->phases()->filterOutPhase('update') foreach @Modules;
is_deeply([process_arguments($ctx, {}, @modules, '--no-src')], \@Modules, 'testing --no-src phase updating');
my @args = process_arguments($ctx, {}, @modules, '--no-src');
is_deeply(
[map { $_->phases()->phases() } @args ],
[map { $_->phases()->phases() } @Modules],
'testing --no-src phase updating');
ok(!list_has([$ctx->phases()->phases()], 'update'), 'Build context also not updating');
&$resetContext();
......@@ -338,45 +361,38 @@ ok(!list_has([$ctx->phases()->phases()], 'update'), 'Build context also not upda
# build (in updateModulesPhases) because of the global '#no-src' being set in
# process_arguments.
my @temp_modules = process_arguments($ctx, {}, @modules, '--no-src');
# There should be no module-specific no-src/no-build/manual-update/etc. set.
is_deeply([updateModulePhases(@temp_modules)], \@temp_modules, 'updateModulePhases only for modules');
is($ctx->getOption('no-src'), '', 'Ensure --no-src does not also set #no-src flag');
&$resetContext();
$kdelibsModule->setOption('run-tests', 1);
my $newModules = dclone(\@Modules);
# is_deeply does not work under blessed references i.e. it will not verify
# the contents of blessed array references are actually equal, which causes
# some tests to spuriously pass in my experience :(
# Instead we compare the canonical in-memory representations of data structures
# which should have identical contents. This means we should use ok() instead
# of is() since we don't want the expected value dumped to tty.
$Storable::canonical = 1;
is(freeze($newModules), freeze(\@Modules), 'identical objects are identical');
$newModules->[1]->phases()->addPhase('test'); # kdelibs
ok(freeze([updateModulePhases(@Modules)]) eq freeze($newModules), 'Make sure run-tests is recognized for a module');
updateModulePhases($Modules[1]);
ok(list_has([$Modules[1]->phases()->phases()], 'test'), 'Make sure run-tests is recognized for a module');
ok(!$kdebaseModule->getOption('run-tests'), 'run-tests not set for kdebase');
$newModules->[2]->phases()->addPhase('test'); # kdebase
ok(freeze([updateModulePhases(@Modules)]) ne freeze($newModules), 'Make sure run-tests is recognized only for its module');
updateModulePhases($Modules[2]);
ok(!list_has([$Modules[2]->phases()->phases()], 'test'), 'Make sure run-tests is recognized only for its module');
&$resetContext();
# Test only --no-build
$_->phases()->filterOutPhase('build') foreach @Modules;
ok(freeze([process_arguments($ctx, {}, @modules, '--no-build')])
eq freeze(\@Modules), 'testing --no-build phase updating');
ok(!list_has([$ctx->phases()->phases()], 'build'), 'Build context also not building');
@temp_modules = process_arguments($ctx, {}, @modules, '--no-build');
ok(none(map { $_->phases()->has('build') } @temp_modules), 'testing --no-build phase updating');
ok(!$ctx->phases()->has('build'), 'Build context also not building');
# Add on --no-src
$_->phases()->filterOutPhase('update') foreach @Modules;
ok(freeze([process_arguments($ctx, {}, @modules, '--no-build', '--no-src')])
eq freeze(\@Modules), 'testing --no-src and --no-build phase updating');
@temp_modules = process_arguments($ctx, {}, @modules, '--no-build', '--no-src');
ok(none( map {
$_->phases()->has('build') || $_->phases()->has('update')
} @temp_modules),
'testing --no-src and --no-build phase updating');
ok(!list_has([$ctx->phases()->phases()], 'build') &&
!list_has([$ctx->phases()->phases()], 'update'),
ok(!$ctx->phases()->has('build') && !$ctx->phases()->has('update'),
'Build context also not building or updating');
my $conf = <<EOF;
......@@ -399,6 +415,8 @@ module qt
repository kde:qt
end module
# This shouldn't actually show up as a module, but
# should override the prev. decl. in set1.
module kde-runtime
manual-build true
end module
......@@ -409,6 +427,54 @@ open my $fh, '<', \$conf;
# Read in new options
my @conf_modules = read_options($ctx, $fh);
ok($conf_modules[0]->isa('ksb::ModuleSet'), 'First read module-set IS-A module set');
ok($conf_modules[1]->isa('ksb::ModuleSet::KDEProjects'), 'First read kde-projects module-set IS-A kde-projects module-set');
ok($conf_modules[2]->isa('ksb::Module'), 'First read module IS-A module');
$ctx->setOption('resume-from', 'set1');
my @filtered_modules = applyModuleFilters($ctx, @conf_modules);
is_deeply(
[map { $_->name() } @filtered_modules[0..1]],
[qw/set1 qt/],
'resume-from a module-set');
is_deeply(
[map { $_->name() } @filtered_modules],
[qw/set1 qt/],
'resume-from a module-set, w/ option overrides');
$ctx->setOption('resume-after', 'set1');
# Setting both resume-from and resume-after should raise an exception.
$@ = '';
eval {
@filtered_modules = applyModuleFilters($ctx, @conf_modules);
};
isa_ok($@, 'BuildException', 'resume-{from,after} combine for exception');
$ctx->deleteOption('resume-from');
@filtered_modules = applyModuleFilters($ctx, @conf_modules);
is_deeply(
[map { $_->name() } @filtered_modules[0..0]],
[qw/qt/],
'resume-after a module-set');
is_deeply(
[map { $_->name() } @filtered_modules],
[qw/qt/],
'resume-after a module-set, w/ option overrides');
$ctx->deleteOption('resume-after');
# We re-bless conf_modules[1] to ensure it doesn't actually try to download
# the XML.
bless $conf_modules[1], 'ksb::ModuleSet';
$conf_modules[1]->{options}->{repository} = 'test';
my $metadataModule;
($metadataModule, @conf_modules) = expandModuleSets($ctx, @conf_modules);
is($metadataModule, undef, 'No metadata module return without kde-projects module sets');
# qt
is($conf_modules[3]->getOption('configure-flags'), '-fast', 'read_options/parse_module');
......@@ -418,46 +484,34 @@ is($conf_modules[0]->scmType(), 'git', 'Ensure repository gives git scm (part 1)
is($conf_modules[2]->getOption('manual-build'), 'true', 'manual-build for kde-projects submodule (Bug 288611)');
my @ConfModules = map { ksb::Module->new($ctx, $_) }(qw/kdelibs kdesrc-build kde-runtime qt/);
is($ConfModules[0]->scmType(), 'git', 'Ensure repository gives git scm (part 2)');
$ConfModules[0]->setModuleSet(''); # Unnamed module set, instead of undef
$ConfModules[1]->setModuleSet('set1');
$ConfModules[1]->setScmType('proj');
$ConfModules[2]->setModuleSet('set1');
$ConfModules[2]->setScmType('proj');
$ConfModules[2]->setOption('manual-build', 'true');
$ConfModules[3]->setOption('repository', 'kde:qt');
# This test must be performed to get the test after to pass, due to differences in each
# code path leading to one having build_obj still undef.
is($ConfModules[3]->buildSystemType(), $conf_modules[3]->buildSystemType(), 'Qt build systems load right.');
ok(freeze(\@conf_modules) eq freeze(\@ConfModules), 'read_options module reading');
is($conf_modules[3]->buildSystemType(), 'Qt', 'Qt build systems load right.');
# Test resume-from options
$ctx->setOption('resume-from', 'kdesrc-build');
my @filtered_modules = applyModuleFilters($ctx, @conf_modules);
is_deeply(\@filtered_modules, [@ConfModules[1..$#ConfModules]], 'resume-from under module-set');
$ctx->setOption('resume-from', 'kde-runtime');
@filtered_modules = applyModuleFilters($ctx, @conf_modules);
is_deeply(\@filtered_modules, [@ConfModules[2..$#ConfModules]], 'resume-from under module-set, not first module in set');
is_deeply(
[map { "$_" } @filtered_modules[0..2]],
[qw/kdesrc-build kde-runtime qt/],
'resume-from under module-set');
$ctx->setOption('resume-from', 'set1');
@filtered_modules = applyModuleFilters($ctx, @conf_modules);
is_deeply(\@filtered_modules, [@ConfModules[1..$#ConfModules]], 'resume-from a module-set');
$ctx->setOption('resume-after', 'set1');
# Setting both resume-from and resume-after should raise an exception.
$@ = '';
eval {
@filtered_modules = applyModuleFilters($ctx, @conf_modules);
};
isa_ok($@, 'BuildException', 'resume-{from,after} combine for exception');
is_deeply(
[map { "$_" } @filtered_modules],
[qw/kdesrc-build kde-runtime qt/],
'resume-from under module-set w/ option override');
$ctx->deleteOption('resume-from');
$ctx->setOption('resume-from', 'kde-runtime');
@filtered_modules = applyModuleFilters($ctx, @conf_modules);
is_deeply(\@filtered_modules, [@ConfModules[3..$#ConfModules]], 'resume-after a module-set');
is_deeply(
[map { "$_" } @filtered_modules[0..1]],
[qw/kde-runtime qt/],
'resume-from under module-set, not first module in set');
is_deeply(
[map { "$_" } @filtered_modules],
[qw/kde-runtime qt/],
'resume-from under module-set, not first module in set, w/ override');
# Test sub directory creation.
ok(! -d "$testSourceDirName/build", 'Ensure build dir does not exist');
......
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