diff --git a/src/hydra-queue-runner/build-result.cc b/src/hydra-queue-runner/build-result.cc index aa98acbb5..e4ff3bf77 100644 --- a/src/hydra-queue-runner/build-result.cc +++ b/src/hydra-queue-runner/build-result.cc @@ -143,7 +143,7 @@ BuildOutput getBuildOutput( for (auto & line : tokenizeString(file->second.contents.value(), "\n")) { auto fields = tokenizeString>(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]; diff --git a/t/Hydra/Plugin/RunCommand/json.t b/t/Hydra/Plugin/RunCommand/json.t index 7bd8484d3..ac21d5404 100644 --- a/t/Hydra/Plugin/RunCommand/json.t +++ b/t/Hydra/Plugin/RunCommand/json.t @@ -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."); @@ -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 { diff --git a/t/jobs/runcommand.nix b/t/jobs/runcommand.nix index f4b8b0fc7..1c5eaac4e 100644 --- a/t/jobs/runcommand.nix +++ b/t/jobs/runcommand.nix @@ -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" '' ) ];