Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hydra-queue-runner/build-result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ BuildOutput getBuildOutput(
for (auto & line : tokenizeString<Strings>(file->second.contents.value(), "\n")) {
auto fields = tokenizeString<std::vector<std::string>>(line);
if (fields.size() < 2) continue;
if (!std::regex_match(fields[0], std::regex("[a-zA-Z0-9._-]+")))
if (!std::regex_match(fields[0], std::regex(R"([a-zA-Z0-9._%\-\[\]:]+)")))
continue;
BuildMetric metric;
metric.name = fields[0];
Expand Down
10 changes: 9 additions & 1 deletion t/Hydra/Plugin/RunCommand/json.t
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ subtest "Validate the outputs match" => sub {
};

subtest "Validate the metrics match" => sub {
is(scalar(@{$dat->{metrics}}), 2, "There are exactly two metrics");
is(scalar(@{$dat->{metrics}}), 3, "There are exactly three metrics");

my ($lineCoverage) = grep { $_->{name} eq "lineCoverage" } @{$dat->{metrics}};
my ($maxResident) = grep { $_->{name} eq "maxResident" } @{$dat->{metrics}};
my ($test_foo_py) = grep { $_->{name} eq "test_foo.py::best_bar[1]" } @{$dat->{metrics}};


subtest "verifying the lineCoverage metric" => sub {
is($lineCoverage->{name}, "lineCoverage", "The name matches.");
Expand All @@ -96,6 +98,12 @@ subtest "Validate the metrics match" => sub {
is($maxResident->{value}, 27, "The value matches.");
is($maxResident->{unit}, "KiB", "The unit matches.");
};

subtest "verifying the test_foo_py metric" => sub {
is($test_foo_py->{name}, "test_foo.py::best_bar[1]", "The name matches.");
is($test_foo_py->{value}, 3.1, "The value matches.");
is($test_foo_py->{unit}, "s", "The unit matches.");
};
};

subtest "Validate the products match" => sub {
Expand Down
1 change: 1 addition & 0 deletions t/jobs/runcommand.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ with import ./config.nix;
mkdir -p "$(dirname "$metrics")"
echo "lineCoverage 18 %" >> "$metrics"
echo "maxResident 27 KiB" >> "$metrics"
echo "test_foo.py::best_bar[1] 3.1 s" >> "$metrics"
''
)
];
Expand Down