File: ruby-tests.rb

package info (click to toggle)
ruby-rspec 3.9.0c2e2m1s3-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,612 kB
  • sloc: ruby: 67,456; sh: 1,572; makefile: 98
file content (82 lines) | stat: -rw-r--r-- 2,089 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require 'fileutils'

$AUTOPKGTEST = ENV.include?("AUTOPKGTEST_TMP")

def banner(title, c = '∙')
  puts
  puts c * (title.length + 4)
  puts "%s %s %s" % [c, title, c]
  puts c * (title.length + 4)
  puts
end

def maybe_move_away(path)
  if $AUTOPKGTEST
    FileUtils::Verbose.mv(path, path + '.off')
    begin
      yield
    ensure
      FileUtils::Verbose.mv(path + '.off', path)
    end
  else
    yield
  end
end

def run(cmd)
  puts(cmd)
  maybe_move_away('lib') do
    system(cmd)
  end
end

arch = `dpkg --print-architecture`.strip

LIBS = %w{rspec-core rspec-expectations rspec-mocks rspec-support}

if $AUTOPKGTEST
  excludes_pattern = "debian/tests/excludes/{all,autopkgtest,%s}" % arch
else
  excludes_pattern = "debian/tests/excludes/{all,%s}" % arch

  ENV["PATH"] = [File.expand_path("rspec-core/exe"), ENV["PATH"]].join(':')
  puts "PATH=#{ENV['PATH']}"
  #  ________________________________________________________________________
  # /                                                                        \
  # | ALL THIS CAN BE REMOVED AFTER THE PREVIOUS VERSION OF RSPEC USING THE  |
  # | VENDOR LAYOUT IS NO LONGER THERE.                                      |
  # |                                                                        |
  rubylib = ENV.fetch('RUBYLIB', 'debian')
  LIBS.each do |lib|
    rubylib += ":" + File.expand_path(File.join(lib, 'lib'))
  end
  puts "RUBYLIB=#{rubylib}"
  ENV['RUBYLIB'] = rubylib
  # |                                                                        |
  # \________________________________________________________________________/



end

ENV['NO_COVERAGE'] = 'yes'

failed = []
LIBS.each do |lib|
  excludes = []
  Dir.glob(File.join(excludes_pattern, lib)).each do |f|
    excludes += File.readlines(f).map(&:strip)
  end
  banner lib

  FileUtils::Verbose.chdir(lib) do
    files = Dir['spec/**/*_spec.rb'] - excludes
    testcmd = '%s -S rspec %s' % [RbConfig.ruby, files.join(' ')]
    failed << lib unless run(testcmd)
  end
end

unless failed.empty?
  puts "Failed: %s" % failed.join(', ')
  exit(1)
end