Skip to content

Commit

Permalink
Move the logic to test bundled gems to Ruby code
Browse files Browse the repository at this point in the history
* Writing shell scripts in a Makefile is very error-prone.
* TEST_BUNDLED_GEMS_ALLOW_FAILURES seemed to not work before.
  • Loading branch information
eregon committed Sep 29, 2019
1 parent d090e44 commit 4096e4b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
10 changes: 1 addition & 9 deletions template/Makefile.in
Expand Up @@ -536,15 +536,7 @@ cont.$(OBJEXT): $(COROUTINE_H)
TEST_BUNDLED_GEMS_ALLOW_FAILURES =

test-bundled-gems-run:
$(Q) fail=0 keep=; case "$(MFLAGS)" in *k*) keep=1;; esac; \
while read gem _; do \
echo testing $$gem gem; \
[ $$keep ] || echo $(TEST_BUNDLED_GEMS_ALLOW_FAILURES) | grep -q $$gem || set -e; \
$(XRUBY) -C $(srcdir)/gems/src/$$gem -Ilib ../../../.bundle/bin/rake; \
[ $$? = 0 ] || fail=1; \
set +e; \
done < $(srcdir)/gems/bundled_gems; \
exit $$fail
$(Q) $(XRUBY) $(srcdir)/tool/test-bundled-gems.rb

update-src::
@$(CHDIR) "$(srcdir)" && LC_TIME=C exec $(VCSUP)
Expand Down
26 changes: 26 additions & 0 deletions tool/test-bundled-gems.rb
@@ -0,0 +1,26 @@
require 'rbconfig'

allowed_failures = ENV['TEST_BUNDLED_GEMS_ALLOW_FAILURES'] || ''
allowed_failures = allowed_failures.split(',').reject(&:empty?)

exit_code = 0
File.foreach('gems/bundled_gems') do |line|
gem = line.split.first
puts "\nTesting the #{gem} gem"

gem_src_dir = File.expand_path("../../gems/src/#{gem}", __FILE__ )
test_command = "#{RbConfig.ruby} -C #{gem_src_dir} -Ilib ../../../.bundle/bin/rake"
puts test_command
system test_command

unless $?.success?
puts "Tests failed with exit code #{$?.exitstatus}"
if allowed_failures.include?(gem)
puts "Ignoring test failures for #{gem} due to \$TEST_BUNDLED_GEMS_ALLOW_FAILURES"
else
exit_code = $?.exitstatus
end
end
end

exit exit_code

0 comments on commit 4096e4b

Please sign in to comment.