Add test to verify includes work
This commit is contained in:
parent
503b0e0b6f
commit
ba557972c7
26
t/Config/include.t
Normal file
26
t/Config/include.t
Normal file
|
@ -0,0 +1,26 @@
|
|||
use strict;
|
||||
use Setup;
|
||||
|
||||
my %ctx = test_init(
|
||||
use_external_destination_store => 0,
|
||||
hydra_config => "include foo.conf"
|
||||
);
|
||||
|
||||
write_file($ctx{'tmpdir'} . "/foo.conf", q|
|
||||
<foo>
|
||||
include bar.conf
|
||||
</foo>
|
||||
|);
|
||||
|
||||
write_file($ctx{'tmpdir'} . "/bar.conf", q|
|
||||
bar = baz
|
||||
|);
|
||||
|
||||
require Hydra::Helper::Nix;
|
||||
use Test2::V0;
|
||||
|
||||
is(Hydra::Helper::Nix::getHydraConfig(), {
|
||||
foo => { bar => "baz" }
|
||||
}, "Nested includes work.");
|
||||
|
||||
done_testing;
|
|
@ -9,7 +9,7 @@ use File::Basename;
|
|||
use Cwd qw(abs_path getcwd);
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(test_init hydra_setup nrBuildsForJobset queuedBuildsForJobset
|
||||
our @EXPORT = qw(test_init hydra_setup write_file nrBuildsForJobset queuedBuildsForJobset
|
||||
nrQueuedBuildsForJobset createBaseJobset createJobsetWithOneInput
|
||||
evalSucceeds runBuild sendNotifications updateRepository
|
||||
captureStdoutStderr);
|
||||
|
@ -49,19 +49,16 @@ sub test_init {
|
|||
$ENV{'NIX_CONF_DIR'} = "$dir/nix/etc/nix";
|
||||
make_path($ENV{'NIX_CONF_DIR'});
|
||||
my $nixconf = "$ENV{'NIX_CONF_DIR'}/nix.conf";
|
||||
open(my $fh, '>', $nixconf) or die "Could not open file '$nixconf' $!";
|
||||
print $fh "sandbox = false\n";
|
||||
print $fh $opts{'nix_config'} || "";
|
||||
close $fh;
|
||||
|
||||
my $nix_config = "sandbox = false\n" . $opts{'nix_config'};
|
||||
write_file($nixconf, $nix_config);
|
||||
$ENV{'HYDRA_CONFIG'} = "$dir/hydra.conf";
|
||||
|
||||
open(my $fh, '>', $ENV{'HYDRA_CONFIG'}) or die "Could not open file '" . $ENV{'HYDRA_CONFIG'}. " $!";
|
||||
my $hydra_config = $opts{'hydra_config'} || "";
|
||||
if ($opts{'use_external_destination_store'} // 1) {
|
||||
print $fh "store_uri = file:$dir/nix/dest-store\n"
|
||||
$hydra_config = "store_uri = file:$dir/nix/dest-store\n" . $hydra_config;
|
||||
}
|
||||
print $fh $opts{'hydra_config'} || "";
|
||||
close $fh;
|
||||
|
||||
write_file($ENV{'HYDRA_CONFIG'}, $hydra_config);
|
||||
|
||||
$ENV{'NIX_LOG_DIR'} = "$dir/nix/var/log/nix";
|
||||
$ENV{'NIX_REMOTE_SYSTEMS'} = '';
|
||||
|
@ -82,6 +79,13 @@ sub test_init {
|
|||
);
|
||||
}
|
||||
|
||||
sub write_file {
|
||||
my ($path, $text) = @_;
|
||||
open(my $fh, '>', $path) or die "Could not open file '$path' $!";
|
||||
print $fh $text || "";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
sub captureStdoutStderr {
|
||||
# "Lazy"-load Hydra::Helper::Nix to avoid the compile-time
|
||||
# import of Hydra::Model::DB. Early loading of the DB class
|
||||
|
|
Loading…
Reference in a new issue