tests: add option for showing how long each test took

This commit is contained in:
Moritz Bunkus 2021-07-07 16:16:23 +02:00
parent 640a0ba0a6
commit 8cd0dea492
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 7 additions and 1 deletions

View File

@ -50,6 +50,8 @@ def main
controller.test_date_after = Time.local($1, $2, $3, $4, $5, $6)
elsif (arg =~ /-D([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})/)
controller.test_date_before = Time.local($1, $2, $3, $4, $5, $6)
elsif ((arg == "-s") or (arg == "--show-duration"))
controller.show_duration = true
elsif arg =~ /-j(\d+)/
controller.num_threads = $1.to_i
elsif /^ (!)? (\d{1,4}) (?: - (\d{1,4}) )?$/x.match arg
@ -74,6 +76,7 @@ Syntax: run.rb [options]
-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
-s, --show-duration show how long each test took to run
-jNUM run NUM tests at once (default: number of CPU cores)
123 run test 123 (any number; can be given multiple times)
12-345 run tests 12 through 345 (any range of numbers; can be given multiple times)

View File

@ -1,5 +1,5 @@
class Controller
attr_accessor :test_failed, :test_new, :test_date_after, :teset_date_before, :update_failed, :num_failed, :record_duration
attr_accessor :test_failed, :test_new, :test_date_after, :teset_date_before, :update_failed, :num_failed, :record_duration, :show_duration
attr_reader :num_threads, :results
def initialize
@ -11,6 +11,7 @@ class Controller
@update_failed = false
@num_threads = self.get_num_processors
@record_duration = false
@show_duration = false
@tests = Array.new
@exclusions = Array.new
@ -128,6 +129,8 @@ class Controller
result = current_test.run_test expected_results
duration = Time.now - start
puts "Finished '#{class_name}' after #{sprintf('%0.3f', duration)}s" if self.show_duration
if (result)
if (!@results.exist? class_name)
self.add_result class_name, :passed, :message => " NEW test. Storing result '#{result}'.", :checksum => result, :duration => duration