Skip to content
Newer
Older
100644 215 lines (176 sloc) 5.61 KB
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
1 #!/usr/bin/env rake
2 # -*- Ruby -*-
3 require 'rubygems'; require 'require_relative'
4
5 ROOT_DIR = File.dirname(__FILE__)
6 Gemspec_filename='trepan8.gemspec'
7 require_relative './app/options'
8
9 def gemspec
10 @gemspec ||= eval(File.read(Gemspec_filename), binding, Gemspec_filename)
11 end
12
d7164b7 @rocky Go with rdoc > 2.4.2 now. Sigh
rocky authored Sep 27, 2011
13 require 'rdoc/task'
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
14 desc 'Build the gem'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
15 task :package=>:gem
16 task :gem=>:gemspec do
17 Dir.chdir(ROOT_DIR) do
18 sh "gem build #{Gemspec_filename}"
19 FileUtils.mkdir_p 'pkg'
20 FileUtils.mv gemspec.file_name, 'pkg'
21 end
22 end
23
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
24 desc 'Install the gem locally'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
25 task :install => :gem do
26 Dir.chdir(ROOT_DIR) do
27 sh %{gem install --local pkg/#{gemspec.file_name}}
28 end
29 end
30
31 require 'rake/testtask'
32 require 'rbconfig'
33
78f5f7f @rocky Part of last commit. See that.
rocky authored Jun 8, 2011
34 def RbConfig.ruby
35 File.join(RbConfig::CONFIG['bindir'],
36 RbConfig::CONFIG['RUBY_INSTALL_NAME'] +
37 RbConfig::CONFIG['EXEEXT'])
38 end unless defined? RbConfig.ruby
39
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
40 def run_standalone_ruby_files(list, opts={})
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
41 puts '*' * 40
42 list.each do |ruby_file|
43 system(RbConfig.ruby, ruby_file)
44 p $?.exitstatus
45 break if $?.exitstatus != 0 && !opts[:continue]
46 end
47 end
48
49 def run_standalone_ruby_file(directory, opts={})
50 puts(('*' * 10) + ' ' + directory + ' ' + ('*' * 10))
51 Dir.chdir(directory) do
52 Dir.glob('*.rb').each do |ruby_file|
53 puts(('-' * 20) + ' ' + ruby_file + ' ' + ('-' * 20))
54 system(RbConfig.ruby, ruby_file)
55 break if $?.exitstatus != 0 && !opts[:continue]
56 end
57 end
58 end
59
60 desc 'Create a GNU-style ChangeLog via git2cl'
61 task :ChangeLog do
62 system('git log --pretty --numstat --summary | git2cl > ChangeLog')
63 end
64
65 desc 'Test units - the smaller tests'
66 Rake::TestTask.new(:'test:unit') do |t|
67 t.test_files = FileList['test/unit/**/test-*.rb']
68 # t.pattern = 'test/**/*test-*.rb' # instead of above
69 t.options = '--verbose' if $VERBOSE
70 end
71
72 desc 'Test functional - the medium-sized tests'
73 Rake::TestTask.new(:'test:functional') do |t|
74 t.test_files = FileList['test/functional/**/test-*.rb']
75 t.options = '--verbose' if $VERBOSE
76 end
77
78 desc 'Test integration - end-to-end blackbox tests'
79 Rake::TestTask.new(:'test:integration') do |t|
80 t.test_files = FileList['test/integration/**/test-*.rb']
81 t.options = '--verbose' if $VERBOSE
82 end
83
84 desc 'Test everything - unit tests for now.'
85 task :test do
ab5de6e @rocky Get first integration test working. "set debug testing" beefed up for…
rocky authored Jun 5, 2011
86 exceptions = %w(test:unit test:integration).collect do |task|
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
87 begin
88 Rake::Task[task].invoke
89 nil
90 rescue => e
91 e
92 end
93 end.compact
94
95 exceptions.each {|e| puts e;puts e.backtrace }
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
96 raise 'Test failures' unless exceptions.empty?
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
97 end
98
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
99 desc 'Run each Ruby app file in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
100 task :'check:app' do
101 run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} app)))
102 end
103
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
104 desc 'Run each command in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
105 task :'check:commands' do
106 run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} processor command)))
107 end
108
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
109 desc 'Run each of the sub-sub commands in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
110 task :'check:sub:commands' do
111 p "#{ROOT_DIR}/processor/command/*_subcmd/*_subcmd/*.rb"
112 Dir.glob("#{ROOT_DIR}/processor/command/*_subcmd").each do |sub_dir|
113 run_standalone_ruby_file(sub_dir)
114 end
115 end
116
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
117 desc 'Run each of the sub-sub commands in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
118 task :'check:subsub:commands' do
119 subsub_files = FileList["#{ROOT_DIR}/processor/command/*_subcmd/*_subcmd/*.rb"]
120 run_standalone_ruby_files(subsub_files)
121 end
122
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
123 desc 'Run each processor Ruby file in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
124 task :'check:lib' do
125 run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} lib)))
126 end
127
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
128 desc 'Run each processor Ruby file in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
129 task :'check:processor' do
130 run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} processor)))
131 end
132
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
133 desc 'Run each processor Ruby file in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
134 task :'check:unit' do
135 run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test unit)))
136 end
137
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
138 desc 'Run functional tests in standalone mode.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
139 task :'check:functional' do
140 run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test functional)))
141 end
142
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
143 desc 'Run command parser grammar.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
144 task :'check:cmd_parse' do
145 sh "kpeg --test --debug #{File.join(ROOT_DIR, %w(app cmd_parse.kpeg))}"
146 end
147
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
148 desc 'Generate command parser.'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
149 task :'cmd_parse' do
150 require 'tmpdir'
151 temp_file =
152 File.join(Dir.tmpdir,
153 Dir::Tmpname.make_tmpname(['cmd_parser_', '.rb'], nil))
154
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
155 sh('kpeg --name CmdParse --verbose --stand-alone ' +
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
156 "#{File.join(ROOT_DIR, %w(app cmd_parse.kpeg))} " +
157 "--output #{temp_file}")
158 end
159
160 task :'check:integration' do
161 run_standalone_ruby_files(FileList['test/integration/**/test-*.rb'])
162 end
163
164 task :check => %w(check:lib check:processor check:commands).map{|c| c.to_sym}
165
166 desc "Default action is same as 'test'."
167 task :default => :test
168
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
169 desc 'Generate the gemspec'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
170 task :generate do
171 puts gemspec.to_ruby
172 end
173
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
174 desc 'Validate the gemspec'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
175 task :gemspec do
176 gemspec.validate
177 end
178
179 # --------- RDoc Documentation ------
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
180 desc 'Generate rdoc documentation'
181 Rake::RDocTask.new('rdoc') do |rdoc|
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
182 rdoc.rdoc_dir = 'doc'
183 rdoc.title = "Trepanning #{Trepan::VERSION} Documentation"
184
185 rdoc.rdoc_files.include(%w(lib/*.rb
186 app/*.rb intf/*.rb io/*.rb
187 bin/trepan8
188 ))
189 end
190
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
191 desc 'Same as rdoc'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
192 task :doc => :rdoc
193
194 task :clobber_package do
195 FileUtils.rm_rf File.join(ROOT_DIR, 'pkg')
196 end
197
198 task :clobber_rdoc do
199 FileUtils.rm_rf File.join(ROOT_DIR, 'doc')
200 end
201
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
202 desc 'Remove residue from running patch'
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
203 task :rm_patch_residue do
4a28feb @rocky Get ready for 0.1.3 release.
rocky authored Jun 11, 2011
204 FileUtils.rm_rf FileList['**/*.{rej,orig}'].to_a, :verbose => true
9ef281d @rocky Port over Rakefile from rb-trepanning. Add first unit test (from rb-t…
rocky authored May 27, 2011
205 end
206
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
207 desc 'Remove ~ backup files'
208 task :rm_tilde_backups do
209 FileUtils.rm_rf Dir.glob('**/*~'), :verbose => true
22352eb @rocky I run rubinius on this too often.
rocky authored Jun 11, 2011
210 FileUtils.rm_rf Dir.glob('**/*.rbc'), :verbose => true
cd42f12 @rocky Better file cleanup. Sync with rbx-trepanning.
rocky authored Jun 9, 2011
211 end
212
213 desc 'Remove built files'
214 task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue, :rm_tilde_backups]
Something went wrong with that request. Please try again.