diff options
Diffstat (limited to 'bin/custodian-dequeue')
-rwxr-xr-x | bin/custodian-dequeue | 153 |
1 files changed, 62 insertions, 91 deletions
diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue index d49049e..bc84adf 100755 --- a/bin/custodian-dequeue +++ b/bin/custodian-dequeue @@ -1,66 +1,20 @@ -#!/usr/bin/ruby -Ilib/ -I../lib/ -rubygems -# -# NAME -# custodian-dequeue - Pull network tests from a queue and execute them in series. -# -# SYNOPSIS -# custodian-dequeue [ -h | --help ] -# [ -m | --manual] -# [ -f | --fail ] -# [ -s | --single ] -# [ -v | --verbose ] -# -# OPTIONS -# -# -h, --help Show a help message, and exit. -# -# -m, --manual Show this manual, and exit. -# -# -s, --single Run a single test and exit. -# -# -f, --fail Stop running once a single test fails. -# -# -v, --verbose Be noisy. -# -# -# ABOUT -# -# This tool is designed to pull network/protocol-tests from the central queue -# and execute them one by one. -# -# The results of the testing will be sent to a notifier, where they can later -# be acted upon. +#!/usr/bin/ruby -rubygems # +# Usage information at the end of the script. # -# AUTHOR -# -# Steve Kemp <steve@bytemark.co.uk> -# - -# -# Standard modules -# require 'getoptlong' - - -# -# Our code. -# require 'custodian/settings' require 'custodian/queue' require 'custodian/worker' - - - # # Entry-point to our code. # -if __FILE__ == $PROGRAM_NAME then +if __FILE__ == $PROGRAM_NAME - $help = false - $manual = false + help = false + manual = false # # The settings object contains a lot of configuration-data. @@ -69,24 +23,24 @@ if __FILE__ == $PROGRAM_NAME then begin opts = GetoptLong.new( - ['--help', '-h', GetoptLong::NO_ARGUMENT], - ['--manual', '-m', GetoptLong::NO_ARGUMENT], - ['--fail', '-f', GetoptLong::NO_ARGUMENT], - ['--single', '-s', GetoptLong::NO_ARGUMENT], - ['--verbose', '-v', GetoptLong::NO_ARGUMENT] + ['--help', '-h', GetoptLong::NO_ARGUMENT], + ['--manual', '-m', GetoptLong::NO_ARGUMENT], + ['--fail', '-f', GetoptLong::NO_ARGUMENT], + ['--single', '-s', GetoptLong::NO_ARGUMENT], + ['--verbose', '-v', GetoptLong::NO_ARGUMENT] ) - opts.each do |opt, arg| + opts.each do |opt, _arg| case opt when '--verbose' then - ENV['VERBOSE'] = '1' + ENV['VERBOSE'] = '1' when '--single' then - ENV['SINGLE'] = '1' + ENV['SINGLE'] = '1' when '--fail' then - ENV['FAIL'] = '1' + ENV['FAIL'] = '1' when '--help' then - $help = true + help = true when '--manual' then - $manual = true + manual = true end end rescue StandardError => ex @@ -94,49 +48,26 @@ if __FILE__ == $PROGRAM_NAME then exit end - - # - # CAUTION! Here be quality kode. + # Show the help information. # - if $manual or $help - - # Open the file, stripping the shebang line - lines = File.open(__FILE__){|fh| fh.readlines}[1..-1] - - found_synopsis = false - - lines.each do |line| - - line.chomp! - break if line.empty? - - if $help and !found_synopsis - found_synopsis = (line =~ /^#\s+SYNOPSIS\s*$/) - next - end - - puts line[2..-1].to_s - - break if $help and found_synopsis and line =~ /^#\s*$/ - + if manual || help + DATA.read.split("\n").each do |line| + puts Regexp.last_match(1).dup if line =~ /^# ?(.*)/ end - exit 0 end - # # Create the worker, passing it the settings object so it can # sort out its own logfile, etc. # worker = Custodian::Worker.new(settings) - # # Single step? # - if ENV['SINGLE'] + if ENV['SINGLE'] worker.process_single_job exit(0) end @@ -144,7 +75,7 @@ if __FILE__ == $PROGRAM_NAME then # # Run until we see a failure? # - if ENV['FAIL'] + if ENV['FAIL'] worker.process_until_fail exit(0) end @@ -155,3 +86,43 @@ if __FILE__ == $PROGRAM_NAME then worker.run! end + + +__END__ +# +# NAME +# custodian-dequeue - Execute network tests from the central queue. +# +# SYNOPSIS +# custodian-dequeue [ -h | --help ] +# [ -m | --manual] +# [ -f | --fail ] +# [ -s | --single ] +# [ -v | --verbose ] +# +# OPTIONS +# +# -h, --help Show a help message, and exit. +# +# -m, --manual Show this manual, and exit. +# +# -s, --single Run a single test and exit. +# +# -f, --fail Stop running once a single test fails. +# +# -v, --verbose Be noisy. +# +# +# ABOUT +# +# This tool is designed to pull network/protocol-tests from the central queue +# and execute them one by one. +# +# The results of the testing will be sent to a notifier, where they can later +# be acted upon. +# +# +# AUTHOR +# +# Steve Kemp <steve@bytemark.co.uk> +# |