tests: add option for listing all failed case IDs

This commit is contained in:
Moritz Bunkus 2016-05-13 19:46:12 +02:00
parent a65f30bd21
commit 0094e3ffa2
2 changed files with 17 additions and 0 deletions

View File

@ -57,9 +57,13 @@ def main
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 }
elsif ((arg == "-F" || (arg == "--list-failed")))
controller.list_failed_ids
exit 0
elsif ((arg == "-h") || (arg == "--help"))
puts <<EOHELP
Syntax: run.rb [options]
-F, --list-failed list IDs of failed tests
-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)

View File

@ -162,4 +162,17 @@ class Controller
@results_mutex.unlock
end
def list_failed_ids
entries = @dir_entries.collect do |entry|
if (FileTest.file?(entry) && (entry =~ /^test-(\d+).*\.rb$/))
class_name = file_name_to_class_name entry
@results.status?(class_name) == :failed ? $1.to_i : nil
else
nil
end
end
puts entries.reject(&:nil?).sort.map(&:to_s).join(" ")
end
end