-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
85 lines (71 loc) · 2.29 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
require "bundler/gem_tasks"
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
test.libs << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
rescue LoadError
task :rcov do
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
end
end
task :default => :test
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
if File.exist?('VERSION')
version = File.read('VERSION')
else
version = ""
end
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "tack #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
namespace :tack do
task :acceptance do
command = 'bin/tack -u -s -Itest test/acceptance'
puts 'Running acceptance tests'
puts `#{command}`
end
task :unit do
command = 'bin/tack -u -s -Itest test/unit'
puts 'Running unit tests'
puts `#{command}`
end
task :compare do
puts "Comparing results of running tests with Tack to those when running tests with Ruby"
tack_command = 'bin/tack -s -u -Itest test'
puts 'Running tests with tack'
tack_output = `#{tack_command}`
### "24 tests, 0 failures, 0 pending"
match = tack_output.match(/(\d+) tests, (\d+) failures, (\d+) pending/)
tack_tests, tack_failures, tack_pending = match[1..3].map(&:to_i)
ruby_command = 'rake test'
puts 'Running tests with ruby'
ruby_output = `#{ruby_command}`
ruby_pending = ruby_output.scan(/DEFERRED\:/).length
match = ruby_output.match(/(\d+) tests, \d+ assertions, (\d+) failures, (\d+) errors/)
ruby_tests = match[1].to_i + ruby_pending
ruby_failures = match[2].to_i + match[3].to_i
if tack_tests != ruby_tests
puts "!!! Tack reported #{tack_tests} tests while Ruby reported #{ruby_tests} !!!"
end
if tack_failures != ruby_failures
puts "!!! Tack reported #{tack_failures} failures while Ruby reported #{ruby_failures} !!!"
end
if tack_pending != ruby_pending
puts "!!! Tack reported #{tack_pending} pending while Ruby reported #{ruby_pending} !!!"
end
puts "Comparison complete"
end
task :all => [:unit, :acceptance]
end