Skip to content

Commit 0472ccb

Browse files
committed
Move test tasks to test.rake to fix dependencies
The test task depends upon clearing MRuby's test task but we can't do that until after MRuby's Rakefile loads. Moving the test tasks to a separate file we import allows us to clear MRuby's test actions at the proper time.
1 parent a20c617 commit 0472ccb

File tree

2 files changed

+50
-44
lines changed

2 files changed

+50
-44
lines changed

Rakefile

+5-44
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ end
2424
task :mruby => mruby_root
2525

2626
mruby_rakefile = "#{mruby_root}/Rakefile"
27-
file mruby_rakefile => mruby_root
2827

28+
file mruby_rakefile => mruby_root
2929
import mruby_rakefile
3030

31+
test_rakefile = "tasks/test.rake"
32+
file test_rakefile => mruby_rakefile
33+
import test_rakefile
34+
3135
task :app_version do
3236
load "mrbgem.rake"
3337

@@ -47,49 +51,6 @@ task :compile => [:all] do
4751
end
4852
end
4953

50-
namespace :test do
51-
desc "run mruby & unit tests"
52-
# only build mtest for host
53-
task :mtest => :compile do
54-
# in order to get mruby/test/t/synatx.rb __FILE__ to pass,
55-
# we need to make sure the tests are built relative from mruby_root
56-
cd mruby_root do
57-
MRuby.each_target do |target|
58-
# only run unit tests here
59-
target.enable_bintest = false
60-
run_test if target.test_enabled?
61-
end
62-
end
63-
end
64-
65-
def clean_env(envs)
66-
old_env = {}
67-
envs.each do |key|
68-
old_env[key] = ENV[key]
69-
ENV[key] = nil
70-
end
71-
yield
72-
envs.each do |key|
73-
ENV[key] = old_env[key]
74-
end
75-
end
76-
77-
desc "run integration tests"
78-
task :bintest => :compile do
79-
cd mruby_root do
80-
MRuby.each_target do |target|
81-
clean_env(%w(MRUBY_ROOT MRUBY_CONFIG)) do
82-
run_bintest if target.bintest_enabled?
83-
end
84-
end
85-
end
86-
end
87-
end
88-
89-
desc "run all tests"
90-
Rake::Task['test'].clear
91-
task :test => ['test:bintest', 'test:mtest']
92-
9354
desc "cleanup"
9455
task :clean do
9556
sh "rake deep_clean"

tasks/test.rake

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Remove default test task actions from MRuby's Rakefile
2+
Rake::Task['test'].clear
3+
4+
namespace :test do
5+
desc "run mruby & unit tests"
6+
# only build mtest for host
7+
task :mtest => :compile do
8+
# in order to get mruby/test/t/synatx.rb __FILE__ to pass,
9+
# we need to make sure the tests are built relative from MRUBY_ROOT
10+
cd MRUBY_ROOT do
11+
MRuby.each_target do |target|
12+
# only run unit tests here
13+
target.enable_bintest = false
14+
run_test if target.test_enabled?
15+
end
16+
end
17+
end
18+
19+
def clean_env(envs)
20+
old_env = {}
21+
envs.each do |key|
22+
old_env[key] = ENV[key]
23+
ENV[key] = nil
24+
end
25+
yield
26+
envs.each do |key|
27+
ENV[key] = old_env[key]
28+
end
29+
end
30+
31+
desc "run integration tests"
32+
task :bintest => :compile do
33+
cd MRUBY_ROOT do
34+
MRuby.each_target do |target|
35+
clean_env(%w(MRUBY_ROOT MRUBY_CONFIG)) do
36+
run_bintest if target.bintest_enabled?
37+
end
38+
end
39+
end
40+
end
41+
end
42+
43+
desc "run all tests"
44+
task :test => ['test:bintest', 'test:mtest']
45+

0 commit comments

Comments
 (0)