]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
cs-adjust-flight: Add jobs-rename command which applies a perlop to job names
authorIan Campbell <ian.campbell@citrix.com>
Tue, 19 Jan 2016 12:47:49 +0000 (12:47 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 20 Jan 2016 16:42:59 +0000 (16:42 +0000)
My intention was to allow creation of adhoc jobs based on a template
but modified e.g. to enable/disable XSM with a sequence something
like:

./cs-adjust-flight $flight copy-jobs $template test-foo-xsm
./cs-adjust-flight $flight jobs-rename test-foo-xsm 's/-xsm$//'
./cs-adjust-flight $flight runvar-set $job enable_xsm false
./cs-adjust-flight ... update %buildjob

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
cs-adjust-flight

index a72cd8846cb37b159aa52c4a146bc3018513703c..04f5a7eaf2b751c56678ca706b83446a881ad631 100755 (executable)
@@ -18,6 +18,7 @@
 #   intended-blessing <intended-blessing>
 #   branch-set <new-branch>
 #   job-status <job-spec>
+#   jobs-rename <job-spec> <perl-expr>
 #
 # <foo-spec>:
 #   <foo-name>
@@ -371,6 +372,29 @@ END
     });
 }
 
+sub change__jobs_rename {
+    die unless @changes >= 2;
+    my $jobs = shift @changes;
+    my $perlop = shift @changes;
+
+    my $jobq = $dbh_tests->prepare(<<END);
+    UPDATE jobs
+       SET job = ?
+     WHERE flight = ? AND job = ?
+END
+    my $runvarq = $dbh_tests->prepare(<<END);
+    UPDATE runvars
+       SET job = ?
+     WHERE flight = ? AND job = ?
+END
+    for_jobs($dstflight, $jobs, sub {
+       my ($oldjob) = @_;
+       my $newjob = perlop_value ($oldjob, '', $perlop, $oldjob);
+       print "$oldjob renamed to $newjob\n";
+       $jobq->execute($newjob, $dstflight, $oldjob);
+       $runvarq->execute($newjob, $dstflight, $oldjob);
+    })
+}
 sub changes () {
     debug("CHANGES...\n");