|
3 | 3 |
|
4 | 4 | describe "JRuby native launcher" do
|
5 | 5 | it "should run org.jruby.Main" do
|
6 |
| - jruby_launcher_args("").last.should == "org/jruby/Main" |
| 6 | + expect(jruby_launcher_args("").last).to eq "org/jruby/Main" |
7 | 7 | end
|
8 | 8 |
|
9 | 9 | it "should pass unrecognized arguments to JRuby" do
|
10 |
| - jruby_launcher_args("-J-Dsome.option -v --help")[-3..-1].should == ["org/jruby/Main", "-v", "--help"] |
| 10 | + expect(jruby_launcher_args("-J-Dsome.option -v --help")[-3..-1]).to contain_exactly("org/jruby/Main", "-v", "--help") |
11 | 11 | end
|
12 | 12 |
|
13 | 13 | it "should print help message" do
|
14 | 14 | args = jruby_launcher_args("-Xhelp 2>&1")
|
15 |
| - args.select {|l| l =~ /JRuby Launcher usage/}.should_not be_empty |
16 |
| - args.should include("-X") |
| 15 | + expect(args.select {|l| l =~ /JRuby Launcher usage/}).not_to be_empty |
| 16 | + expect(args).to include("-X") |
17 | 17 | args = jruby_launcher_args("-X 2>&1")
|
18 |
| - args.detect {|l| l =~ /JRuby Launcher usage/}.should_not be_empty |
19 |
| - args.should include("-X") |
| 18 | + expect(args.detect {|l| l =~ /JRuby Launcher usage/}).not_to be_empty |
| 19 | + expect(args).to include("-X") |
20 | 20 | end
|
21 | 21 |
|
22 | 22 | it "should use $JAVACMD when JAVACMD is specified" do
|
23 | 23 | with_environment "JAVACMD" => File.join("jato") do
|
24 | 24 | if windows?
|
25 |
| - jruby_launcher_args("-v 2>&1").join.should =~ %r{jato} |
| 25 | + expect(jruby_launcher_args("-v 2>&1").join).to match %r{jato} |
26 | 26 | else
|
27 |
| - jruby_launcher_args("-v").first.should == File.join("jato") |
| 27 | + expect(jruby_launcher_args("-v").first).to eq File.join("jato") |
28 | 28 | end
|
29 | 29 | end
|
30 | 30 | end
|
31 | 31 |
|
32 | 32 | it "should use $JAVA_HOME/bin/java when JAVA_HOME is specified" do
|
33 | 33 | with_environment "JAVA_HOME" => File.join("some", "java", "home") do
|
34 | 34 | if windows?
|
35 |
| - jruby_launcher_args("-v 2>&1").join.should =~ %r{some/java/home} |
| 35 | + expect(jruby_launcher_args("-v 2>&1").join).to match %r{some/java/home} |
36 | 36 | else
|
37 |
| - jruby_launcher_args("-v").first.should == File.join("some", "java", "home", "bin", "java") |
| 37 | + expect(jruby_launcher_args("-v").first).to eq File.join("some", "java", "home", "bin", "java") |
38 | 38 | end
|
39 | 39 | end
|
40 | 40 | end
|
41 | 41 |
|
42 | 42 | it "should use -Xjdkhome argument above JAVA_HOME" do
|
43 | 43 | with_environment "JAVA_HOME" => File.join("env", "java", "home") do
|
44 | 44 | if windows?
|
45 |
| - jruby_launcher_args("-Xjdkhome some/java/home 2>&1").join.should =~ %r{some/java/home} |
| 45 | + expect(jruby_launcher_args("-Xjdkhome some/java/home 2>&1").join).to match %r{some/java/home} |
46 | 46 | else
|
47 |
| - jruby_launcher_args("-Xjdkhome some/java/home").first.should == File.join("some", "java", "home", "bin", "java") |
| 47 | + expect(jruby_launcher_args("-Xjdkhome some/java/home").first).to eq File.join("some", "java", "home", "bin", "java") |
48 | 48 | end
|
49 | 49 | end
|
50 | 50 | end
|
51 | 51 |
|
52 | 52 | it "should drop the backslashes at the end of JAVA_HOME" do
|
53 | 53 | with_environment "JAVA_HOME" => File.join("some", "java", "home\\\\") do
|
54 | 54 | if windows?
|
55 |
| - jruby_launcher_args("").join.should =~ %r{some/java/home} |
| 55 | + expect(jruby_launcher_args("").join).to match %r{some/java/home} |
56 | 56 | else
|
57 |
| - jruby_launcher_args("").first.should == File.join("some", "java", "home", "bin", "java") |
| 57 | + expect(jruby_launcher_args("").first).to eq File.join("some", "java", "home", "bin", "java") |
58 | 58 | end
|
59 | 59 | end
|
60 | 60 | end
|
61 | 61 |
|
62 | 62 | it "should complain about a missing log argument" do
|
63 |
| - jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/ |
64 |
| - jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/ |
| 63 | + expect(jruby_launcher("-Xtrace 2>&1")).to match /Argument is missing for "-Xtrace"/ |
| 64 | + expect(jruby_launcher("-Xtrace -- 2>&1")).to match /Argument is missing for "-Xtrace"/ |
65 | 65 | end
|
66 | 66 |
|
67 | 67 | it "should complain about a missing jdkhome argument" do
|
68 |
| - jruby_launcher("-Xjdkhome 2>&1").should =~ /Argument is missing/ |
69 |
| - jruby_launcher("-Xjdkhome -- 2>&1").should =~ /Argument is missing/ |
| 68 | + expect(jruby_launcher("-Xjdkhome 2>&1")).to match /Argument is missing/ |
| 69 | + expect(jruby_launcher("-Xjdkhome -- 2>&1")).to match /Argument is missing/ |
70 | 70 | end
|
71 | 71 |
|
72 | 72 | it "should complain about a missing classpath append argument" do
|
73 |
| - jruby_launcher("-Xcp:a 2>&1").should =~ /Argument is missing/ |
74 |
| - jruby_launcher("-Xcp:a -- 2>&1").should =~ /Argument is missing/ |
| 73 | + expect(jruby_launcher("-Xcp:a 2>&1")).to match /Argument is missing/ |
| 74 | + expect(jruby_launcher("-Xcp:a -- 2>&1")).to match /Argument is missing/ |
75 | 75 | end
|
76 | 76 |
|
77 | 77 | it "should run nailgun server with --ng-server option" do
|
78 |
| - jruby_launcher_args("--ng-server").last.should == "com/martiansoftware/nailgun/NGServer" |
| 78 | + expect(jruby_launcher_args("--ng-server").last).to eq "com/martiansoftware/nailgun/NGServer" |
79 | 79 | end
|
80 | 80 |
|
81 | 81 | it "should run nailgun client with --ng option" do
|
82 |
| - jruby_launcher_args('--ng -e "puts 1"').should == ["org.jruby.util.NailMain", "-e", "puts 1"] |
| 82 | + expect(jruby_launcher_args('--ng -e "puts 1"')).to eq ["org.jruby.util.NailMain", "-e", "puts 1"] |
83 | 83 | end
|
84 | 84 |
|
85 | 85 | it "should handle -J JVM options" do
|
86 |
| - jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2").should include("-Darg1=value1", "-Darg2=value2") |
| 86 | + expect(jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2")).to include("-Darg1=value1", "-Darg2=value2") |
87 | 87 | end
|
88 | 88 |
|
89 | 89 | it "should pass -Xprop.erty=value as -J-Djruby.prop.erty=value" do
|
90 |
| - jruby_launcher_args("-Xprop.erty=value").should include("-Djruby.prop.erty=value") |
| 90 | + expect(jruby_launcher_args("-Xprop.erty=value")).to include("-Djruby.prop.erty=value") |
91 | 91 | end
|
92 | 92 |
|
93 | 93 | it "should pass -Xproperties as --properties" do
|
94 |
| - jruby_launcher_args("-Xproperties").should include("--properties") |
| 94 | + expect(jruby_launcher_args("-Xproperties")).to include("--properties") |
95 | 95 | end
|
96 | 96 |
|
97 | 97 | it "should default to 500m max heap" do
|
98 |
| - jruby_launcher_args("").should include("-Xmx500m") |
| 98 | + expect(jruby_launcher_args("")).to include("-Xmx500m") |
99 | 99 | end
|
100 | 100 |
|
101 | 101 | it "should allow max heap to be overridden" do
|
102 |
| - jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m") |
| 102 | + expect(jruby_launcher_args("-J-Xmx256m")).to include("-Xmx256m") |
103 | 103 | end
|
104 | 104 |
|
105 | 105 | it "should default to 2048k max stack" do
|
106 |
| - jruby_launcher_args("").should include("-Xss2048k") |
| 106 | + expect(jruby_launcher_args("")).to include("-Xss2048k") |
107 | 107 | end
|
108 | 108 |
|
109 | 109 | it "should allow max stack to be overridden" do
|
110 |
| - jruby_launcher_args("-J-Xss512k").should include("-Xss512k") |
| 110 | + expect(jruby_launcher_args("-J-Xss512k")).to include("-Xss512k") |
111 | 111 | end
|
112 | 112 |
|
113 | 113 | it "should add the contents of the CLASSPATH environment variable" do
|
114 | 114 | with_environment "CLASSPATH" => "some.jar" do
|
115 |
| - classpath_arg(jruby_launcher_args("")).should =~ /some.jar/ |
| 115 | + expect(classpath_arg(jruby_launcher_args(""))).to match /some.jar/ |
116 | 116 | end
|
117 | 117 | end
|
118 | 118 |
|
119 | 119 | it "should add the classpath elements in proper order" do
|
120 | 120 | s = File::PATH_SEPARATOR
|
121 | 121 | with_environment "CLASSPATH" => "some-env.jar" do
|
122 | 122 | args = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar")
|
123 |
| - classpath_arg(args).should =~ /some.jar.*#{s}some-env.jar#{s}some-other.jar/ |
| 123 | + expect(classpath_arg(args)).to match /some.jar.*#{s}some-env.jar#{s}some-other.jar/ |
124 | 124 | end
|
125 | 125 | end
|
126 | 126 |
|
127 | 127 | it "should use the --server compiler" do
|
128 |
| - jruby_launcher_args("--server").should include("-server") |
| 128 | + expect(jruby_launcher_args("--server")).to include("-server") |
129 | 129 | end
|
130 | 130 |
|
131 | 131 | it "should use the --client compiler" do
|
132 |
| - jruby_launcher_args("--client").should include("-client") |
| 132 | + expect(jruby_launcher_args("--client")).to include("-client") |
133 | 133 | end
|
134 | 134 |
|
135 | 135 | it "should set the JMX settings when --manage is present" do
|
136 |
| - jruby_launcher_args("--manage").should include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true") |
| 136 | + expect(jruby_launcher_args("--manage")).to include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true") |
137 | 137 | end
|
138 | 138 |
|
139 | 139 | it "should set the headless flag when --headless is present" do
|
140 |
| - jruby_launcher_args("--headless").should include("-Djava.awt.headless=true") |
| 140 | + expect(jruby_launcher_args("--headless")).to include("-Djava.awt.headless=true") |
141 | 141 | end
|
142 | 142 |
|
143 | 143 | it "should pass -Xprof when --sample is present" do
|
144 |
| - jruby_launcher_args("--sample").should include("-Xprof") |
| 144 | + expect(jruby_launcher_args("--sample")).to include("-Xprof") |
145 | 145 | end
|
146 | 146 |
|
147 | 147 | it "should stop argument processing when a -- is seen" do
|
148 |
| - jruby_launcher_args("-- -Xhelp -Xtrace --headless").should include("-Xhelp", "-Xtrace", "--headless") |
| 148 | + expect(jruby_launcher_args("-- -Xhelp -Xtrace --headless")).to include("-Xhelp", "-Xtrace", "--headless") |
149 | 149 | end
|
150 | 150 |
|
151 | 151 | # JRUBY-4151
|
152 | 152 | it "should properly handle single quotes" do
|
153 |
| - jruby_launcher_args("-e 'ABC DEF'").should include("ABC DEF") |
| 153 | + expect(jruby_launcher_args("-e 'ABC DEF'")).to include("ABC DEF") |
154 | 154 | end
|
155 | 155 |
|
156 | 156 | # JRUBY-4581
|
157 | 157 | it "should prepend JRUBY_OPTS to the start of the argument list to process" do
|
158 | 158 | with_environment "JRUBY_OPTS" => "--server -J-Dsome.key=val -rubygems" do
|
159 |
| - jruby_launcher_args("-e 'ABC DEF'").should include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF") |
| 159 | + expect(jruby_launcher_args("-e 'ABC DEF'")).to include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF") |
160 | 160 | end
|
161 | 161 | end
|
162 | 162 |
|
163 | 163 | # JRUBY-4611
|
164 | 164 | it "stops argument processing on first non-option argument" do
|
165 |
| - jruby_launcher_args("foo.rb --sample")[-2..-1].should == ["foo.rb", "--sample"] |
| 165 | + expect(jruby_launcher_args("foo.rb --sample")[-2..-1]).to eq ["foo.rb", "--sample"] |
166 | 166 | end
|
167 | 167 |
|
168 | 168 | # JRUBY-4608
|
169 | 169 | if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
170 | 170 | it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
|
171 |
| - jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8") |
| 171 | + expect(jruby_launcher_args("-e true")).to include("-Dfile.encoding=UTF-8") |
172 | 172 | with_environment "JAVA_ENCODING" => "MacRoman" do
|
173 |
| - jruby_launcher_args("-e true").should_not include("-Dfile.encoding=UTF-8") |
| 173 | + expect(jruby_launcher_args("-e true")).not_to include("-Dfile.encoding=UTF-8") |
174 | 174 | end
|
175 | 175 | end
|
176 | 176 | end
|
177 | 177 |
|
178 | 178 | it "does not crash on empty args" do
|
179 |
| - jruby_launcher_args("-e ''").should include("-e") |
180 |
| - jruby_launcher("-Xtrace '' 2>&1").should =~ /-Xtrace/ |
181 |
| - jruby_launcher("-Xjdkhome '' 2>&1").should =~ /-Xjdkhome/ |
| 179 | + expect(jruby_launcher_args("-e ''")).to include("-e") |
| 180 | + expect(jruby_launcher("-Xtrace '' 2>&1")).to match /-Xtrace/ |
| 181 | + expect(jruby_launcher("-Xjdkhome '' 2>&1")).to match /-Xjdkhome/ |
182 | 182 | end
|
183 | 183 |
|
184 | 184 | # JRUBY-4706
|
185 | 185 | it "should put JRuby on regular classpath when -Xnobootclasspath is used" do
|
186 | 186 | args = jruby_launcher_args("-e true")
|
187 |
| - args.grep(/Xbootclasspath/).should_not be_empty |
| 187 | + expect(args.grep(/Xbootclasspath/)).not_to be_empty |
188 | 188 | args = jruby_launcher_args("-Xnobootclasspath -e true")
|
189 |
| - args.grep(/Xbootclasspath/).should be_empty |
| 189 | + expect(args.grep(/Xbootclasspath/)).to be_empty |
190 | 190 | end
|
191 | 191 |
|
192 | 192 | it "should put JRuby on regular classpath when VERIFY_JRUBY is set" do
|
193 | 193 | with_environment "VERIFY_JRUBY" => "true" do
|
194 | 194 | args = jruby_launcher_args("-e true")
|
195 |
| - args.grep(/Xbootclasspath/).should be_empty |
| 195 | + expect(args.grep(/Xbootclasspath/)).to be_empty |
196 | 196 | end
|
197 | 197 | end
|
198 | 198 |
|
199 | 199 | # JRUBY-4709
|
200 | 200 | it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
|
201 |
| - classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true")).should =~ |
202 |
| - if windows? |
203 |
| - /;$/ |
204 |
| - else |
205 |
| - /:$/ |
206 |
| - end |
| 201 | + end_of_path_pattern = if windows? |
| 202 | + /;$/ |
| 203 | + else |
| 204 | + /:$/ |
| 205 | + end |
| 206 | + |
| 207 | + expect(classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true"))).to match end_of_path_pattern |
207 | 208 | end
|
208 | 209 |
|
209 | 210 | # JRUBY-6016
|
210 | 211 | it "should honor JAVA_MEM" do
|
211 | 212 | with_environment "JAVA_MEM" => "-Xmx768m" do
|
212 |
| - jruby_launcher_args("").should include("-Xmx768m") |
| 213 | + expect(jruby_launcher_args("")).to include("-Xmx768m") |
213 | 214 | end
|
214 | 215 | end
|
215 | 216 |
|
216 | 217 | it "should honor JAVA_STACK" do
|
217 | 218 | with_environment "JAVA_STACK" => "-Xss3072k" do
|
218 |
| - jruby_launcher_args("").should include("-Xss3072k") |
| 219 | + expect(jruby_launcher_args("")).to include("-Xss3072k") |
219 | 220 | end
|
220 | 221 | end
|
221 | 222 |
|
222 | 223 | it "should honor JRUBY_HOME" do
|
223 | 224 | with_environment "JRUBY_HOME" => "/tmp" do
|
224 |
| - jruby_launcher_args("").should include("-Djruby.home=/tmp") |
| 225 | + expect(jruby_launcher_args("")).to include("-Djruby.home=/tmp") |
225 | 226 | end
|
226 | 227 | end
|
227 | 228 |
|
|
240 | 241 |
|
241 | 242 | it "should add jruby.jar to the bootclasspath" do
|
242 | 243 | with_environment "JRUBY_HOME" => jruby_home do
|
243 |
| - jruby_launcher_args("").should include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar") |
| 244 | + expect(jruby_launcher_args("")).to include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar") |
244 | 245 | end
|
245 | 246 | end
|
246 | 247 | end
|
247 | 248 |
|
248 | 249 | it "should place user-supplied options after default options" do
|
249 | 250 | args = jruby_launcher_args("-J-Djruby.home=/tmp")
|
250 | 251 | home_args = args.select {|x| x =~ /^-Djruby\.home/ }
|
251 |
| - home_args.length.should == 2 |
252 |
| - home_args.last.should == "-Djruby.home=/tmp" |
| 252 | + expect(home_args.length).to eq 2 |
| 253 | + expect(home_args.last).to eq "-Djruby.home=/tmp" |
253 | 254 | end
|
254 | 255 |
|
255 | 256 | it "should print the version" do
|
256 |
| - jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/ |
| 257 | + expect(jruby_launcher("-Xversion 2>&1")).to match /Launcher Version #{JRubyLauncher::VERSION}/ |
257 | 258 | end
|
258 | 259 |
|
259 | 260 | it "should not crash on format-strings" do
|
260 |
| - jruby_launcher_args("-e %s%s%s%s%s 2>&1").should include('-e', '%s%s%s%s%s') |
| 261 | + expect(jruby_launcher_args("-e %s%s%s%s%s 2>&1")).to include('-e', '%s%s%s%s%s') |
261 | 262 | end
|
262 | 263 | end
|
0 commit comments