Skip to content

Commit

Permalink
Track down incompatibility/race condition between JRuby and RSpec moc…
Browse files Browse the repository at this point in the history
…ks in tests (#581)
  • Loading branch information
bensheldon authored Apr 25, 2022
1 parent 0998bac commit c548fb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
uses: actions/cache@v1
with:
path: gemfiles/vendor/bundle
key: v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
key: v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock', 'gemfiles/*.gemfile.lock') }}
restore-keys: |
v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-
- name: Install Appraisal gems
Expand All @@ -106,6 +106,7 @@ jobs:
--require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter
- name: Run System tests
if: ${{ !contains(matrix.ruby, 'jruby') }}
run: |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
Expand Down
3 changes: 3 additions & 0 deletions spec/lib/good_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
described_class.cleanup_preserved_jobs

expect(ActiveSupport::Notifications).to have_received(:instrument).at_least(:once)

# Manually remove the stub to prevent the instrumentation from affecting multi-threaded teardown
::RSpec::Mocks.space.proxy_for(ActiveSupport::Notifications).remove_stub(:instrument)
end
end
end
2 changes: 1 addition & 1 deletion spec/support/reset_good_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
THREAD_ERRORS.clear
Thread.current.name = "RSpec: #{example.description}"
GoodJob.on_thread_error = lambda do |exception|
THREAD_ERRORS << [Thread.current.name, exception]
THREAD_ERRORS << [Thread.current.name, exception, exception.backtrace]
end

example.run
Expand Down

0 comments on commit c548fb7

Please sign in to comment.