Skip to content

Commit

Permalink
Run each spec file in a process to detect missing requires
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Jan 8, 2023
1 parent 47af242 commit e711d63
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 11 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ source 'https://rubygems.org'

require File.join(File.dirname(__FILE__), 'lib/concurrent-ruby/concurrent/version')
require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby-edge/concurrent/edge/version')
require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby/concurrent/utility/engine')

no_path = ENV['NO_PATH']
options = no_path ? {} : { path: '.' }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ Everything within this gem can be loaded simply by requiring it:
require 'concurrent'
```

TODO: update this
*Requiring only specific abstractions from Concurrent Ruby is not yet supported.*

To use the tools in the Edge gem it must be required separately:
Expand Down
1 change: 0 additions & 1 deletion concurrent-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby/concurrent/version')
require File.join(File.dirname(__FILE__ ), 'lib/concurrent-ruby/concurrent/utility/engine')

Gem::Specification.new do |s|
git_files = `git ls-files`.split("\n")
Expand Down
13 changes: 13 additions & 0 deletions deps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Currently:
* lib/concurrent-ruby/concurrent/synchronization.rb loads C exts
* require 'concurrent/synchronization/*' seems not supported, too deep, and relies on require 'concurrent/synchronization' instead (seems OK).

A cycle:
AtomicMarkableReference -> Synchronization::Object

Synchronization::Object (synchronization/object.rb) -> AtomicReference
AtomicReference -> MutexAtomicReference (but only if non-cruby/jruby/tuffleruby)
MutexAtomicReference -> Synchronization::LockableObject
Synchronization::LockableObject -> MutexLockableObject, JRubyLockableObject, MonitorLockableObject
MutexLockableObject -> AbstractLockableObject
AbstractLockableObject -> Synchronization::Object
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/synchronization'

module Concurrent
# An atomic reference which maintains an object reference along with a mark bit
# that can be updated atomically.
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/atomic/atomic_reference.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization' # NEEDED?
require 'concurrent/utility/engine'
require 'concurrent/atomic_reference/numeric_cas_wrapper'

Expand Down
6 changes: 6 additions & 0 deletions spec/concurrent/agent_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
require 'concurrent/agent'
require 'concurrent/executor/single_thread_executor'
require 'concurrent/executor/immediate_executor'
require 'concurrent/executor/fixed_thread_pool'
require 'concurrent/atomic/count_down_latch'

require_relative 'concern/observable_shared'

module Concurrent
Expand Down
2 changes: 2 additions & 0 deletions spec/concurrent/array_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/array'

module Concurrent
RSpec.describe Array do
let!(:ary) { described_class.new }
Expand Down
3 changes: 2 additions & 1 deletion spec/concurrent/async_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Concurrent
require 'concurrent/async'

module Concurrent
RSpec.describe Async do

let(:async_class) do
Expand Down
2 changes: 2 additions & 0 deletions spec/concurrent/atomic/atomic_boolean_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/atomic/atomic_boolean'

RSpec.shared_examples :atomic_boolean do

describe 'construction' do
Expand Down
2 changes: 2 additions & 0 deletions spec/concurrent/atomic/atomic_fixnum_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/atomic/atomic_fixnum'

RSpec.shared_examples :atomic_fixnum do

context 'construction' do
Expand Down
2 changes: 2 additions & 0 deletions spec/concurrent/atomic/atomic_markable_reference_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/atomic/atomic_markable_reference'

RSpec.describe Concurrent::AtomicMarkableReference do
subject { described_class.new 1000, true }

Expand Down
7 changes: 7 additions & 0 deletions spec/concurrent/no_concurrent_files_loaded_before_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
files_loaded_before = $LOADED_FEATURES.grep(/\/concurrent\//).grep_v(/\/version\.rb$/)

RSpec.describe 'The test harness' do
it 'does not load concurrent-ruby files to ensure there are no missing requires' do
expect(files_loaded_before).to eq []
end
end
12 changes: 7 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ def requires=(paths)
end
end

require 'concurrent'
require 'concurrent-edge'

Concurrent.use_simple_logger Logger::FATAL

require_relative 'support/example_group_extensions'
require_relative 'support/threadsafe_test'

Expand All @@ -44,6 +39,13 @@ def requires=(paths)
config.include Concurrent::TestHelpers
config.extend Concurrent::TestHelpers

config.before :all do
# Only configure logging if it has been required, to make sure the necessary require's are in place
if Concurrent.respond_to? :use_simple_logger
Concurrent.use_simple_logger Logger::FATAL
end
end

config.before :each do
expect(!defined?(@created_threads) || @created_threads.nil? || @created_threads.empty?).to be_truthy
end
Expand Down
3 changes: 1 addition & 2 deletions spec/support/example_group_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'rbconfig'
require 'concurrent/synchronization'

module Concurrent
module TestHelpers
Expand All @@ -17,7 +16,7 @@ def delta(v1, v2)
return (v1 - v2).abs
end

include Utility::EngineDetector
# include Utility::EngineDetector # TODO

def use_c_extensions?
Concurrent.allow_c_extensions?
Expand Down

0 comments on commit e711d63

Please sign in to comment.