18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/slightish/command.rb', line 18
def run(test_files, sandbox_template_dir: nil)
Thread.abort_on_exception = true
suites = []
worker_threads = []
test_files.each do |file|
suite = Slightish::TestSuite.from_file(file, sandbox_template_dir: sandbox_template_dir)
suites << suite
worker_threads << Thread.new { suite.run }
end
worker_threads.each(&:join)
suites.each do |suite|
puts(suite.failure_description) if suite.failed?
end
puts('----------') if suites.any?(&:failed?)
total_tests = 0
total_passed = 0
total_failed = 0
max_suite_name_length = suites.max_by { |suite| suite.name.length }.name.length
max_passed_length = suites.max_by(&:passed_count).passed_count.to_s.length
max_failed_length = suites.max_by(&:failed_count).failed_count.to_s.length
suites.each do |suite|
total_tests += suite.test_cases.length
total_passed += suite.passed_count
total_failed += suite.failed_count
line = suite.name.ljust(max_suite_name_length + 1).bold + "\t"
line += "#{suite.passed_count.to_s.rjust(max_passed_length)} passed".green + "\t"
line += "#{suite.failed_count.to_s.rjust(max_failed_length)} failed".red
puts(line)
end
puts
puts('Total tests: '.bold + total_tests.to_s.gray)
puts('Passed: '.green + total_passed.to_s.gray)
puts('Failed: '.red + (total_tests - total_passed).to_s.gray)
Process.exit(1) if total_failed > 0
end
|