diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 3b9ae480..62eb572c 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -156,7 +156,8 @@ void State::monitorMachinesFile() if (machinesFiles.empty()) { parseMachines("localhost " + (settings.thisSystem == "x86_64-linux" ? "x86_64-linux,i686-linux" : settings.thisSystem.get()) - + " - " + std::to_string(settings.maxBuildJobs) + " 1"); + + " - " + std::to_string(settings.maxBuildJobs) + " 1 " + + concatStringsSep(",", settings.systemFeatures.get())); return; } diff --git a/t/default-machine-file.t b/t/default-machine-file.t new file mode 100644 index 00000000..01203a72 --- /dev/null +++ b/t/default-machine-file.t @@ -0,0 +1,30 @@ +use feature 'unicode_strings'; +use strict; +use Setup; + +my %ctx = test_init(); + +require Hydra::Schema; +require Hydra::Model::DB; + +use Test2::V0; + +my $db = Hydra::Model::DB->new; +hydra_setup($db); + +my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"}); + +my $jobset = createBaseJobset("default-machine-file", "default-machine-file.nix", $ctx{jobsdir}); + +ok(evalSucceeds($jobset), "Evaluating jobs/default-machine-file.nix should exit with return code 0"); +is(nrQueuedBuildsForJobset($jobset), 1, "Evaluating jobs/default-machine-file.nix should result in 1 build"); + +for my $build (queuedBuildsForJobset($jobset)) { + ok(runBuild($build), "Build '".$build->job."' from jobs/default-machine-file.nix should exit with code 0"); + my $newbuild = $db->resultset('Builds')->find($build->id); + is($newbuild->finished, 1, "Build '".$build->job."' from jobs/default-machine-file.nix should be finished."); + my $expected = $build->job eq "fails" ? 1 : $build->job =~ /with_failed/ ? 6 : 0; + is($newbuild->buildstatus, $expected, "Build '".$build->job."' from jobs/default-machine-file.nix should have buildstatus $expected."); +} + +done_testing; diff --git a/t/jobs/default-machine-file.nix b/t/jobs/default-machine-file.nix new file mode 100644 index 00000000..49647cb0 --- /dev/null +++ b/t/jobs/default-machine-file.nix @@ -0,0 +1,9 @@ +with import ./config.nix; +{ + requireExperimentalFeatures = + mkDerivation { + name = "empty-dir"; + builder = ./empty-dir-builder.sh; + requiredSystemFeatures = [ "test-system-feature" ]; + }; +} diff --git a/t/lib/Setup.pm b/t/lib/Setup.pm index b5236978..fc078ac5 100644 --- a/t/lib/Setup.pm +++ b/t/lib/Setup.pm @@ -48,6 +48,7 @@ sub test_init { 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 "system-features = test-system-feature\n"; print $fh $opts{'nix_config'} || ""; close $fh;