2010-07-27 13:55:37 +00:00
|
|
|
#!/usr/bin/env ruby
|
2010-06-15 22:26:19 +00:00
|
|
|
|
2018-03-07 09:05:50 +00:00
|
|
|
require "digest/md5"
|
2015-12-29 15:35:15 +00:00
|
|
|
require "json"
|
2018-03-07 09:05:50 +00:00
|
|
|
require "json_schema"
|
2012-01-26 19:02:25 +00:00
|
|
|
require "pp"
|
2018-11-16 08:54:52 +00:00
|
|
|
require "rexml/document"
|
2012-03-26 07:28:42 +00:00
|
|
|
require "tempfile"
|
2011-12-03 14:07:24 +00:00
|
|
|
|
2012-01-26 19:02:25 +00:00
|
|
|
require_relative "test.d/controller.rb"
|
|
|
|
require_relative "test.d/results.rb"
|
|
|
|
require_relative "test.d/test.rb"
|
2012-01-27 18:29:02 +00:00
|
|
|
require_relative "test.d/simple_test.rb"
|
2012-01-26 19:02:25 +00:00
|
|
|
require_relative "test.d/util.rb"
|
2004-09-20 17:25:37 +00:00
|
|
|
|
2012-01-26 19:02:25 +00:00
|
|
|
begin
|
|
|
|
require "thread"
|
|
|
|
rescue
|
2004-08-19 14:05:56 +00:00
|
|
|
end
|
|
|
|
|
2012-01-26 19:02:25 +00:00
|
|
|
def setup
|
|
|
|
ENV[ /darwin/i.match(RUBY_PLATFORM) ? 'LANG' : 'LC_ALL' ] = 'en_US.UTF-8'
|
|
|
|
ENV['PATH'] = "../src:" + ENV['PATH']
|
2004-08-19 14:05:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def main
|
2012-01-26 19:02:25 +00:00
|
|
|
controller = Controller.new
|
2004-08-19 14:05:56 +00:00
|
|
|
|
|
|
|
ARGV.each do |arg|
|
|
|
|
if ((arg == "-f") or (arg == "--failed"))
|
2010-06-15 22:26:19 +00:00
|
|
|
controller.test_failed = true
|
2004-08-19 14:05:56 +00:00
|
|
|
elsif ((arg == "-n") or (arg == "--new"))
|
2010-06-15 22:26:19 +00:00
|
|
|
controller.test_new = true
|
2004-08-30 21:27:45 +00:00
|
|
|
elsif ((arg == "-u") or (arg == "--update-failed"))
|
2010-06-15 22:26:19 +00:00
|
|
|
controller.update_failed = true
|
2010-07-18 10:27:17 +00:00
|
|
|
elsif ((arg == "-r") or (arg == "--record-duration"))
|
|
|
|
controller.record_duration = true
|
2004-08-25 17:23:07 +00:00
|
|
|
elsif (arg =~ /-d([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})/)
|
2010-06-15 22:26:19 +00:00
|
|
|
controller.test_date_after = Time.local($1, $2, $3, $4, $5, $6)
|
2004-08-25 17:23:07 +00:00
|
|
|
elsif (arg =~ /-D([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})/)
|
2010-06-15 22:26:19 +00:00
|
|
|
controller.test_date_before = Time.local($1, $2, $3, $4, $5, $6)
|
2015-09-17 19:48:05 +00:00
|
|
|
elsif arg =~ /-j(\d+)/
|
|
|
|
controller.num_threads = $1.to_i
|
2011-10-21 18:12:04 +00:00
|
|
|
elsif /^ (\d{3}) (?: - (\d{3}) )?$/x.match arg
|
|
|
|
$1.to_i.upto(($2 || $1).to_i) { |idx| controller.add_test_case sprintf("%03d", idx) }
|
2015-09-17 19:48:05 +00:00
|
|
|
elsif %r{^ / (.+) / $}ix.match arg
|
2015-10-26 19:23:54 +00:00
|
|
|
re = Regexp.new "^T_(\\d+).*(?:#{$1})", Regexp::IGNORECASE
|
2015-10-03 20:26:44 +00:00
|
|
|
tests = controller.results.results.keys.collect { |e| re.match(e) ? $1 : nil }.compact
|
|
|
|
error_and_exit "No tests matched RE #{re}" if tests.empty?
|
|
|
|
tests.each { |e| controller.add_test_case e }
|
2016-05-13 17:46:12 +00:00
|
|
|
elsif ((arg == "-F" || (arg == "--list-failed")))
|
|
|
|
controller.list_failed_ids
|
|
|
|
exit 0
|
2015-09-17 19:48:05 +00:00
|
|
|
elsif ((arg == "-h") || (arg == "--help"))
|
|
|
|
puts <<EOHELP
|
|
|
|
Syntax: run.rb [options]
|
2016-05-13 17:46:12 +00:00
|
|
|
-F, --list-failed list IDs of failed tests
|
2015-09-17 19:48:05 +00:00
|
|
|
-f, --failed only run tests marked as failed
|
|
|
|
-n, --new only run tests for which no entry exists in results.txt
|
|
|
|
-dDATE only run tests added after DATE (YYYYMMDD-HHMM)
|
|
|
|
-DDATE only run tests added before DATE (YYYYMMDD-HHMM)
|
|
|
|
-u, --update-failed update the results for tests that fail
|
|
|
|
-r, --record-duration update the duration field of the tests run
|
|
|
|
-jNUM run NUM tests at once (default: number of CPU cores)
|
|
|
|
123 run test 123 (any number, can be given multiple times)
|
|
|
|
/REGEX/ run tests whose names match REGEX (case insensitive; can be given multiple times)
|
|
|
|
EOHELP
|
|
|
|
exit 0
|
2004-08-19 14:05:56 +00:00
|
|
|
else
|
2010-06-15 22:26:19 +00:00
|
|
|
error_and_exit "Unknown argument '#{arg}'."
|
2004-08-19 14:05:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-15 22:26:19 +00:00
|
|
|
controller.go
|
2004-08-19 14:05:56 +00:00
|
|
|
|
2010-06-15 22:26:19 +00:00
|
|
|
exit controller.num_failed > 0 ? 1 : 0
|
2004-08-19 14:05:56 +00:00
|
|
|
end
|
|
|
|
|
2012-01-26 19:02:25 +00:00
|
|
|
setup
|
2004-08-19 14:05:56 +00:00
|
|
|
main
|