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 12, 2023
1 parent 8a01381 commit f748148
Show file tree
Hide file tree
Showing 138 changed files with 386 additions and 162 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI
on: [push, pull_request]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
Expand All @@ -26,3 +29,17 @@ jobs:
bundler-cache: true
- name: Run tests
run: bundle exec rake ci

isolated:
name: "Test isolated"
runs-on: ubuntu-latest
env:
RUBYOPT: '-w'
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- run: bundle exec rake compile
- run: bundle exec rake spec:isolated
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
13 changes: 13 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ begin
desc 'executed in CI'
task :ci => [:compile, 'spec:ci']

desc 'run each spec file in a separate process to help find missing requires'
task 'spec:isolated' do
glob = "#{ENV['DIR'] || 'spec'}/**/*_spec.rb"
from = ENV['FROM']
env = { 'ISOLATED' => 'true' }
Dir[glob].each do |spec|
next if from and from != spec
from = nil if from == spec

sh env, 'rspec', spec
end
end

task :default => [:clobber, :compile, :spec]
rescue LoadError => e
puts 'RSpec is not installed, skipping test task definitions: ' + e.message
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
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
3 changes: 2 additions & 1 deletion lib/concurrent-ruby-edge/concurrent/actor.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# NOTE: finer grained than require 'concurrent/actor' not supported

require 'concurrent/configuration'
require 'concurrent/executor/serialized_execution'
require 'concurrent/synchronization'
require 'concurrent/edge/promises'

module Concurrent
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby-edge/concurrent/channel/tick.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/object'
require 'concurrent/utility/monotonic_time'

module Concurrent
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/object'
require 'concurrent/promises'

module Concurrent

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

# @!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
4 changes: 4 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,7 @@
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
3 changes: 2 additions & 1 deletion lib/concurrent-ruby/concurrent/agent.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require 'concurrent/configuration'
require 'concurrent/atomic/atomic_reference'
require 'concurrent/atomic/count_down_latch'
require 'concurrent/atomic/thread_local_var'
require 'concurrent/collection/copy_on_write_observer_set'
require 'concurrent/concern/observable'
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/atom.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'concurrent/atomic/atomic_reference'
require 'concurrent/collection/copy_on_notify_observer_set'
require 'concurrent/concern/observable'
require 'concurrent/synchronization'
require 'concurrent/synchronization/object'

# @!macro thread_safe_variable_comparison
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'concurrent/synchronization/object'

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/cyclic_barrier.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'
require 'concurrent/utility/native_integer'

module Concurrent
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,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'
require 'concurrent/utility/native_integer'

module Concurrent
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/atomic/mutex_semaphore.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'
require 'concurrent/utility/native_integer'

module Concurrent
Expand Down
3 changes: 2 additions & 1 deletion lib/concurrent-ruby/concurrent/atomic/read_write_lock.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'thread'
require 'concurrent/atomic/atomic_fixnum'
require 'concurrent/errors'
require 'concurrent/synchronization'
require 'concurrent/synchronization/object'
require 'concurrent/synchronization/lock'

module Concurrent

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require 'thread'
require 'concurrent/atomic/atomic_reference'
require 'concurrent/atomic/atomic_fixnum'
require 'concurrent/errors'
require 'concurrent/synchronization'
require 'concurrent/synchronization/object'
require 'concurrent/synchronization/lock'
require 'concurrent/atomic/thread_local_var'

module Concurrent
Expand Down
1 change: 0 additions & 1 deletion lib/concurrent-ruby/concurrent/atomic/semaphore.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'concurrent/atomic/mutex_semaphore'
require 'concurrent/synchronization'

module Concurrent

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent
module Collection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent
module Collection
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 @@ -3,6 +3,7 @@
require 'concurrent/errors'
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
4 changes: 2 additions & 2 deletions lib/concurrent-ruby/concurrent/delay.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'thread'
require 'concurrent/concern/obligation'
require 'concurrent/executor/immediate_executor'
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent

Expand Down 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 @@
require 'concurrent/errors'
require 'concurrent/concern/deprecation'
require 'concurrent/executor/executor_service'
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent

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,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'concurrent/errors'
require 'concurrent/concern/logging'
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,8 @@
require 'concurrent/atomics'
require 'concurrent/atomic/atomic_boolean'
require 'concurrent/atomic/atomic_fixnum'
require 'concurrent/atomic/event'
require 'concurrent/executor/executor_service'
require 'concurrent/executor/ruby_executor_service'

module Concurrent

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/immutable_struct.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'concurrent/synchronization/abstract_struct'
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent

Expand Down
3 changes: 2 additions & 1 deletion lib/concurrent-ruby/concurrent/ivar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
require 'concurrent/collection/copy_on_write_observer_set'
require 'concurrent/concern/obligation'
require 'concurrent/concern/observable'
require 'concurrent/synchronization'
require 'concurrent/executor/safe_task_executor'
require 'concurrent/synchronization/lockable_object'

module Concurrent

Expand Down
1 change: 0 additions & 1 deletion lib/concurrent-ruby/concurrent/map.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'thread'
require 'concurrent/constants'
require 'concurrent/synchronization'
require 'concurrent/utility/engine'

module Concurrent
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/maybe.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'concurrent/synchronization'
require 'concurrent/synchronization/object'

module Concurrent

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/mutable_struct.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'concurrent/synchronization/abstract_struct'
require 'concurrent/synchronization'
require 'concurrent/synchronization/lockable_object'

module Concurrent

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent-ruby/concurrent/mvar.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'concurrent/concern/dereferenceable'
require 'concurrent/synchronization'
require 'concurrent/synchronization/object'

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
Loading

0 comments on commit f748148

Please sign in to comment.