Skip to content

Commit 247e062

Browse files
committed
Not to chdir globally
* Calling Dir.chdir in top level of Rakefile makes us not to add any tasks which should run on project root directory.
1 parent f162570 commit 247e062

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

mrblib/mruby-cli/setup.rb

+24-19
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,8 @@ def rakefile
330330
ENV['MRUBY_ROOT'] = mruby_root
331331
ENV['MRUBY_CONFIG'] = mruby_config
332332
Rake::Task[:mruby].invoke unless Dir.exist?(mruby_root)
333-
Dir.chdir(mruby_root)
334333
load "\#{mruby_root}/Rakefile"
335334
336-
337335
load File.join(File.expand_path(File.dirname(__FILE__)), "mrbgem.rake")
338336
339337
current_gem = MRuby::Gem.current
@@ -342,26 +340,29 @@ def rakefile
342340
343341
desc "compile binary"
344342
task :compile => [:all] do
345-
346-
MRuby.each_target do |target|
347-
`\#{target.cc.command} --version`
348-
abort("Command \#{target.cc.command} for \#{target.name} is missing.") unless $?.success?
349-
end
350-
%W(\#{mruby_root}/build/x86_64-pc-linux-gnu/bin/\#{APP_NAME} \#{mruby_root}/build/i686-pc-linux-gnu/\#{APP_NAME}).each do |bin|
351-
sh "strip --strip-unneeded \#{bin}" if File.exist?(bin)
343+
Dir.chdir(mruby_root) do
344+
MRuby.each_target do |target|
345+
`\#{target.cc.command} --version`
346+
abort("Command \#{target.cc.command} for \#{target.name} is missing.") unless $?.success?
347+
end
348+
%W(\#{mruby_root}/build/x86_64-pc-linux-gnu/bin/\#{APP_NAME} \#{mruby_root}/build/i686-pc-linux-gnu/\#{APP_NAME}).each do |bin|
349+
sh "strip --strip-unneeded \#{bin}" if File.exist?(bin)
350+
end
352351
end
353352
end
354353
355354
namespace :test do
356355
desc "run mruby & unit tests"
357356
# only build mtest for host
358357
task :mtest => :compile do
359-
# in order to get mruby/test/t/synatx.rb __FILE__ to pass,
360-
# we need to make sure the tests are built relative from mruby_root
361-
MRuby.each_target do |target|
362-
# only run unit tests here
363-
target.enable_bintest = false
364-
run_test if target.test_enabled?
358+
Dir.chdir(mruby_root) do
359+
# in order to get mruby/test/t/synatx.rb __FILE__ to pass,
360+
# we need to make sure the tests are built relative from mruby_root
361+
MRuby.each_target do |target|
362+
# only run unit tests here
363+
target.enable_bintest = false
364+
run_test if target.test_enabled?
365+
end
365366
end
366367
end
367368
@@ -379,9 +380,11 @@ def clean_env(envs)
379380
380381
desc "run integration tests"
381382
task :bintest => :compile do
382-
MRuby.each_target do |target|
383-
clean_env(%w(MRUBY_ROOT MRUBY_CONFIG)) do
384-
run_bintest if target.bintest_enabled?
383+
Dir.chdir(mruby_root) do
384+
MRuby.each_target do |target|
385+
clean_env(%w(MRUBY_ROOT MRUBY_CONFIG)) do
386+
run_bintest if target.bintest_enabled?
387+
end
385388
end
386389
end
387390
end
@@ -393,7 +396,9 @@ def clean_env(envs)
393396
394397
desc "cleanup"
395398
task :clean do
396-
sh "rake deep_clean"
399+
Dir.chdir(mruby_root) do
400+
sh "rake deep_clean"
401+
end
397402
end
398403
399404
desc "generate a release tarball"

0 commit comments

Comments
 (0)