Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 67 lines (54 sloc) 1.828 kb
685fa37 @manveru Brand new rake tasks, fine-grained with help of raku
manveru authored
1 desc 'Run all bacon specs with pretty output'
2 task :bacon => :install_dependencies do
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
3 require 'open3'
979e75e @manveru Better spec task
manveru authored
4 require 'scanf'
a4c080f @manveru Improve bacon task
manveru authored
5 require 'matrix'
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
6
685fa37 @manveru Brand new rake tasks, fine-grained with help of raku
manveru authored
7 specs = PROJECT_SPECS
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
8
979e75e @manveru Better spec task
manveru authored
9 some_failed = false
a4c080f @manveru Improve bacon task
manveru authored
10 specs_size = specs.size
979e75e @manveru Better spec task
manveru authored
11 len = specs.map{|s| s.size }.sort.last
a4c080f @manveru Improve bacon task
manveru authored
12 total_tests = total_assertions = total_failures = total_errors = 0
13 totals = Vector[0, 0, 0, 0]
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
14
685fa37 @manveru Brand new rake tasks, fine-grained with help of raku
manveru authored
15 red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
979e75e @manveru Better spec task
manveru authored
16 left_format = "%4d/%d: %-#{len + 11}s"
17 spec_format = "%d specifications (%d requirements), %d failures, %d errors"
6e23112 @manveru run specs with total summary
manveru authored
18
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
19 specs.each_with_index do |spec, idx|
a4c080f @manveru Improve bacon task
manveru authored
20 print(left_format % [idx + 1, specs_size, spec])
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
21
685fa37 @manveru Brand new rake tasks, fine-grained with help of raku
manveru authored
22 Open3.popen3(RUBY, spec) do |sin, sout, serr|
02cd6ec @manveru Improve bacon task so specs can fail on dependencies without messing up ...
manveru authored
23 out = sout.read.strip
24 err = serr.read.strip
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
25
02cd6ec @manveru Improve bacon task so specs can fail on dependencies without messing up ...
manveru authored
26 # this is conventional, see spec/innate/state/fiber.rb for usage
27 if out =~ /^Bacon::Error: (needed .*)/
28 puts(yellow % ("%6s %s" % ['', $1]))
29 else
30 total = nil
64033fc @clivecrous Failure feedback when specs completely fail to run
clivecrous authored
31
02cd6ec @manveru Improve bacon task so specs can fail on dependencies without messing up ...
manveru authored
32 out.each_line do |line|
33 scanned = line.scanf(spec_format)
34
35 next unless scanned.size == 4
a4c080f @manveru Improve bacon task
manveru authored
36
02cd6ec @manveru Improve bacon task so specs can fail on dependencies without messing up ...
manveru authored
37 total = Vector[*scanned]
38 break
39 end
40
41 if total
42 totals += total
43 tests, assertions, failures, errors = total_array = total.to_a
979e75e @manveru Better spec task
manveru authored
44
02cd6ec @manveru Improve bacon task so specs can fail on dependencies without messing up ...
manveru authored
45 if tests > 0 && failures + errors == 0
46 puts((green % "%6d passed") % tests)
47 else
48 some_failed = true
49 puts(red % " failed")
50 puts out unless out.empty?
51 puts err unless err.empty?
52 end
a4c080f @manveru Improve bacon task
manveru authored
53 else
54 some_failed = true
55 puts(red % " failed")
02cd6ec @manveru Improve bacon task so specs can fail on dependencies without messing up ...
manveru authored
56 puts out unless out.empty?
57 puts err unless err.empty?
979e75e @manveru Better spec task
manveru authored
58 end
95a59e2 @manveru Improve tasks for spec/rcov
manveru authored
59 end
36e461d @manveru Finally switch to bacon totally, enjoy :D
manveru authored
60 end
fd26838 @manveru restructure spec tasks, check `rake -T` for the new tasks
manveru authored
61 end
6e23112 @manveru run specs with total summary
manveru authored
62
a4c080f @manveru Improve bacon task
manveru authored
63 total_color = some_failed ? red : green
64 puts(total_color % (spec_format % totals.to_a))
979e75e @manveru Better spec task
manveru authored
65 exit 1 if some_failed
fd26838 @manveru restructure spec tasks, check `rake -T` for the new tasks
manveru authored
66 end
Something went wrong with that request. Please try again.