forked from rocky/rb-trepanning
/
Rakefile
165 lines (134 loc) · 3.99 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env rake
# -*- Ruby -*-
require 'rubygems'
ROOT_DIR = File.dirname(__FILE__)
require File.join %W(#{ROOT_DIR} app options)
def gemspec
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
end
require 'rake/gempackagetask'
desc "Build the gem"
task :package=>:gem
task :gem=>:gemspec do
Dir.chdir(ROOT_DIR) do
sh "gem build .gemspec"
FileUtils.mkdir_p 'pkg'
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
end
end
desc "Install the gem locally"
task :install => :gem do
Dir.chdir(ROOT_DIR) do
sh %{gem install --local pkg/#{gemspec.name}-#{gemspec.version}}
end
end
require 'rake/testtask'
desc "Test everything."
Rake::TestTask.new(:test) do |t|
t.libs << './lib'
t.pattern = 'test/test-*.rb'
t.verbose = true
end
task :test => :lib
desc "same as test"
task :check => :test
require 'rbconfig'
RUBY_PATH = File.join(RbConfig::CONFIG['bindir'],
RbConfig::CONFIG['RUBY_INSTALL_NAME'])
def run_standalone_ruby_file(directory)
puts ('*' * 10) + ' ' + directory + ' ' + ('*' * 10)
Dir.chdir(directory) do
Dir.glob('*.rb').each do |ruby_file|
puts ('-' * 20) + ' ' + ruby_file + ' ' + ('-' * 20)
system(RUBY_PATH, ruby_file)
end
end
end
desc 'Create a GNU-style ChangeLog via git2cl'
task :ChangeLog do
system('git log --pretty --numstat --summary | git2cl > ChangeLog')
end
desc 'Test units - the smaller tests'
Rake::TestTask.new(:'test:unit') do |t|
t.test_files = FileList['test/unit/**/test-*.rb']
# t.pattern = 'test/**/*test-*.rb' # instead of above
t.verbose = true
end
desc 'Test functional - the medium-sized tests'
Rake::TestTask.new(:'test:functional') do |t|
t.test_files = FileList['test/functional/**/test-*.rb']
t.verbose = true
end
desc 'Test integration - end-to-end blackbox tests'
Rake::TestTask.new(:'test:integration') do |t|
t.test_files = FileList['test/integration/**/test-*.rb']
t.verbose = true
end
desc 'Test everything - unit tests for now.'
task :test do
exceptions = %w(test:unit test:functional test:integration).collect do |task|
begin
Rake::Task[task].invoke
nil
rescue => e
e
end
end.compact
exceptions.each {|e| puts e;puts e.backtrace }
raise "Test failures" unless exceptions.empty?
end
desc "Run each library Ruby file in standalone mode."
task :'check:app' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} app)))
end
desc "Run each command in standalone mode."
task :'check:commands' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} processor command)))
end
desc "Run each processor Ruby file in standalone mode."
task :'check:lib' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} lib)))
end
desc "Run each processor Ruby file in standalone mode."
task :'check:processor' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} processor)))
end
desc "Run each processor Ruby file in standalone mode."
task :'check:unit' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test unit)))
end
task :'check:functional' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test functional)))
end
task :'check:integration' do
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test integration)))
end
task :check => %w(check:lib check:processor check:commands).map{|c| c.to_sym}
desc "Test everything - same as test."
task :default => :test
desc "Generate the gemspec"
task :generate do
puts gemspec.to_ruby
end
desc "Validate the gemspec"
task :gemspec do
gemspec.validate
end
# --------- RDoc Documentation ------
require 'rake/rdoctask'
desc "Generate rdoc documentation"
Rake::RDocTask.new("rdoc") do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = "Trepanning #{Trepanning::VERSION} Documentation"
rdoc.rdoc_files.include('lib/*.rb', 'app/*.rb', 'bin/trepan')
end
desc "Same as rdoc"
task :doc => :rdoc
desc "Remove built files"
task :clean => [:clobber_package, :clobber_rdoc]
task :clobber_package do
FileUtils.rm_rf File.join(ROOT_DIR, 'pkg')
end
task :clobber_rdoc do
FileUtils.rm_rf File.join(ROOT_DIR, 'doc')
end