die unless @ARGV==1 && $ARGV[0] =~ m/^\w+$/;
-
our @cols = qw(job name val);
our @rows;
+our %jobs;
+
+sub collect ($;$@) {
+ my ($flight,$jobcond,@jobcondparams) = @_;
-sub collect ($) {
- my ($flight) = @_;
+ $jobcond //= "TRUE";
$flight =~ m/^\d+/ or $flight = "'$flight'";
- my $qfrom = "FROM runvars WHERE flight=$flight AND $synthcond";
+ my $qfrom = "FROM runvars WHERE flight=$flight AND $synthcond AND $jobcond";
my $q = $dbh_tests->prepare
- ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY synth, name, job");
- $q->execute();
+ ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY name, job");
+ $q->execute(@jobcondparams);
while (my (@row) = $q->fetchrow_array()) {
my $synth = shift @row;
collect($ARGV[0]);
+if ($recurse) {
+ # collect() appends to @rows, avoiding the need to recurse
+ # there. However this means we can't use foreach (since that is
+ # not guaranteed to work if the array is mutated under its feet),
+ # instead use an index.
+ for ( my $rowidx = 0; $rowidx < @rows ; $rowidx++ ) {
+ my $row = $rows[$rowidx];
+
+ next unless $row->[1] =~ m/^(?:.*_)?([^_]*)buildjob$/;
+
+ # parse this flight and job, which must be in $flight.$job
+ # form if $recurse is true (see collect())
+ my ($tflight, $tjob) = flight_otherjob(undef, $row->[0]);
+ die "$row->[1]" unless $tflight;
+
+ # parse the buildjob reference and recurse. might be a job in
+ # this flight, in which case we still recurse since it might
+ # be a chain from a non-top-level job which hasn't been
+ # included yet. %jobs will prevent us from duplicating or
+ # infinite loops.
+ my ($oflight, $ojob) = flight_otherjob($tflight, $row->[2]);
+
+ next if $jobs{$oflight,$ojob}++;
+
+ collect($oflight, "job = ?", $ojob);
+ }
+}
+
our @colws;
sub max ($$) { $_[$_[0] < $_[1]] }
foreach my $row (@rows) {
}
$colws[1] += length $synthsufx;
-foreach my $row (@rows) {
+# Sort by runvar name, then (flight+)job, synth runvars come last.
+foreach my $row (map { $_->[0] }
+ sort { $a->[1] cmp $b->[1] }
+ map { [ $_, ($_->[1] =~ m/~$/)." $_->[1] $_->[0]" ] }
+ @rows) {
printf "%-*s %-*s %-*s\n", map { $colws[$_], $row->[$_] } qw(0 1 2)
or die $!;
}