Skip to content

Commit

Permalink
Add build_mrbtest after config block is evaluated
Browse files Browse the repository at this point in the history
This allows us to add `enable_test` anywhere in a build target,
without having to worry about the order in which they are included.

Previously, there was a bug that occured when adding 'mruby-test' gem
to dependencies before additional gems.

Instead of adding the 'mruby-test' gem dependency manually to a test build,
we now only need to call `enable_test` in the target. This also allows us to
call `test_enabled?` downstream when running mruby tests ourselves.

/cc mruby#2924
  • Loading branch information
Zachary Scott committed Sep 3, 2015
1 parent cc0b283 commit bacb826
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
4 changes: 1 addition & 3 deletions Rakefile
Expand Up @@ -116,9 +116,7 @@ end
desc "run all mruby tests"
task :test => ["all"] do
MRuby.each_target do
if gems.find { |v| v.name == 'mruby-test' }
run_test unless build_mrbtest_lib_only?
end
run_test if test_enabled?
end
end

Expand Down
2 changes: 1 addition & 1 deletion build_config.rb
Expand Up @@ -114,9 +114,9 @@

enable_debug
conf.enable_bintest
conf.enable_test

conf.gembox 'default'
conf.gem :core => "mruby-test"
end

# Define cross build settings
Expand Down
2 changes: 1 addition & 1 deletion mrbgems/mruby-test/mrbgem.rake
Expand Up @@ -32,7 +32,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
end
end

gem_table = build.gems.generate_gem_table self
gem_table = build.gems.generate_gem_table build

build.gems.each do |g|
test_rbobj = g.test_rbireps.ext(exts.object)
Expand Down
21 changes: 18 additions & 3 deletions tasks/mruby_build.rake
Expand Up @@ -46,7 +46,7 @@ module MRuby
include LoadGems
attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir
attr_reader :libmruby, :gems, :toolchains
attr_writer :enable_bintest
attr_writer :enable_bintest, :enable_test

COMPILERS = %w(cc cxx objc asm)
COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc)
Expand Down Expand Up @@ -85,6 +85,8 @@ module MRuby
@build_mrbtest_lib_only = false
@cxx_abi_enabled = false
@cxx_exception_disabled = false
@enable_bintest = false
@enable_test = false
@toolchains = []

MRuby.targets[@name] = self
Expand All @@ -94,6 +96,7 @@ module MRuby
MRuby.targets[@name].instance_eval(&block)

build_mrbc_exec if name == 'host'
build_mrbtest if test_enabled?
end

def enable_debug
Expand Down Expand Up @@ -170,6 +173,18 @@ EOS
MRUBY_ROOT
end

def enable_test
@enable_test = true
end

def test_enabled?
@enable_test
end

def build_mrbtest
gem :core => 'mruby-test'
end

def build_mrbc_exec
gem :core => 'mruby-bin-mrbc'
end
Expand Down Expand Up @@ -252,7 +267,7 @@ EOS
mrbtest = exefile("#{build_dir}/bin/mrbtest")
sh "#{filename mrbtest.relative_path}#{$verbose ? ' -v' : ''}"
puts
run_bintest if @enable_bintest
run_bintest if bintest_enabled?
end

def run_bintest
Expand Down Expand Up @@ -297,7 +312,7 @@ EOS
end

def run_test
mrbtest = exefile("#{build_dir}/test/mrbtest")
mrbtest = exefile("#{build_dir}/bin/mrbtest")
if (@test_runner.command == nil)
puts "You should run #{mrbtest} on target device."
puts
Expand Down
12 changes: 2 additions & 10 deletions travis_config.rb
Expand Up @@ -22,6 +22,7 @@
c.defines += %w(MRB_GC_FIXED_ARENA)
end
conf.enable_bintest
conf.enable_test
end

MRuby::Build.new('cxx_abi') do |conf|
Expand All @@ -33,18 +34,9 @@
c.defines += %w(MRB_GC_FIXED_ARENA)
end
conf.enable_bintest
conf.enable_test

enable_cxx_abi

build_mrbc_exec
end

MRuby::Build.new('test') do |conf|
toolchain :gcc

enable_debug
conf.enable_bintest

conf.gembox 'full-core'
conf.gem :core => "mruby-test"
end

0 comments on commit bacb826

Please sign in to comment.