Merge pull request #6012 from sinisterchipmunk/allow-to-skip-tests-for-specific-mgems

Allow tests to be disabled for specific gems; warn about disabled tests
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-05-16 14:36:40 +09:00
committed by GitHub
3 changed files with 36 additions and 3 deletions
+15
View File
@@ -92,6 +92,21 @@ end
However, it should be used with caution, as it may deviate from the intent
of the gem's author.
### Gem Testing
If you enable unit tests in your build with `enable_test`, tests will be
generated for all gems and their dependencies by default. If necessary, it is
possible to suppress tests for a specific gem like so:
```ruby
conf.gem 'mruby-noisygem' do |g|
g.skip_test = true
end
```
However, it is considered best practice to leave all tests enabled whenever
possible. A warning message will be generated for each gem with disabled tests.
## GemBox
There are instances when you wish to add a collection of mrbgems into mruby at
+6
View File
@@ -36,6 +36,7 @@ module MRuby
attr_accessor :export_include_paths
attr_reader :generate_functions
attr_writer :skip_test
attr_block MRuby::Build::COMMANDS
@@ -62,6 +63,7 @@ module MRuby
@test_preload = nil # 'test/assert.rb'
@test_args = {}
@skip_test = false
@bins = []
@cdump = true
@@ -87,6 +89,10 @@ module MRuby
build.locks[repo_url]['version'] = version if repo_url
end
def skip_test?
@skip_test
end
def setup_compilers
(core? ? [@cc, *(@cxx if build.cxx_exception_enabled?)] : compilers).each do |compiler|
compiler.define_rules build_dir, @dir, @build.exts.presym_preprocessed if build.presym_enabled?
+15 -3
View File
@@ -144,14 +144,26 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
f.puts %Q[]
f.puts %Q[struct mrb_state;]
f.puts %Q[typedef struct mrb_state mrb_state;]
f.puts %Q[#include <mruby.h>]
f.puts %Q[#include <mruby/variable.h>]
f.puts %Q[#include <mruby/array.h>]
f.puts %Q[]
build.gems.each do |g|
f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);]
end
f.puts %Q[void mrbgemtest_init(mrb_state* mrb) {]
build.gems.each do |g|
f.puts %Q[ GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);]
if g.skip_test?
f.puts %Q[ do {]
f.puts %Q[ mrb_value asserts = mrb_gv_get(mrb, mrb_intern_lit(mrb, "$asserts"));]
f.puts %Q[ mrb_ary_push(mrb, asserts, mrb_str_new_lit(mrb, ]
f.puts %Q[ "Warn: Skipping tests for gem (#{
g.name == 'mruby-test' ? 'core' : "mrbgems: #{g.name}"
})"));]
f.puts %Q[ } while (0);]
else
f.puts %Q[ GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);]
end
end
f.puts %Q[}]
end