From 26aebdb6d6ada732bf0aadd9062e65291c7cc413 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 27 Nov 2024 14:22:40 +0900 Subject: [PATCH] Added --env option to mspec for test-bundled-gems --- common.mk | 5 +++-- spec/bundled_gems.mspec | 2 +- spec/mspec/lib/mspec/commands/mspec-run.rb | 1 + spec/mspec/lib/mspec/utils/options.rb | 8 ++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common.mk b/common.mk index 2861adee8f..15a350aa8a 100644 --- a/common.mk +++ b/common.mk @@ -1646,8 +1646,9 @@ test-bundled-gems-spec: $(TEST_RUNNABLE)-test-bundled-gems-spec yes-test-bundled-gems-spec: yes-test-spec-precheck $(PREPARE_BUNDLED_GEMS) $(ACTIONS_GROUP) $(gnumake_recursive)$(Q) \ - BUNDLED_GEMS=$(BUNDLED_GEMS) $(RUNRUBY) -r./$(arch)-fake -r$(tooldir)/lib/_tmpdir \ - $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/bundled_gems.mspec $(MSPECOPT) $(SPECOPTS) + $(RUNRUBY) -r./$(arch)-fake -r$(tooldir)/lib/_tmpdir \ + $(srcdir)/spec/mspec/bin/mspec run --env BUNDLED_GEMS=$(BUNDLED_GEMS) -B $(srcdir)/spec/bundled_gems.mspec \ + $(MSPECOPT) $(SPECOPTS) $(ACTIONS_ENDGROUP) no-test-bundled-gems-spec: diff --git a/spec/bundled_gems.mspec b/spec/bundled_gems.mspec index 435f8b381a..f17f32f1b2 100644 --- a/spec/bundled_gems.mspec +++ b/spec/bundled_gems.mspec @@ -2,7 +2,7 @@ load File.dirname(__FILE__) + '/default.mspec' class MSpecScript test_bundled_gems = get(:stdlibs).to_a & get(:bundled_gems).to_a - unless ENV["BUNDLED_GEMS"].empty? + unless ENV["BUNDLED_GEMS"].nil? test_bundled_gems = ENV["BUNDLED_GEMS"].split(",").map do |gem| test_bundled_gems.find{|test_gem| test_gem.include?(gem) } end.compact diff --git a/spec/mspec/lib/mspec/commands/mspec-run.rb b/spec/mspec/lib/mspec/commands/mspec-run.rb index 4d8f4d9984..064c177d69 100644 --- a/spec/mspec/lib/mspec/commands/mspec-run.rb +++ b/spec/mspec/lib/mspec/commands/mspec-run.rb @@ -32,6 +32,7 @@ class MSpecRun < MSpecScript options.chdir options.prefix options.configure { |f| load f } + options.env options.randomize options.repeat options.pretend diff --git a/spec/mspec/lib/mspec/utils/options.rb b/spec/mspec/lib/mspec/utils/options.rb index 3b5962dbe6..23cf915e66 100644 --- a/spec/mspec/lib/mspec/utils/options.rb +++ b/spec/mspec/lib/mspec/utils/options.rb @@ -204,6 +204,13 @@ class MSpecOptions "Load FILE containing configuration options", &block) end + def env + on("--env", "KEY=VALUE", "Set environment variable") do |env| + key, value = env.split('=', 2) + ENV[key] = value + end + end + def targets on("-t", "--target", "TARGET", "Implementation to run the specs, where TARGET is:") do |t| @@ -484,6 +491,7 @@ class MSpecOptions def all configure {} + env targets formatters filters