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
* Fixes #934.
  • Loading branch information
eregon committed Jan 8, 2023
1 parent 217dde0 commit 8eea936
Show file tree
Hide file tree
Showing 89 changed files with 306 additions and 137 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 (through generated code for #initialize)
AtomicReference -> MutexAtomicReference (but only if non-cruby-ext/non-jruby/non-truffleruby)
MutexAtomicReference -> Synchronization::LockableObject
Synchronization::LockableObject -> MutexLockableObject, JRubyLockableObject, MonitorLockableObject
MutexLockableObject -> AbstractLockableObject
AbstractLockableObject -> Synchronization::Object
2 changes: 1 addition & 1 deletion docs-source/actor/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
input_paths.each_with_index do |input_path, i|

pid = fork do
require File.join(root, 'init.rb')
require_relative 'init'

begin
output_path = input_path.gsub /\.in\.rb$/, '.out.rb'
Expand Down
4 changes: 2 additions & 2 deletions docs-source/tvar.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ is first read or written. If it cannot lock a `TVar` it aborts and retries.
There is no contention manager so competing transactions may retry eternally.

```ruby
require 'concurrent-ruby'
require 'concurrent'

v1 = Concurrent::TVar.new(0)
v2 = Concurrent::TVar.new(0)
Expand Down Expand Up @@ -60,7 +60,7 @@ However, the inconsistent reads are detected correctly at commit time. This
means the script below will always print `[2000000, 200000]`.

```ruby
require 'concurrent-ruby'
require 'concurrent'

v1 = Concurrent::TVar.new(0)
v2 = Concurrent::TVar.new(0)
Expand Down
4 changes: 2 additions & 2 deletions examples/benchmark_map.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "benchmark"
require "concurrent"
require 'benchmark'
require 'concurrent'

hash = {}
map = Concurrent::Map.new
Expand Down
2 changes: 1 addition & 1 deletion examples/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
input_paths.each_with_index do |input_path, i|

pid = fork do
require_relative 'init.rb'
require_relative 'init'

begin
output_path = input_path.gsub /\.in\.rb$/, '.out.rb'
Expand Down
2 changes: 2 additions & 0 deletions lib/concurrent-ruby-edge/concurrent/actor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# NOTE: finer grained than require 'concurrent/actor' not supported

require 'concurrent/configuration'
require 'concurrent/executor/serialized_execution'
require 'concurrent/synchronization'
Expand Down
2 changes: 2 additions & 0 deletions lib/concurrent-ruby-edge/concurrent/edge/cancellation.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'concurrent/concern/deprecation'
require 'concurrent/synchronization'
require 'concurrent/promises'

module Concurrent

Expand Down
2 changes: 2 additions & 0 deletions lib/concurrent-ruby-edge/concurrent/edge/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/synchronization/object'

# @!macro warn.edge
module Concurrent
module Promises
Expand Down
8 changes: 8 additions & 0 deletions lib/concurrent-ruby-edge/concurrent/edge/erlang_actor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
require 'set'
require 'concurrent/atomic/count_down_latch'
require 'concurrent/concern/logging'
require 'concurrent/edge/channel'
require 'concurrent/errors'
require 'concurrent/promises'
require 'concurrent/synchronization/object'

module Concurrent

# This module provides actor abstraction that has same behaviour as Erlang actor.
Expand Down
2 changes: 2 additions & 0 deletions lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/synchronization/object'

module Concurrent

# @!visibility private
Expand Down
5 changes: 5 additions & 0 deletions lib/concurrent-ruby-edge/concurrent/edge/processing_actor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
require 'concurrent/synchronization/object'
require 'concurrent/promises'
require 'concurrent/edge/channel'


module Concurrent

# A new implementation of actor which also simulates the process, therefore it can be used
Expand Down
4 changes: 4 additions & 0 deletions lib/concurrent-ruby-edge/concurrent/edge/throttle.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
require 'concurrent/edge/lock_free_queue'
require 'concurrent/promises'
require 'concurrent/synchronization/object'

module Concurrent
# A tool managing concurrency level of tasks.
# The maximum capacity is set in constructor.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require 'concurrent/synchronization/object'
require 'concurrent/executor/executor_service'

module Concurrent

# A delegating executor which modifies each task with arguments
Expand Down
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/event.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'thread'
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'thread'
require 'concurrent/atomic/atomic_reference'
require 'concurrent/atomic/atomic_fixnum'
require 'concurrent/errors'
require 'concurrent/synchronization'
require 'concurrent/atomic/thread_local_var'
Expand Down
2 changes: 2 additions & 0 deletions lib/concurrent-ruby/concurrent/concern/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def log(level, progname, message = nil, &block)
logger = if defined?(@logger) && @logger
@logger
else
# TODO this warns, need to find a better fix
require 'concurrent/configuration' unless Concurrent.respond_to? :global_logger
Concurrent.global_logger
end
logger.call level, progname, message, &block
Expand Down
1 change: 1 addition & 0 deletions lib/concurrent-ruby/concurrent/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'concurrent/concern/logging'
require 'concurrent/concern/deprecation'
require 'concurrent/executor/immediate_executor'
require 'concurrent/executor/fixed_thread_pool'
require 'concurrent/executor/cached_thread_pool'
require 'concurrent/utility/processor_counter'

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/delay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def initialize(opts = {}, &block)

# Return the value this object represents after applying the options
# specified by the `#set_deref_options` method. If the delayed operation
# raised an exception this method will return nil. The execption object
# raised an exception this method will return nil. The exception object
# can be accessed via the `#reason` method.
#
# @param [Numeric] timeout the maximum number of seconds to wait
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if Concurrent.on_jruby?
require 'concurrent/utility/engine'

if Concurrent.on_jruby?
require 'concurrent/errors'
require 'concurrent/utility/engine'
require 'concurrent/executor/abstract_executor_service'

module Concurrent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'concurrent/atomics'
require 'concurrent/atomic/atomic_boolean'
require 'concurrent/atomic/atomic_fixnum'
require 'concurrent/atomic/event'
require 'concurrent/executor/executor_service'

module Concurrent
Expand Down
1 change: 1 addition & 0 deletions lib/concurrent-ruby/concurrent/ivar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'concurrent/collection/copy_on_write_observer_set'
require 'concurrent/concern/obligation'
require 'concurrent/concern/observable'
require 'concurrent/executor/safe_task_executor'
require 'concurrent/synchronization'

module Concurrent
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/promise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module Concurrent
# Start by requiring promises
#
# ```ruby
# require 'concurrent'
# require 'concurrent/promise'
# ```
#
# Then create one
Expand Down
1 change: 1 addition & 0 deletions lib/concurrent-ruby/concurrent/promises.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'concurrent/atomic/atomic_boolean'
require 'concurrent/atomic/atomic_fixnum'
require 'concurrent/collection/lock_free_stack'
require 'concurrent/configuration'
require 'concurrent/errors'
require 'concurrent/re_include'

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/scheduled_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module Concurrent
#
# @example Basic usage
#
# require 'concurrent'
# require 'concurrent/scheduled_task'
# require 'csv'
# require 'open-uri'
#
Expand Down
13 changes: 0 additions & 13 deletions lib/concurrent-ruby/concurrent/synchronization.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
require 'concurrent/utility/native_extension_loader' # load native parts first

require 'concurrent/utility/engine'

require 'concurrent/synchronization/abstract_object'
require 'concurrent/synchronization/mri_object'
require 'concurrent/synchronization/jruby_object'
require 'concurrent/synchronization/truffleruby_object'
require 'concurrent/synchronization/object'
require 'concurrent/synchronization/volatile'

require 'concurrent/synchronization/abstract_lockable_object'
require 'concurrent/synchronization/mutex_lockable_object'
require 'concurrent/synchronization/jruby_lockable_object'

require 'concurrent/synchronization/lockable_object'

require 'concurrent/synchronization/condition'
require 'concurrent/synchronization/lock'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require 'concurrent/utility/monotonic_time'
require 'concurrent/synchronization/object'

module Concurrent
module Synchronization

Expand Down Expand Up @@ -34,7 +37,7 @@ def ns_wait_until(timeout = nil, &condition)
if timeout
wait_until = Concurrent.monotonic_time + timeout
loop do
now = Concurrent.monotonic_time
now = Concurrent.monotonic_time
condition_result = condition.call
return condition_result if now >= wait_until || condition_result
ns_wait wait_until - now
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/utility/engine'

module Concurrent
module Synchronization

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
require 'concurrent/utility/engine'
require 'concurrent/synchronization/abstract_lockable_object'
require 'concurrent/synchronization/mutex_lockable_object'
require 'concurrent/synchronization/jruby_lockable_object'

module Concurrent
module Synchronization

Expand Down
5 changes: 5 additions & 0 deletions lib/concurrent-ruby/concurrent/synchronization/object.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
require 'concurrent/synchronization/abstract_object'
require 'concurrent/synchronization/mri_object'
require 'concurrent/synchronization/jruby_object'
require 'concurrent/synchronization/truffleruby_object'

require 'concurrent/synchronization/safe_initialization'
require 'concurrent/synchronization/volatile'
require 'concurrent/atomic/atomic_reference'
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
3 changes: 3 additions & 0 deletions spec/concurrent/atom_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require_relative 'concern/observable_shared'
require 'concurrent/atom'
require 'concurrent/atomic/count_down_latch'
require 'concurrent/atomic/atomic_fixnum'

module Concurrent

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
2 changes: 2 additions & 0 deletions spec/concurrent/atomic/atomic_reference_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/atomic/atomic_reference'

RSpec.shared_examples :atomic_reference do

specify :test_construct do
Expand Down
2 changes: 2 additions & 0 deletions spec/concurrent/atomic/count_down_latch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/atomic/count_down_latch'

RSpec.shared_examples :count_down_latch do

let(:latch) { described_class.new(3) }
Expand Down
4 changes: 4 additions & 0 deletions spec/concurrent/atomic/cyclic_barrier_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
require 'concurrent/atomic/cyclic_barrier'
require 'concurrent/atomic/count_down_latch'
require 'concurrent/atomic/atomic_fixnum'

module Concurrent

RSpec.describe CyclicBarrier do
Expand Down
3 changes: 3 additions & 0 deletions spec/concurrent/atomic/event_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require 'concurrent/atomic/event'
require 'concurrent/atomic/count_down_latch'

module Concurrent

RSpec.describe Event do
Expand Down
4 changes: 4 additions & 0 deletions spec/concurrent/atomic/read_write_lock_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
require 'concurrent/atomic/read_write_lock'
require 'concurrent/atomic/count_down_latch'
require 'concurrent/atomic/atomic_boolean'

module Concurrent

RSpec.describe ReadWriteLock do
Expand Down
5 changes: 5 additions & 0 deletions spec/concurrent/atomic/reentrant_read_write_lock_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
require 'concurrent/utility/engine'
require 'concurrent/atomic/reentrant_read_write_lock'
require 'concurrent/atomic/count_down_latch'
require 'concurrent/atomic/atomic_boolean'

unless Concurrent.on_jruby?

# NOTE: These tests depend heavily on the private/undocumented
Expand Down
Loading

0 comments on commit 8eea936

Please sign in to comment.