From 5c4273f944b538bc24ed98c52991ea8bf9044654 Mon Sep 17 00:00:00 2001 From: Chris Reuter Date: Thu, 21 Oct 2021 21:33:17 -0400 Subject: Added testing support for cross-MinGW builds. This adds a build_config that will cross-build a Windows executable using the MinGW cross-compiler and will also run the unit (i.e. 'rake test') using Wine. For this to work, I made some modifications to the underlying test scripts as well as some minor changes to a couple of the tests themselves. --- lib/mruby/build.rb | 17 +++++++++++++++++ lib/mruby/build/command.rb | 5 +++++ 2 files changed, 22 insertions(+) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 67267ab46..66005a6df 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -541,6 +541,23 @@ EOS end end + def run_bintest + puts ">>> Bintest #{name} <<<" + targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir } + targets << filename(".") if File.directory? "./bintest" + mrbc = @gems["mruby-bin-mrbc"] ? exefile("#{@build_dir}/bin/mrbc") : mrbcfile + + emulator = @test_runner.command + emulator = @test_runner.shellquote(emulator) if emulator + + env = { + "BUILD_DIR" => @build_dir, + "MRBCFILE" => mrbc, + "EMULATOR" => @test_runner.emulator, + } + sh env, "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}" + end + protected def create_mrbc_build; end diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index c93d08ea7..31a595ef0 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -363,6 +363,11 @@ module MRuby @flags = [] end + def emulator + return "" unless @command + return [@command, *@flags].map{|c| shellquote(c)}.join(' ') + end + def run(testbinfile) puts "TEST for " + @build.name _run runner_options, { :flags => [flags, verbose_flag].flatten.join(' '), :infile => testbinfile } -- cgit v1.2.3