Skip to content

Commit

Permalink
Add "test runner" support for cross builds.
Browse files Browse the repository at this point in the history
 "test runner" means target simulator like QEmu, GDB sim, and so on. Also "test runner" might be debug agents for real targets.
If you do not setup test_runner, Rake will work same as before.
  • Loading branch information
monaka committed Apr 6, 2013
1 parent e885e59 commit 6e28c0e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
3 changes: 3 additions & 0 deletions build_config.rb
Expand Up @@ -114,4 +114,7 @@
# conf.build_mrbtest_lib_only
#
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
#
# conf.test_runner.command = 'env'
#
# end
15 changes: 13 additions & 2 deletions tasks/mruby_build.rake
Expand Up @@ -194,10 +194,21 @@ module MRuby
end # Build

class CrossBuild < Build
attr_block %w(test_runner)

def initialize(name, &block)
@test_runner = Command::CrossTestRunner.new(self)
super
end

def run_test
mrbtest = exefile("#{build_dir}/test/mrbtest")
puts "You should run #{mrbtest} on target device."
puts
if (@test_runner.command == nil)
puts "You should run #{mrbtest} on target device."
puts
else
@test_runner.run(mrbtest)
end
end
end # CrossBuild
end # MRuby
20 changes: 20 additions & 0 deletions tasks/mruby_build_commands.rake
Expand Up @@ -259,4 +259,24 @@ module MRuby
end
end
end

class Command::CrossTestRunner < Command
attr_accessor :runner_options
attr_accessor :verbose_flag
attr_accessor :flags

def initialize(build)
super
@command = nil
@runner_options = '%{flags} %{infile}'
@verbose_flag = ''
@flags = []
end

def run(testbinfile)
puts "TEST for " + @build.name
_run runner_options, { :flags => [flags, verbose_flag].flatten.join(' '), :infile => testbinfile }
end
end

end

0 comments on commit 6e28c0e

Please sign in to comment.