Hydra::Helper::Nix::getMachines: add a test
[?]
Oct 24, 2021, 2:53 AM
QTZ6UUOMFFHMHEMZ2UKRHRZAITXO3WBCXAD3EGLRNKT52K7SANZACDependencies
- [2]
S2KNQCPBNixExprs: extract the `escape` function and test it - [3]
6MNLYIXOperlcritic: explicitly assign the result of readdir/file reads - [4]
HTL6HIBMmachine-status: Read /etc/nix.machines instead of using the BuildMachines table - [5]
L6PVAEWJperlcritic: don't open files as bare words - [6]
M4FPGVN4perlcritic: make all open() calls three-argument - [7]
O3NM62IZSupport multiple machines files - [*]
2GK5DOU7* Downloading closures.
Change contents
- replacement in src/lib/Hydra/Helper/Nix.pm at line 347
chomp;s/\#.*$//g;next if /^\s*$/;chomp($line);$line =~ s/\#.*$//g;next if $line =~ /^\s*$/; - edit in src/lib/Hydra/Helper/Nix.pm at line 351
if (!defined($tokens[5]) || $tokens[5] eq "-") {$tokens[5] = "";} - edit in src/lib/Hydra/Helper/Nix.pm at line 356
if (!defined($tokens[6]) || $tokens[6] eq "-") {$tokens[6] = "";} - file addition: Nix.t[2.981]
use strict;use warnings;use Setup;use File::Temp;my %ctx = test_init();require Hydra::Helper::Nix;use Test2::V0;my $dir = File::Temp->newdir();my $machines = "$dir/machines";$ENV{'NIX_REMOTE_SYSTEMS'} = $machines;open(my $fh, '>', $machines) or die "Could not open file '$machines' $!";print $fh q|# foobarroot@ip x86_64-darwin /sshkey 15 15 big-parallel,kvm,nixos-test - base64key# Macs# root@bar x86_64-darwin /sshkey 6 1 big-parallelroot@baz aarch64-darwin /sshkey 4 1 big-parallelroot@bux i686-linux,x86_64-linux /var/sshkey 1 1 kvm,nixos-test benchmark|;close $fh;is(Hydra::Helper::Nix::getMachines(), {'root@ip' => {'systemTypes' => ["x86_64-darwin"],'sshKeys' => '/sshkey','maxJobs' => 15,'speedFactor' => 15,'supportedFeatures' => ["big-parallel", "kvm", "nixos-test" ],'mandatoryFeatures' => [ ],},'root@baz' => {'systemTypes' => [ "aarch64-darwin" ],'sshKeys' => '/sshkey','maxJobs' => 4,'speedFactor' => 1,'supportedFeatures' => ["big-parallel"],'mandatoryFeatures' => [],},'root@bux' => {'systemTypes' => [ "i686-linux", "x86_64-linux" ],'sshKeys' => '/var/sshkey','maxJobs' => 1,'speedFactor' => 1,'supportedFeatures' => [ "kvm", "nixos-test", "benchmark" ],'mandatoryFeatures' => [ "benchmark" ],},}, ":)");done_testing;