File: require_all_files_separately.rb

package info (click to toggle)
ruby-concurrent 1.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,152 kB
  • sloc: ruby: 30,953; java: 6,128; ansic: 293; makefile: 26; sh: 19
file content (29 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
RSpec.describe 'Every file', if: ENV['ISOLATED'] do
  it 'can be required on its own' do
    root = File.expand_path('../..', __dir__)
    require_paths = []
    dirs = ["#{root}/lib/concurrent-ruby", "#{root}/lib/concurrent-ruby-edge"]
    dirs.each do |dir|
      Dir.glob("#{dir}/**/*.rb") do |file|
        require_path = file[dir.size + 1...-3]
        private_file = %w[ruby_ java_ jruby_ truffleruby_].any? { |prefix|
          File.basename(require_path).start_with?(prefix)
        }
        unless private_file
          require_paths << require_path
        end
      end
    end

    require_paths.each do |require_path|
      # An easy way to see the output and backtrace without RSpec formatting it
      # raise require_path unless system RbConfig.ruby, '-w', '-e', 'require ARGV.first', require_path

      # puts require_path
      out = IO.popen([RbConfig.ruby, '-w', '-e', 'require ARGV.first', require_path], err: [:child, :out], &:read)
      status = $?
      expect(out).to eq ""
      expect(status).to be_success
    end
  end
end