Skip to content

Commit 51f23c5

Browse files
authored
Improve testing infra (#442)
* Add test_in_isolation task to run tests in isolation This simulates how tests are run in Ruby CI and can detect some issues before they're merged and break Ruby CI later. * Run test_in_isolation task on CI * Fix TestRaiseNoBacktraceException's setup
1 parent 453e4da commit 51f23c5

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ jobs:
3636
with:
3737
ruby-version: ${{ matrix.ruby }}
3838
bundler-cache: true
39-
- name: Run test
39+
- name: Run tests
4040
run: bundle exec rake test
41+
- name: Run tests in isolation
42+
run: bundle exec rake test_in_isolation
4143
vterm-yamatanooroti:
4244
name: >-
4345
vterm-yamatanooroti ${{ matrix.ruby }} ${{ matrix.with_latest_reline && '(latest reline)' || '' }}

Rakefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ Rake::TestTask.new(:test) do |t|
88
t.test_files = FileList["test/irb/test_*.rb"]
99
end
1010

11+
# To make sure they have been correctly setup for Ruby CI.
12+
desc "Run each irb test file in isolation."
13+
task :test_in_isolation do
14+
failed = false
15+
16+
FileList["test/irb/test_*.rb"].each do |test_file|
17+
ENV["TEST"] = test_file
18+
begin
19+
Rake::Task["test"].execute
20+
rescue => e
21+
failed = true
22+
msg = "Test '#{test_file}' failed when being executed in isolation. Please make sure 'rake test TEST=#{test_file}' passes."
23+
separation_line = '=' * msg.length
24+
25+
puts <<~MSG
26+
#{separation_line}
27+
#{msg}
28+
#{separation_line}
29+
MSG
30+
end
31+
end
32+
33+
fail "Some tests failed when being executed in isolation" if failed
34+
end
35+
1136
Rake::TestTask.new(:test_yamatanooroti) do |t|
1237
t.libs << 'test' << "test/lib"
1338
t.libs << 'lib'

test/irb/test_raise_no_backtrace_exception.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: false
2+
require "tmpdir"
23

34
require_relative "helper"
45

0 commit comments

Comments
 (0)