When tests are run for a subsection defined in a config file, it is
better if the results for the current subsection are not overwritting
the results of a previous subsection.

So let's store the results for a subsection in a subdirectory of
"test-results/" with the subsection name.

The aggregate.perl, when it is run for a subsection, should then
aggregate the results found in "test-results/$GIT_PERF_SUBSECTION/".

Signed-off-by: Christian Couder <chrisc...@tuxfamily.org>
---
 t/perf/aggregate.perl | 11 ++++++++---
 t/perf/perf-lib.sh    |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 1dbc85b21407d..e40120848837c 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -69,12 +69,17 @@ sub format_times {
        @tests = glob "p????-*.sh";
 }
 
+my $resultsdir = "test-results";
+if ($ENV{GIT_PERF_SUBSECTION} ne "") {
+       $resultsdir .= "/" . $ENV{GIT_PERF_SUBSECTION};
+}
+
 my @subtests;
 my %shorttests;
 for my $t (@tests) {
        $t =~ s{(?:.*/)?(p(\d+)-[^/]+)\.sh$}{$1} or die "bad test name: $t";
        my $n = $2;
-       my $fname = "test-results/$t.subtests";
+       my $fname = "$resultsdir/$t.subtests";
        open my $fp, "<", $fname or die "cannot open $fname: $!";
        for (<$fp>) {
                chomp;
@@ -98,7 +103,7 @@ sub read_descr {
 my %descrs;
 my $descrlen = 4; # "Test"
 for my $t (@subtests) {
-       $descrs{$t} = $shorttests{$t}.": ".read_descr("test-results/$t.descr");
+       $descrs{$t} = $shorttests{$t}.": ".read_descr("$resultsdir/$t.descr");
        $descrlen = length $descrs{$t} if length $descrs{$t}>$descrlen;
 }
 
@@ -138,7 +143,7 @@ sub have_slash {
        my $firstr;
        for my $i (0..$#dirs) {
                my $d = $dirs[$i];
-               $times{$prefixes{$d}.$t} = 
[get_times("test-results/$prefixes{$d}$t.times")];
+               $times{$prefixes{$d}.$t} = 
[get_times("$resultsdir/$prefixes{$d}$t.times")];
                my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}};
                my $w = length format_times($r,$u,$s,$firstr);
                $colwidth[$i] = $w if $w > $colwidth[$i];
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 2f88fc12a9b5c..e4c343a6b795b 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -56,6 +56,7 @@ MODERN_GIT=$GIT_BUILD_DIR/bin-wrappers/git
 export MODERN_GIT
 
 perf_results_dir=$TEST_OUTPUT_DIRECTORY/test-results
+test -n "$GIT_PERF_SUBSECTION" && 
perf_results_dir="$perf_results_dir/$GIT_PERF_SUBSECTION"
 mkdir -p "$perf_results_dir"
 rm -f "$perf_results_dir"/$(basename "$0" .sh).subtests
 

--
https://github.com/git/git/pull/408

Reply via email to