Fake a JSON module to make --pretend work without kde-build-metadata.

This is mostly to make the testsuite run, which is not supposed to pull
down kde-build-metadata, though it may be worth it to construct a
suitable "fake metadata" instead.
wilder^2
Michael Pyne 8 years ago
parent ca30f09b51
commit 14b5093bf1
  1. 5
      modules/ksb/Updater/KDEProjectMetadata.pm
  2. 5
      modules/ksb/Util.pm

@ -49,7 +49,8 @@ sub logicalModuleGroups
my $self = shift;
my $path = $self->module()->fullpath('source') . "/logical-module-structure";
my $fh = pretend_open($path) or
# The {} is an empty JSON obj to support pretend mode
my $fh = pretend_open($path, '{}') or
croak_internal("Unable to read logical module structure: $!");
my ($json_hashref, $e) = do {
@ -61,7 +62,7 @@ sub logicalModuleGroups
($json, $@); # Implicit return
};
croak_runtime ("Unable to load module group data! :(\n\t$e") if $e;
croak_runtime ("Unable to load module group data from $path! :(\n\t$e") if $e;
return $json_hashref;
}

@ -628,6 +628,7 @@ sub download_file
#
# Parameters:
# filename - Path to the file to open.
# default - String to use if the file doesn't exist in pretend mode
#
# Returns:
# filehandle on success (supports readline() and eof()), can return boolean
@ -636,11 +637,11 @@ sub download_file
sub pretend_open
{
my $path = shift;
my $defaultText = shift // '';
my $fh;
if (pretending() && ! -e $path) {
my $simulatedFile = '';
open $fh, '<', \$simulatedFile or return;
open $fh, '<', \$defaultText or return;
}
else {
open $fh, '<', $path or return;

Loading…
Cancel
Save