Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 106 lines (85 sloc) 2.789 kb
e1e265f @lian makes bundlers gem-tasks optional in Rakefile.
lian authored
1 begin
2 require 'bundler/gem_tasks'
3 rescue LoadError
4 end
e8f68e5 @lian network and protocol parsing
lian authored
5
aa1dcdf @mhanne test coverage reports
mhanne authored
6
0fb0b5e @lian change spec files order
lian authored
7 PROJECT_SPECS = ( FileList['spec/bitcoin/bitcoin_spec.rb'] +
8 FileList['spec/bitcoin/protocol/*_spec.rb'] +
9 FileList['spec/bitcoin/script/*_spec.rb'] +
10 FileList['spec/bitcoin/wallet/*_spec.rb'] +
6e25bb7 @lian move storage specs to its own directory
lian authored
11 FileList['spec/bitcoin/storage/*_spec.rb'] +
0fb0b5e @lian change spec files order
lian authored
12 FileList['spec/bitcoin/*_spec.rb'] ).uniq
e8f68e5 @lian network and protocol parsing
lian authored
13
60b63e4 @lian fix rake bacon for 1.9.3
lian authored
14 RUBY = 'ruby' unless defined?(RUBY)
15
0fb0b5e @lian change spec files order
lian authored
16 task :default => :bacon
e8f68e5 @lian network and protocol parsing
lian authored
17 #
18 # test runner
19 #
20 desc 'Run all bacon specs with pretty output'
21 task :bacon do
22 require 'open3'
23 require 'scanf'
24 require 'matrix'
25
26 specs = PROJECT_SPECS
bdc3a60 @lian fix get_prev_out in storage_spec
lian authored
27 #specs.delete_if{|i| File.basename(i) == 'storage_spec.rb' } # skip for now
e8f68e5 @lian network and protocol parsing
lian authored
28
29 some_failed = false
30 specs_size = specs.size
31 len = specs.map{|s| s.size }.sort.last
32 total_tests = total_assertions = total_failures = total_errors = 0
33 totals = Vector[0, 0, 0, 0]
34
35 red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
36 left_format = "%4d/%d: %-#{len + 11}s"
37 spec_format = "%d specifications (%d requirements), %d failures, %d errors"
38
39 specs.each_with_index do |spec, idx|
40 print(left_format % [idx + 1, specs_size, spec])
41
42 Open3.popen3(RUBY, spec) do |sin, sout, serr|
43 out = sout.read.strip
44 err = serr.read.strip
45
46 # this is conventional, see spec/innate/state/fiber.rb for usage
47 if out =~ /^Bacon::Error: (needed .*)/
48 puts(yellow % ("%6s %s" % ['', $1]))
49 else
50 total = nil
51
52 out.each_line do |line|
53 scanned = line.scanf(spec_format)
54
55 next unless scanned.size == 4
56
57 total = Vector[*scanned]
58 break
59 end
60
61 if total
62 totals += total
63 tests, assertions, failures, errors = total_array = total.to_a
64
65 if tests > 0 && failures + errors == 0
66 puts((green % "%6d passed") % tests)
67 else
68 some_failed = true
69 puts(red % " failed")
70 puts out unless out.empty?
71 puts err unless err.empty?
72 end
73 else
74 some_failed = true
75 puts(red % " failed")
76 puts out unless out.empty?
77 puts err unless err.empty?
78 end
79 end
80 end
81 end
82
83 total_color = some_failed ? red : green
84 puts(total_color % (spec_format % totals.to_a))
85 exit 1 if some_failed
86 end
5426c5f @mhanne rake task to generate rdoc
mhanne authored
87
88
89 desc 'Generate RDoc documentation'
90 task :rdoc do
91 `rm -rf rdoc`
111e966 @mhanne documentation
mhanne authored
92 system("rdoc -o rdoc -m README.rdoc examples/ doc/ lib/ README.rdoc COPYING")
ccf9bdc @lian tiny cleanup
lian authored
93 end
aa1dcdf @mhanne test coverage reports
mhanne authored
94
95
96 desc 'Generate test coverage report'
97 task :coverage do
98 begin
99 require 'simplecov'
100 rescue LoadError
101 puts "Simplecov not found. Run `gem install simplecov` to install it."
102 exit
103 end
104 system "bacon #{PROJECT_SPECS.join(' ')}"
105 end
Something went wrong with that request. Please try again.