summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-18 18:37:52 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-18 18:37:52 +0000
commit49ef9b1e49a0f2b53a97afbacb0bed0f20b1fab1 (patch)
treec2c077397a917963390db8629e04411e66e21d17
parent3335f9936fa1aa700ca634e32c3178743bcb2f74 (diff)
Added --fail flag.
-rwxr-xr-xbin/custodian-dequeue16
-rw-r--r--lib/custodian.rb16
2 files changed, 31 insertions, 1 deletions
diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue
index 85bc6f3..dd5daa6 100755
--- a/bin/custodian-dequeue
+++ b/bin/custodian-dequeue
@@ -6,6 +6,7 @@
# SYNOPSIS
# custodian-dequeue [ -h | --help ]
# [ -m | --manual]
+# [ -f | --fail ]
# [ -l | --logfile FILE]
# [ -S | --server 1.2.3.4:123 ]
# [ -s | --single ]
@@ -23,6 +24,8 @@
#
# -s, --single Run a single test and exit. Don't poll the queue for more.
#
+# -f, --fail Run tests but stop the first time we see a fail.
+#
# -v, --verbose Be noisy.
#
#
@@ -72,6 +75,7 @@ if __FILE__ == $0 then
opts = GetoptLong.new(
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
[ "--manual", "-m", GetoptLong::NO_ARGUMENT ],
+ [ "--fail", "-f", GetoptLong::NO_ARGUMENT ],
[ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
[ "--repeat", "-r", GetoptLong::REQUIRED_ARGUMENT ],
[ "--server", "-S", GetoptLong::REQUIRED_ARGUMENT ],
@@ -90,6 +94,8 @@ if __FILE__ == $0 then
$SERVER = arg
when "--single":
ENV["SINGLE"] = "1"
+ when "--fail":
+ ENV["FAIL"] = "1"
when "--help":
$help = true
when "--manual":
@@ -142,7 +148,15 @@ if __FILE__ == $0 then
# Single step?
#
if ( ENV['SINGLE'] )
- worker.process_single_job
+ worker.process_single_job()
+ exit(0)
+ end
+
+ #
+ # Run until we see a failure?
+ #
+ if ( ENV['FAIL'] )
+ worker.process_until_fail()
exit(0)
end
diff --git a/lib/custodian.rb b/lib/custodian.rb
index 6c0ec81..fec928b 100644
--- a/lib/custodian.rb
+++ b/lib/custodian.rb
@@ -104,6 +104,8 @@ class Custodian
#
def process_single_job
+ result = false
+
begin
job = @queue.reserve()
@@ -200,6 +202,7 @@ class Custodian
log_message( "Test succeeed - clearing alert" )
success = true
alert.clear()
+ result = true
end
count += 1
end
@@ -228,7 +231,20 @@ class Custodian
log_message( "Job ID : #{job.id} - Removed" )
job.delete if ( job )
end
+
+ return result
end
+
+
+ #
+ # Process jobs until we see a failure - stop then.
+ #
+ def process_until_fail
+ while( process_single_job() )
+ # nop
+ end
+ end
+
end