File: test.rake

package info (click to toggle)
jruby 1.7.26-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 84,572 kB
  • sloc: ruby: 669,910; java: 253,056; xml: 35,152; ansic: 9,187; yacc: 7,267; cpp: 5,244; sh: 1,036; makefile: 345; jsp: 48; tcl: 40
file content (197 lines) | stat: -rw-r--r-- 6,357 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
require 'rake/testtask'

desc "Alias for spec:ci"
task :spec => "spec:ci"

desc "Alias for test:short"
task :test => "test:short"

desc "Alias for test:short19"
task :test19 => "test:short19"

desc "Alias for test:short18"
task :test18 => "test:short18"

namespace :test do
  desc "Compile test code"
  task :compile do
    sh "javac -cp lib/jruby.jar:test/target/junit.jar -d test/target/test-classes #{Dir['spec/java_integration/fixtures/**/*.java'].to_a.join(' ')}"
  end

  short_tests_18 = ['jruby', 'mri', 'rubicon']
  short_tests_19 = short_tests_18.map {|test| test + "19"}
  short_tests = short_tests_18 + short_tests_19
  long_tests_18 = short_tests_18 + ['spec:ji', 'spec:compiler', 'spec:ffi', 'spec:regression']
  long_tests_19 = long_tests_18.map {|test| test + "19"} + ['spec:profiler19']
  slow_tests = ['test:slow', 'test:objectspace']
  long_tests = ['test:tracing'] + long_tests_18 + long_tests_19 + slow_tests
  all_tests_18 = long_tests_18.map {|test| test + ':all'}
  all_tests_19 = long_tests_19.map {|test| test + ':all'}
  all_tests = all_tests_18 + all_tests_19 + slow_tests

  desc "Run the short suite: #{short_tests.inspect}"
  task :short => [:compile, *short_tests]

  desc "Run the short 1.9 suite: #{short_tests_19.inspect}"
  task :short19 => [:compile, *short_tests_19]

  desc "Run the short 1.8 suite: #{short_tests_18.inspect}"
  task :short18 => [:compile, *short_tests_18]

  desc "Run the long suite: #{long_tests.inspect}"
  task :long => [:compile, *long_tests]

  desc "Run the long 1.9 suite: #{long_tests_19.inspect}"
  task :long19 => [:compile, *long_tests_19]

  desc "Run the long 1.8 suite: #{long_tests_18.inspect}"
  task :long18 => [:compile, *long_tests_18]

  desc "Run the comprehensive suite: #{all_tests}"
  task :all => [:compile, *all_tests]

  desc "Run the comprehensive 1.9 suite: #{all_tests_19}"
  task :all19 => [:compile, *all_tests_19]

  desc "Run the comprehensive 1.8 suite: #{all_tests_18}"
  task :all18 => [:compile, *all_tests_18]

  task :rake_targets => long_tests
  
  task :extended do
    # cause unit tests to run
    sh 'mvn -q -Ptest test'
    
    # run Ruby integration tests
    Rake::Task["test:rake_targets"].invoke
  end

  task :dist do
    # run builds and test for dist artifacts
    sh 'mvn -Pdist clean install' or fail 'mvn -Pdist failed'
    sh 'mvn -Pcomplete clean install' or fail 'mvn -Pcomplete failed'
    sh 'mvn -Pmain clean install' or fail 'mvn -Pmain failed'
    sh 'mvn -Pjruby-jars clean install' or fail 'mvn -Pjruby-jars failed'
    sh 'mvn -Pgems clean install' or fail 'mvn -Pgems failed'
    sh 'mvn -Pall clean install' or fail 'mvn -Pall failed'
  end

  desc "Run tracing tests"
  task :tracing do
    Rake::TestTask.new('test:tracing') do |t|
      t.pattern = 'test/tracing/test_*.rb'
      t.verbose = true
      t.ruby_opts << '-J-ea'
      t.ruby_opts << '--debug'
      t.ruby_opts << '--1.8'
    end
  end
  
  compile_flags = {
    :default => :int,
    :int => ["-X-C"],
    :jit => ["-Xjit.threshold=0", "-J-XX:MaxPermSize=256M"],
    :aot => ["-X+C", "-J-XX:MaxPermSize=256M"],
    :ir_int => ["-X-CIR"],
    :all => [:int, :jit, :aot]
  }

  def files_in_file(filename)
    files = []
    File.readlines(filename).each do |line|
      filename = "test/#{line.chomp}.rb"
      files << filename if File.exist? filename
    end
    files
  end
  
  permute_tests(:mri19, compile_flags) do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/mri.1.9.index'
    ENV['EXCLUDE_DIR'] = 'test/externals/ruby1.9/excludes'
    t.ruby_opts << '-J-Dfile.encoding=UTF-8' if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
    t.ruby_opts << '-J-ea' << '--1.9' 
    t.ruby_opts << '-I test/externals/ruby1.9'
    t.ruby_opts << '-I test/externals/ruby1.9/ruby'
    t.ruby_opts << '-r ./test/ruby19_env.rb'
    t.ruby_opts << '-r minitest'
    t.ruby_opts << '-r minitest/excludes'
  end
  
  permute_tests(:mri, compile_flags) do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/mri.1.8.index'
    t.ruby_opts << '-J-ea' << '--1.8'
  end

  permute_tests(:jruby19, compile_flags, 'test:compile') do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/jruby.1.9.index'
    t.ruby_opts << '-J-ea' << '--1.9'
    t.ruby_opts << '-J-cp test:test/target/test-classes:core/target/test-classes'
  end

  permute_tests(:jruby, compile_flags, 'test:compile') do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/jruby.1.8.index'
    t.ruby_opts << '-J-ea' << '--1.8'
    t.ruby_opts << '-J-cp test:test/target/test-classes:core/target/test-classes'
  end

  permute_tests(:rubicon19, compile_flags) do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/rubicon.1.9.index'
    t.ruby_opts << '-J-ea' << '--1.9' << '-X+O'
  end

  permute_tests(:rubicon, compile_flags) do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/rubicon.1.8.index'
    t.ruby_opts << '-J-ea' << '--1.8' << '-X+O'
  end

  permute_tests(:slow, compile_flags) do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/slow.index'
    t.ruby_opts << '-J-ea' << '--1.8'
    t.ruby_opts << '-J-cp target/test-classes'
  end

  permute_tests(:objectspace, compile_flags) do |t|
    t.verbose = true
    t.test_files = files_in_file 'test/objectspace.index'
    t.ruby_opts << '-J-ea' << '--1.8' << '-X+O'
  end
  
  def junit(options)
    cp = options[:classpath] or raise "junit tasks must have classpath"
    test = options[:test] or raise "junit tasks must have test"
    
    cmd = "#{ENV_JAVA['java.home']}/bin/java -cp #{cp.join(File::PATH_SEPARATOR)} -Djruby.compat.mode=1.8 junit.textui.TestRunner #{test}"
    
    puts cmd
    system cmd
  end
  
  namespace :junit do
    test_class_path = [
      "target/junit.jar",
      "target/livetribe-jsr223.jar",
      "target/bsf.jar",
      "target/commons-logging.jar",
      "lib/jruby.jar",
      "target/test-classes",
      "test/requireTest.jar",
      "test"
    ]
    
    desc "Run the main JUnit test suite"
    task :main => 'test:compile' do
      junit :classpath => test_class_path, :test => "org.jruby.test.MainTestSuite", :maxmemory => '512M' do
        env :key => "JRUBY_OPTS", :value => "--1.8"
        sysproperty :key => 'jruby.compat.version', :value => '1.8'
        jvmarg :line => '-ea'
      end
    end
  end
end