From a8db32983969b9b1f11a3bedb2bb8cd2d04a9465 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 25 Sep 2013 15:30:59 +0200 Subject: [PATCH] Warn against multiple jobs with the same name --- src/lib/Hydra/Helper/AddBuilds.pm | 11 ++++++++++- src/script/hydra-evaluator | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index 0d51b9fb..32dea879 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -282,7 +282,16 @@ sub evalJobs { SuppressEmpty => '') or die "cannot parse XML output"; - return ($jobs, $nixExprInput); + my %jobNames; + my $errors; + foreach my $job (@{$jobs->{job}}) { + $jobNames{$job->{jobName}}++; + if ($jobNames{$job->{jobName}} == 2) { + $errors .= "warning: there are multiple jobs named ‘$job->{jobName}’; support for this will go away soon!\n\n"; + } + } + + return ($jobs, $nixExprInput, $errors); } diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator index 646407a2..52192c74 100755 --- a/src/script/hydra-evaluator +++ b/src/script/hydra-evaluator @@ -133,7 +133,7 @@ sub checkJobsetWrapped { # Evaluate the job expression. my $evalStart = time; - my ($jobs, $nixExprInput) = evalJobs($inputInfo, $exprType, $jobset->nixexprinput, $jobset->nixexprpath); + my ($jobs, $nixExprInput, $msg) = evalJobs($inputInfo, $exprType, $jobset->nixexprinput, $jobset->nixexprpath); my $evalStop = time; my $jobOutPathMap = {}; @@ -238,7 +238,6 @@ sub checkJobsetWrapped { }); # Store the error messages for jobs that failed to evaluate. - my $msg = ""; foreach my $error (@{$jobs->{error}}) { my $bindings = ""; foreach my $arg (@{$error->{arg}}) {