jruby-launcher 1.0.13-java → 1.0.14-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/argparser.cpp CHANGED
@@ -55,6 +55,7 @@ const char *ArgParser::OPT_JDK_HOME = "-Djdk.home=";
55
55
  const char *ArgParser::OPT_JRUBY_HOME = "-Djruby.home=";
56
56
  const char *ArgParser::OPT_JRUBY_COMMAND_NAME = "-Dsun.java.command=";
57
57
 
58
+ const char *ArgParser::OPT_CMDLINE_CLASS_PATH = "-cp";
58
59
  const char *ArgParser::OPT_CLASS_PATH = "-Djava.class.path=";
59
60
  const char *ArgParser::OPT_BOOT_CLASS_PATH = "-Xbootclasspath/a:";
60
61
 
@@ -65,7 +66,7 @@ const char *ArgParser::MAIN_CLASS = "org/jruby/Main";
65
66
  const char *ArgParser::DEFAULT_EXECUTABLE = "jruby";
66
67
 
67
68
  ArgParser::ArgParser()
68
- : separateProcess(false)
69
+ : separateProcess(true)
69
70
  , nailgunClient(false)
70
71
  , noBootClassPath(false)
71
72
  , printCommandLine(false)
@@ -433,9 +434,15 @@ void ArgParser::prepareOptions() {
433
434
  option += cmdName;
434
435
  javaOptions.push_back(option);
435
436
 
436
- option = OPT_CLASS_PATH;
437
- option += classPath;
438
- javaOptions.push_back(option);
437
+ // When launching a separate process, use '-cp' which expands embedded wildcards
438
+ if (separateProcess) {
439
+ javaOptions.push_back(OPT_CMDLINE_CLASS_PATH);
440
+ javaOptions.push_back(classPath);
441
+ } else {
442
+ option = OPT_CLASS_PATH;
443
+ option += classPath;
444
+ javaOptions.push_back(option);
445
+ }
439
446
 
440
447
  if (!bootClassPath.empty()) {
441
448
  option = OPT_BOOT_CLASS_PATH;
data/argparser.h CHANGED
@@ -19,6 +19,7 @@ protected:
19
19
  static const char *OPT_JRUBY_HOME;
20
20
  static const char *OPT_JRUBY_COMMAND_NAME;
21
21
 
22
+ static const char *OPT_CMDLINE_CLASS_PATH;
22
23
  static const char *OPT_CLASS_PATH;
23
24
  static const char *OPT_BOOT_CLASS_PATH;
24
25
 
@@ -1,3 +1,3 @@
1
1
  module JRubyLauncher
2
- VERSION = "1.0.13"
2
+ VERSION = "1.0.14"
3
3
  end
@@ -0,0 +1,7 @@
1
+ require 'rbconfig'
2
+
3
+ mf = File.read('Makefile')
4
+ mf = mf.gsub(/^BINDIR\s*=.*$/, "BINDIR = #{Config::CONFIG['bindir']}")
5
+ mf = mf.gsub(/^PREFIX\s*=.*$/, "PREFIX = #{File.dirname(Config::CONFIG['libdir'])}")
6
+ puts mf
7
+ File.open('Makefile', 'wb') {|f| f << mf}
@@ -0,0 +1,3 @@
1
+ module JRubyLauncher
2
+ VERSION = "1.0.13"
3
+ end
@@ -0,0 +1,4 @@
1
+ class Gem::ConfigFile
2
+ PLATFORM_DEFAULTS['install'] = '--no-rdoc --no-ri'
3
+ PLATFORM_DEFAULTS['update'] = '--no-rdoc --no-ri'
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'rbconfig'
2
+
3
+ mf = File.read('Makefile')
4
+ mf = mf.gsub(/^BINDIR\s*=.*$/, "BINDIR = #{Config::CONFIG['bindir']}")
5
+ mf = mf.gsub(/^PREFIX\s*=.*$/, "PREFIX = #{File.dirname(Config::CONFIG['libdir'])}")
6
+ puts mf
7
+ File.open('Makefile', 'wb') {|f| f << mf}
@@ -0,0 +1,3 @@
1
+ module JRubyLauncher
2
+ VERSION = "1.0.12"
3
+ end
@@ -0,0 +1,4 @@
1
+ class Gem::ConfigFile
2
+ PLATFORM_DEFAULTS['install'] = '--no-rdoc --no-ri'
3
+ PLATFORM_DEFAULTS['update'] = '--no-rdoc --no-ri'
4
+ end
@@ -0,0 +1,223 @@
1
+ require File.expand_path('../spec_helper.rb', __FILE__)
2
+ load File.expand_path('../../lib/jruby-launcher.rb', __FILE__)
3
+
4
+ describe "JRuby native launcher" do
5
+ it "should run org.jruby.Main" do
6
+ jruby_launcher_args("").last.should == "org/jruby/Main"
7
+ end
8
+
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"]
11
+ end
12
+
13
+ it "should print help message" do
14
+ args = jruby_launcher_args("-Xhelp 2>&1")
15
+ args.detect{|l| l =~ /JRuby Launcher usage/}.should be_true
16
+ args.should include("-X")
17
+ args = jruby_launcher_args("-X 2>&1")
18
+ args.detect{|l| l =~ /JRuby Launcher usage/}.should be_true
19
+ args.should include("-X")
20
+ end
21
+
22
+ it "should use $JAVACMD when JAVACMD is specified" do
23
+ with_environment "JAVACMD" => File.join("jato") do
24
+ if windows?
25
+ jruby_launcher_args("-v 2>&1").join.should =~ %r{jato}
26
+ else
27
+ jruby_launcher_args("-v").first.should == File.join("jato")
28
+ end
29
+ end
30
+ end
31
+
32
+ it "should use $JAVA_HOME/bin/java when JAVA_HOME is specified" do
33
+ with_environment "JAVA_HOME" => File.join("some", "java", "home") do
34
+ if windows?
35
+ jruby_launcher_args("-v 2>&1").join.should =~ %r{some/java/home}
36
+ else
37
+ jruby_launcher_args("-v").first.should == File.join("some", "java", "home", "bin", "java")
38
+ end
39
+ end
40
+ end
41
+
42
+ it "should use -Xjdkhome argument above JAVA_HOME" do
43
+ with_environment "JAVA_HOME" => File.join("env", "java", "home") do
44
+ if windows?
45
+ jruby_launcher_args("-Xjdkhome some/java/home 2>&1").join.should =~ %r{some/java/home}
46
+ else
47
+ jruby_launcher_args("-Xjdkhome some/java/home").first.should == File.join("some", "java", "home", "bin", "java")
48
+ end
49
+ end
50
+ end
51
+
52
+ it "should complain about a missing log argument" do
53
+ jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
54
+ jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
55
+ end
56
+
57
+ it "should complain about a missing jdkhome argument" do
58
+ jruby_launcher("-Xjdkhome 2>&1").should =~ /Argument is missing/
59
+ jruby_launcher("-Xjdkhome -- 2>&1").should =~ /Argument is missing/
60
+ end
61
+
62
+ it "should complain about a missing classpath append argument" do
63
+ jruby_launcher("-Xcp:a 2>&1").should =~ /Argument is missing/
64
+ jruby_launcher("-Xcp:a -- 2>&1").should =~ /Argument is missing/
65
+ end
66
+
67
+ it "should run nailgun server with --ng-server option" do
68
+ jruby_launcher_args("--ng-server").last.should == "com/martiansoftware/nailgun/NGServer"
69
+ end
70
+
71
+ it "should run nailgun client with --ng option" do
72
+ jruby_launcher_args('--ng -e "puts 1"').should == ["org.jruby.util.NailMain", "-e", "puts 1"]
73
+ end
74
+
75
+ it "should handle -J JVM options" do
76
+ jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2").should include("-Darg1=value1", "-Darg2=value2")
77
+ end
78
+
79
+ it "should pass -Xprop.erty=value as -J-Djruby.prop.erty=value" do
80
+ jruby_launcher_args("-Xprop.erty=value").should include("-Djruby.prop.erty=value")
81
+ end
82
+
83
+ it "should pass -Xproperties as --properties" do
84
+ jruby_launcher_args("-Xproperties").should include("--properties")
85
+ end
86
+
87
+ it "should default to 500m max heap" do
88
+ jruby_launcher_args("").should include("-Xmx500m", "-Djruby.memory.max=500m")
89
+ end
90
+
91
+ it "should allow max heap to be overridden" do
92
+ jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m", "-Djruby.memory.max=256m")
93
+ end
94
+
95
+ it "should default to 2048k max stack" do
96
+ jruby_launcher_args("").should include("-Xss2048k", "-Djruby.stack.max=2048k")
97
+ end
98
+
99
+ it "should allow max stack to be overridden" do
100
+ jruby_launcher_args("-J-Xss512k").should include("-Xss512k", "-Djruby.stack.max=512k")
101
+ end
102
+
103
+ it "should add the contents of the CLASSPATH environment variable" do
104
+ with_environment "CLASSPATH" => "some.jar" do
105
+ classpath_arg = jruby_launcher_args("").detect{|a| a =~ /java\.class\.path/}
106
+ classpath_arg.should =~ /-Djava.class.path=.*some.jar/
107
+ end
108
+ end
109
+
110
+ it "should add the classpath elements in proper order" do
111
+ s = File::PATH_SEPARATOR
112
+ with_environment "CLASSPATH" => "some-env.jar" do
113
+ classpath_arg = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar").detect{|a| a =~ /java\.class\.path/}
114
+ classpath_arg.should =~ /-Djava.class.path=some.jar.*#{s}some-env.jar#{s}some-other.jar/
115
+ end
116
+ end
117
+
118
+ it "should use the --server compiler" do
119
+ jruby_launcher_args("--server").should include("-server")
120
+ end
121
+
122
+ it "should use the --client compiler" do
123
+ jruby_launcher_args("--client").should include("-client")
124
+ end
125
+
126
+ it "should set the JMX settings when --manage is present" do
127
+ jruby_launcher_args("--manage").should include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true")
128
+ end
129
+
130
+ it "should set the headless flag when --headless is present" do
131
+ jruby_launcher_args("--headless").should include("-Djava.awt.headless=true")
132
+ end
133
+
134
+ it "should pass -Xprof when --sample is present" do
135
+ jruby_launcher_args("--sample").should include("-Xprof")
136
+ end
137
+
138
+ it "should stop argument processing when a -- is seen" do
139
+ jruby_launcher_args("-- -Xhelp -Xtrace --headless").should include("-Xhelp", "-Xtrace", "--headless")
140
+ end
141
+
142
+ # JRUBY-4151
143
+ it "should properly handle single quotes" do
144
+ jruby_launcher_args("-e 'ABC DEF'").should include("ABC DEF")
145
+ end
146
+
147
+ # JRUBY-4581
148
+ it "should prepend JRUBY_OPTS to the start of the argument list to process" do
149
+ with_environment "JRUBY_OPTS" => "--server -J-Dsome.key=val -rubygems" do
150
+ jruby_launcher_args("-e 'ABC DEF'").should include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF")
151
+ end
152
+ end
153
+
154
+ # JRUBY-4611
155
+ it "stops argument processing on first non-option argument" do
156
+ jruby_launcher_args("foo.rb --sample")[-2..-1].should == ["foo.rb", "--sample"]
157
+ end
158
+
159
+ # JRUBY-4608
160
+ if Config::CONFIG['target_os'] =~ /darwin/i
161
+ it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
162
+ jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
163
+ with_environment "JAVA_ENCODING" => "MacRoman" do
164
+ jruby_launcher_args("-e true").should_not include("-Dfile.encoding=UTF-8")
165
+ end
166
+ end
167
+ end
168
+
169
+ it "does not crash on empty args" do
170
+ jruby_launcher_args("-e ''").should include("-e")
171
+ jruby_launcher("-Xtrace '' 2>&1").should =~ /-Xtrace/
172
+ jruby_launcher("-Xjdkhome '' 2>&1").should =~ /-Xjdkhome/
173
+ end
174
+
175
+ # JRUBY-4706
176
+ it "should put JRuby on regular classpath when -Xnobootclasspath is used" do
177
+ args = jruby_launcher_args("-e true")
178
+ args.grep(/Xbootclasspath/).should_not be_empty
179
+ args = jruby_launcher_args("-Xnobootclasspath -e true")
180
+ args.grep(/Xbootclasspath/).should be_empty
181
+ end
182
+
183
+ it "should put JRuby on regular classpath when VERIFY_JRUBY is set" do
184
+ with_environment "VERIFY_JRUBY" => "true" do
185
+ args = jruby_launcher_args("-e true")
186
+ args.grep(/Xbootclasspath/).should be_empty
187
+ end
188
+ end
189
+
190
+ # JRUBY-4709
191
+ it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
192
+ jruby_launcher_args("-Xnobootclasspath -e true").grep(/java\.class\.path/).first.should =~
193
+ if windows?
194
+ /;$/
195
+ else
196
+ /:$/
197
+ end
198
+ end
199
+
200
+ # JRUBY-6016
201
+ it "should honor JAVA_MEM" do
202
+ with_environment "JAVA_MEM" => "-Xmx768m" do
203
+ jruby_launcher_args("").should include("-Xmx768m", "-Djruby.memory.max=768m")
204
+ end
205
+ end
206
+
207
+ it "should honor JAVA_STACK" do
208
+ with_environment "JAVA_STACK" => "-Xss3072k" do
209
+ jruby_launcher_args("").should include("-Xss3072k", "-Djruby.stack.max=3072k")
210
+ end
211
+ end
212
+
213
+ it "should place user-supplied options after default options" do
214
+ args = jruby_launcher_args("-J-Djruby.home=/tmp")
215
+ home_args = args.select {|x| x =~ /^-Djruby\.home/ }
216
+ home_args.length.should == 2
217
+ home_args.last.should == "-Djruby.home=/tmp"
218
+ end
219
+
220
+ it "should print the version" do
221
+ jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/
222
+ end
223
+ end
@@ -0,0 +1,75 @@
1
+ require 'rspec'
2
+ require 'rbconfig'
3
+ require 'fileutils'
4
+
5
+ if defined?(JRUBY_VERSION)
6
+ require 'jruby'
7
+ JRuby.runtime.instance_config.run_ruby_in_process = false
8
+ end
9
+
10
+ module JRubyLauncherHelper
11
+ JRUBY_EXE = ''
12
+ WINDOWS = Config::CONFIG['target_os'] =~ /mswin/
13
+
14
+ def self.check_executable_built
15
+ exe = File.expand_path("../../jruby", __FILE__) + Config::CONFIG['EXEEXT']
16
+ unless File.executable?(exe)
17
+ raise "Error: launcher executable not built; type `make' before continuing."
18
+ end
19
+ top = File.dirname(exe)
20
+ name = File.basename(exe)
21
+ home = File.join(top, "build/home")
22
+ FileUtils.mkdir_p(File.join(home, "bin"))
23
+ FileUtils.cp(exe, File.join(home, "bin"))
24
+ if JRubyLauncherHelper::WINDOWS
25
+ FileUtils.cp(exe.sub(/exe/, 'dll'), File.join(home, "bin"))
26
+ end
27
+ FileUtils.mkdir_p(File.join(home, "lib"))
28
+ FileUtils.touch(File.join(home, "lib/jruby.jar"))
29
+ JRUBY_EXE.concat File.join(home, "bin", name)
30
+ end
31
+
32
+ def jruby_launcher(args)
33
+ `#{JRUBY_EXE} #{args}`
34
+ end
35
+
36
+ def jruby_launcher_args(args)
37
+ jruby_launcher("-Xcommand #{args}").split("\n")
38
+ end
39
+
40
+ def last_exit_code
41
+ $?.exitstatus
42
+ end
43
+
44
+ def windows?
45
+ WINDOWS
46
+ end
47
+
48
+ def with_environment(pairs = {})
49
+ prev_env = {}
50
+ pairs.each_pair do |k,v|
51
+ prev_env[k] = ENV[k] if ENV.has_key?(k)
52
+ ENV[k] = v
53
+ end
54
+ begin
55
+ yield
56
+ ensure
57
+ pairs.keys.each {|k| ENV.delete(k)}
58
+ ENV.update(prev_env)
59
+ end
60
+ end
61
+ end
62
+
63
+ RSpec.configure do |config|
64
+ config.before(:all) do
65
+ JRubyLauncherHelper.check_executable_built
66
+ # clear environment for better control
67
+ ENV.delete("JAVA_HOME")
68
+ ENV.delete("JRUBY_HOME")
69
+ ENV.delete("JAVA_OPTS")
70
+ ENV.delete("JRUBY_OPTS")
71
+ ENV.delete("CLASSPATH")
72
+ ENV.delete("JAVA_ENCODING")
73
+ end
74
+ config.include(JRubyLauncherHelper)
75
+ end
@@ -0,0 +1,249 @@
1
+ require File.expand_path('../spec_helper.rb', __FILE__)
2
+ load File.expand_path('../../lib/jruby-launcher.rb', __FILE__)
3
+
4
+ describe "JRuby native launcher" do
5
+ it "should run org.jruby.Main" do
6
+ jruby_launcher_args("").last.should == "org/jruby/Main"
7
+ end
8
+
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"]
11
+ end
12
+
13
+ it "should print help message" do
14
+ args = jruby_launcher_args("-Xhelp 2>&1")
15
+ args.detect{|l| l =~ /JRuby Launcher usage/}.should be_true
16
+ args.should include("-X")
17
+ args = jruby_launcher_args("-X 2>&1")
18
+ args.detect{|l| l =~ /JRuby Launcher usage/}.should be_true
19
+ args.should include("-X")
20
+ end
21
+
22
+ it "should use $JAVACMD when JAVACMD is specified" do
23
+ with_environment "JAVACMD" => File.join("jato") do
24
+ if windows?
25
+ jruby_launcher_args("-v 2>&1").join.should =~ %r{jato}
26
+ else
27
+ jruby_launcher_args("-v").first.should == File.join("jato")
28
+ end
29
+ end
30
+ end
31
+
32
+ it "should use $JAVA_HOME/bin/java when JAVA_HOME is specified" do
33
+ with_environment "JAVA_HOME" => File.join("some", "java", "home") do
34
+ if windows?
35
+ jruby_launcher_args("-v 2>&1").join.should =~ %r{some/java/home}
36
+ else
37
+ jruby_launcher_args("-v").first.should == File.join("some", "java", "home", "bin", "java")
38
+ end
39
+ end
40
+ end
41
+
42
+ it "should use -Xjdkhome argument above JAVA_HOME" do
43
+ with_environment "JAVA_HOME" => File.join("env", "java", "home") do
44
+ if windows?
45
+ jruby_launcher_args("-Xjdkhome some/java/home 2>&1").join.should =~ %r{some/java/home}
46
+ else
47
+ jruby_launcher_args("-Xjdkhome some/java/home").first.should == File.join("some", "java", "home", "bin", "java")
48
+ end
49
+ end
50
+ end
51
+
52
+ it "should complain about a missing log argument" do
53
+ jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
54
+ jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
55
+ end
56
+
57
+ it "should complain about a missing jdkhome argument" do
58
+ jruby_launcher("-Xjdkhome 2>&1").should =~ /Argument is missing/
59
+ jruby_launcher("-Xjdkhome -- 2>&1").should =~ /Argument is missing/
60
+ end
61
+
62
+ it "should complain about a missing classpath append argument" do
63
+ jruby_launcher("-Xcp:a 2>&1").should =~ /Argument is missing/
64
+ jruby_launcher("-Xcp:a -- 2>&1").should =~ /Argument is missing/
65
+ end
66
+
67
+ it "should run nailgun server with --ng-server option" do
68
+ jruby_launcher_args("--ng-server").last.should == "com/martiansoftware/nailgun/NGServer"
69
+ end
70
+
71
+ it "should run nailgun client with --ng option" do
72
+ jruby_launcher_args('--ng -e "puts 1"').should == ["org.jruby.util.NailMain", "-e", "puts 1"]
73
+ end
74
+
75
+ it "should handle -J JVM options" do
76
+ jruby_launcher_args("-J-Darg1=value1 -J-Darg2=value2").should include("-Darg1=value1", "-Darg2=value2")
77
+ end
78
+
79
+ it "should pass -Xprop.erty=value as -J-Djruby.prop.erty=value" do
80
+ jruby_launcher_args("-Xprop.erty=value").should include("-Djruby.prop.erty=value")
81
+ end
82
+
83
+ it "should pass -Xproperties as --properties" do
84
+ jruby_launcher_args("-Xproperties").should include("--properties")
85
+ end
86
+
87
+ it "should default to 500m max heap" do
88
+ jruby_launcher_args("").should include("-Xmx500m", "-Djruby.memory.max=500m")
89
+ end
90
+
91
+ it "should allow max heap to be overridden" do
92
+ jruby_launcher_args("-J-Xmx256m").should include("-Xmx256m", "-Djruby.memory.max=256m")
93
+ end
94
+
95
+ it "should default to 2048k max stack" do
96
+ jruby_launcher_args("").should include("-Xss2048k", "-Djruby.stack.max=2048k")
97
+ end
98
+
99
+ it "should allow max stack to be overridden" do
100
+ jruby_launcher_args("-J-Xss512k").should include("-Xss512k", "-Djruby.stack.max=512k")
101
+ end
102
+
103
+ it "should add the contents of the CLASSPATH environment variable" do
104
+ with_environment "CLASSPATH" => "some.jar" do
105
+ classpath_arg = jruby_launcher_args("").detect{|a| a =~ /java\.class\.path/}
106
+ classpath_arg.should =~ /-Djava.class.path=.*some.jar/
107
+ end
108
+ end
109
+
110
+ it "should add the classpath elements in proper order" do
111
+ s = File::PATH_SEPARATOR
112
+ with_environment "CLASSPATH" => "some-env.jar" do
113
+ classpath_arg = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar").detect{|a| a =~ /java\.class\.path/}
114
+ classpath_arg.should =~ /-Djava.class.path=some.jar.*#{s}some-env.jar#{s}some-other.jar/
115
+ end
116
+ end
117
+
118
+ it "should use the --server compiler" do
119
+ jruby_launcher_args("--server").should include("-server")
120
+ end
121
+
122
+ it "should use the --client compiler" do
123
+ jruby_launcher_args("--client").should include("-client")
124
+ end
125
+
126
+ it "should set the JMX settings when --manage is present" do
127
+ jruby_launcher_args("--manage").should include("-Dcom.sun.management.jmxremote", "-Djruby.management.enabled=true")
128
+ end
129
+
130
+ it "should set the headless flag when --headless is present" do
131
+ jruby_launcher_args("--headless").should include("-Djava.awt.headless=true")
132
+ end
133
+
134
+ it "should pass -Xprof when --sample is present" do
135
+ jruby_launcher_args("--sample").should include("-Xprof")
136
+ end
137
+
138
+ it "should stop argument processing when a -- is seen" do
139
+ jruby_launcher_args("-- -Xhelp -Xtrace --headless").should include("-Xhelp", "-Xtrace", "--headless")
140
+ end
141
+
142
+ # JRUBY-4151
143
+ it "should properly handle single quotes" do
144
+ jruby_launcher_args("-e 'ABC DEF'").should include("ABC DEF")
145
+ end
146
+
147
+ # JRUBY-4581
148
+ it "should prepend JRUBY_OPTS to the start of the argument list to process" do
149
+ with_environment "JRUBY_OPTS" => "--server -J-Dsome.key=val -rubygems" do
150
+ jruby_launcher_args("-e 'ABC DEF'").should include("-server", "-Dsome.key=val", "-rubygems", "-e", "ABC DEF")
151
+ end
152
+ end
153
+
154
+ # JRUBY-4611
155
+ it "stops argument processing on first non-option argument" do
156
+ jruby_launcher_args("foo.rb --sample")[-2..-1].should == ["foo.rb", "--sample"]
157
+ end
158
+
159
+ # JRUBY-4608
160
+ if Config::CONFIG['target_os'] =~ /darwin/i
161
+ it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
162
+ jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
163
+ with_environment "JAVA_ENCODING" => "MacRoman" do
164
+ jruby_launcher_args("-e true").should_not include("-Dfile.encoding=UTF-8")
165
+ end
166
+ end
167
+ end
168
+
169
+ it "does not crash on empty args" do
170
+ jruby_launcher_args("-e ''").should include("-e")
171
+ jruby_launcher("-Xtrace '' 2>&1").should =~ /-Xtrace/
172
+ jruby_launcher("-Xjdkhome '' 2>&1").should =~ /-Xjdkhome/
173
+ end
174
+
175
+ # JRUBY-4706
176
+ it "should put JRuby on regular classpath when -Xnobootclasspath is used" do
177
+ args = jruby_launcher_args("-e true")
178
+ args.grep(/Xbootclasspath/).should_not be_empty
179
+ args = jruby_launcher_args("-Xnobootclasspath -e true")
180
+ args.grep(/Xbootclasspath/).should be_empty
181
+ end
182
+
183
+ it "should put JRuby on regular classpath when VERIFY_JRUBY is set" do
184
+ with_environment "VERIFY_JRUBY" => "true" do
185
+ args = jruby_launcher_args("-e true")
186
+ args.grep(/Xbootclasspath/).should be_empty
187
+ end
188
+ end
189
+
190
+ # JRUBY-4709
191
+ it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
192
+ jruby_launcher_args("-Xnobootclasspath -e true").grep(/java\.class\.path/).first.should =~
193
+ if windows?
194
+ /;$/
195
+ else
196
+ /:$/
197
+ end
198
+ end
199
+
200
+ # JRUBY-6016
201
+ it "should honor JAVA_MEM" do
202
+ with_environment "JAVA_MEM" => "-Xmx768m" do
203
+ jruby_launcher_args("").should include("-Xmx768m", "-Djruby.memory.max=768m")
204
+ end
205
+ end
206
+
207
+ it "should honor JAVA_STACK" do
208
+ with_environment "JAVA_STACK" => "-Xss3072k" do
209
+ jruby_launcher_args("").should include("-Xss3072k", "-Djruby.stack.max=3072k")
210
+ end
211
+ end
212
+
213
+ it "should honor JRUBY_HOME" do
214
+ with_environment "JRUBY_HOME" => "/tmp" do
215
+ jruby_launcher_args("").should include("-Djruby.home=/tmp")
216
+ end
217
+ end
218
+
219
+ context "JRUBY_HOME set and JRUBY_HOME/lib/jruby.jar exists" do
220
+ let(:jruby_home) do
221
+ require 'tempfile'
222
+ t = Tempfile.new("jruby_home")
223
+ t.path.tap { t.close! }
224
+ end
225
+
226
+ before do
227
+ FileUtils.mkdir_p(File.join(jruby_home, "lib"))
228
+ FileUtils.touch(File.join(jruby_home, "lib", "jruby.jar"))
229
+ end
230
+ after { FileUtils.rm_rf jruby_home }
231
+
232
+ it "should add jruby.jar to the bootclasspath" do
233
+ with_environment "JRUBY_HOME" => jruby_home do
234
+ jruby_launcher_args("").should include("-Xbootclasspath/a:#{jruby_home}/lib/jruby.jar")
235
+ end
236
+ end
237
+ end
238
+
239
+ it "should place user-supplied options after default options" do
240
+ args = jruby_launcher_args("-J-Djruby.home=/tmp")
241
+ home_args = args.select {|x| x =~ /^-Djruby\.home/ }
242
+ home_args.length.should == 2
243
+ home_args.last.should == "-Djruby.home=/tmp"
244
+ end
245
+
246
+ it "should print the version" do
247
+ jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/
248
+ end
249
+ end
@@ -0,0 +1,75 @@
1
+ require 'rspec'
2
+ require 'rbconfig'
3
+ require 'fileutils'
4
+
5
+ if defined?(JRUBY_VERSION)
6
+ require 'jruby'
7
+ JRuby.runtime.instance_config.run_ruby_in_process = false
8
+ end
9
+
10
+ module JRubyLauncherHelper
11
+ JRUBY_EXE = ''
12
+ WINDOWS = Config::CONFIG['target_os'] =~ /mswin/
13
+
14
+ def self.check_executable_built
15
+ exe = File.expand_path("../../jruby", __FILE__) + Config::CONFIG['EXEEXT']
16
+ unless File.executable?(exe)
17
+ raise "Error: launcher executable not built; type `make' before continuing."
18
+ end
19
+ top = File.dirname(exe)
20
+ name = File.basename(exe)
21
+ home = File.join(top, "build/home")
22
+ FileUtils.mkdir_p(File.join(home, "bin"))
23
+ FileUtils.cp(exe, File.join(home, "bin"))
24
+ if JRubyLauncherHelper::WINDOWS
25
+ FileUtils.cp(exe.sub(/exe/, 'dll'), File.join(home, "bin"))
26
+ end
27
+ FileUtils.mkdir_p(File.join(home, "lib"))
28
+ FileUtils.touch(File.join(home, "lib/jruby.jar"))
29
+ JRUBY_EXE.concat File.join(home, "bin", name)
30
+ end
31
+
32
+ def jruby_launcher(args)
33
+ `#{JRUBY_EXE} #{args}`
34
+ end
35
+
36
+ def jruby_launcher_args(args)
37
+ jruby_launcher("-Xcommand #{args}").split("\n")
38
+ end
39
+
40
+ def last_exit_code
41
+ $?.exitstatus
42
+ end
43
+
44
+ def windows?
45
+ WINDOWS
46
+ end
47
+
48
+ def with_environment(pairs = {})
49
+ prev_env = {}
50
+ pairs.each_pair do |k,v|
51
+ prev_env[k] = ENV[k] if ENV.has_key?(k)
52
+ ENV[k] = v
53
+ end
54
+ begin
55
+ yield
56
+ ensure
57
+ pairs.keys.each {|k| ENV.delete(k)}
58
+ ENV.update(prev_env)
59
+ end
60
+ end
61
+ end
62
+
63
+ RSpec.configure do |config|
64
+ config.before(:all) do
65
+ JRubyLauncherHelper.check_executable_built
66
+ # clear environment for better control
67
+ ENV.delete("JAVA_HOME")
68
+ ENV.delete("JRUBY_HOME")
69
+ ENV.delete("JAVA_OPTS")
70
+ ENV.delete("JRUBY_OPTS")
71
+ ENV.delete("CLASSPATH")
72
+ ENV.delete("JAVA_ENCODING")
73
+ end
74
+ config.include(JRubyLauncherHelper)
75
+ end
data/platformlauncher.cpp CHANGED
@@ -54,6 +54,7 @@ extern "C" int nailgunClientMain(int argc, char *argv[], char *env[]);
54
54
  PlatformLauncher::PlatformLauncher()
55
55
  : ArgParser()
56
56
  , suppressConsole(false)
57
+ , separateProcess(false)
57
58
  {
58
59
  }
59
60
 
@@ -102,16 +102,15 @@ describe "JRuby native launcher" do
102
102
 
103
103
  it "should add the contents of the CLASSPATH environment variable" do
104
104
  with_environment "CLASSPATH" => "some.jar" do
105
- classpath_arg = jruby_launcher_args("").detect{|a| a =~ /java\.class\.path/}
106
- classpath_arg.should =~ /-Djava.class.path=.*some.jar/
105
+ classpath_arg(jruby_launcher_args("")).should =~ /some.jar/
107
106
  end
108
107
  end
109
108
 
110
109
  it "should add the classpath elements in proper order" do
111
110
  s = File::PATH_SEPARATOR
112
111
  with_environment "CLASSPATH" => "some-env.jar" do
113
- classpath_arg = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar").detect{|a| a =~ /java\.class\.path/}
114
- classpath_arg.should =~ /-Djava.class.path=some.jar.*#{s}some-env.jar#{s}some-other.jar/
112
+ args = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar")
113
+ classpath_arg(args).should =~ /some.jar.*#{s}some-env.jar#{s}some-other.jar/
115
114
  end
116
115
  end
117
116
 
@@ -189,7 +188,7 @@ describe "JRuby native launcher" do
189
188
 
190
189
  # JRUBY-4709
191
190
  it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
192
- jruby_launcher_args("-Xnobootclasspath -e true").grep(/java\.class\.path/).first.should =~
191
+ classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true")).should =~
193
192
  if windows?
194
193
  /;$/
195
194
  else
data/spec/spec_helper.rb CHANGED
@@ -45,6 +45,12 @@ module JRubyLauncherHelper
45
45
  WINDOWS
46
46
  end
47
47
 
48
+ def classpath_arg(args)
49
+ index = args.index("-cp")
50
+ index.should > 0
51
+ args[index + 1]
52
+ end
53
+
48
54
  def with_environment(pairs = {})
49
55
  prev_env = {}
50
56
  pairs.each_pair do |k,v|
data/version.h CHANGED
@@ -6,6 +6,6 @@
6
6
  #ifndef _VERSION_H_
7
7
  #define _VERSION_H_
8
8
 
9
- #define JRUBY_LAUNCHER_VERSION "1.0.13"
9
+ #define JRUBY_LAUNCHER_VERSION "1.0.14"
10
10
 
11
11
  #endif // ! _VERSION_H_
metadata CHANGED
@@ -1,94 +1,157 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jruby-launcher
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.13
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.14
6
6
  platform: java
7
- authors:
8
- - Nick Sieger
9
- - Vladimir Sizikov
10
- autorequire:
7
+ authors:
8
+ - Nick Sieger
9
+ - Vladimir Sizikov
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2012-04-18 00:00:00 Z
13
+ date: 2012-05-04 00:00:00.000000000 Z
15
14
  dependencies: []
16
-
17
15
  description: Builds and installs a native launcher for JRuby on your system
18
- email:
19
- - nick@nicksieger.com
20
- - vsizikov@gmail.com
16
+ email:
17
+ - nick@nicksieger.com
18
+ - vsizikov@gmail.com
21
19
  executables: []
22
-
23
- extensions:
24
- - extconf.rb
20
+ extensions:
21
+ - extconf.rb
25
22
  extra_rdoc_files: []
26
-
27
- files:
28
- - COPYING
29
- - README.txt
30
- - Makefile
31
- - Rakefile
32
- - ng.c
33
- - strlcpy.c
34
- - argparser.cpp
35
- - jruby.cpp
36
- - jrubyexe.cpp
37
- - jvmlauncher.cpp
38
- - platformlauncher.cpp
39
- - unixlauncher.cpp
40
- - utilsfuncs.cpp
41
- - utilsfuncswin.cpp
42
- - argnames.h
43
- - argparser.h
44
- - jvmlauncher.h
45
- - nbexecloader.h
46
- - platformlauncher.h
47
- - rb_w32_cmdvector.h
48
- - unixlauncher.h
49
- - utilsfuncs.h
50
- - version.h
51
- - inc/Makefile-conf.mk
52
- - inc/Makefile-impl.mk
53
- - inc/Makefile-rules.mk
54
- - extconf.rb
55
- - lib/jruby-launcher.rb
56
- - lib/rubygems/defaults/jruby_native.rb
57
- - pkg/jruby-launcher-1.0.12-java/extconf.rb
58
- - pkg/jruby-launcher-1.0.12-java/lib/jruby-launcher.rb
59
- - pkg/jruby-launcher-1.0.12-java/lib/rubygems/defaults/jruby_native.rb
60
- - pkg/jruby-launcher-1.0.12-java/spec/launcher_spec.rb
61
- - pkg/jruby-launcher-1.0.12-java/spec/spec_helper.rb
62
- - spec/launcher_spec.rb
63
- - spec/spec_helper.rb
64
- - resources/jruby.ico
65
- - resources/jruby.rc
23
+ files:
24
+ - COPYING
25
+ - README.txt
26
+ - Makefile
27
+ - Rakefile
28
+ - !binary |-
29
+ bmcuYw==
30
+ - !binary |-
31
+ c3RybGNweS5j
32
+ - !binary |-
33
+ YXJncGFyc2VyLmNwcA==
34
+ - !binary |-
35
+ anJ1YnkuY3Bw
36
+ - !binary |-
37
+ anJ1YnlleGUuY3Bw
38
+ - !binary |-
39
+ anZtbGF1bmNoZXIuY3Bw
40
+ - !binary |-
41
+ cGxhdGZvcm1sYXVuY2hlci5jcHA=
42
+ - !binary |-
43
+ dW5peGxhdW5jaGVyLmNwcA==
44
+ - !binary |-
45
+ dXRpbHNmdW5jcy5jcHA=
46
+ - !binary |-
47
+ dXRpbHNmdW5jc3dpbi5jcHA=
48
+ - !binary |-
49
+ YXJnbmFtZXMuaA==
50
+ - !binary |-
51
+ YXJncGFyc2VyLmg=
52
+ - !binary |-
53
+ anZtbGF1bmNoZXIuaA==
54
+ - !binary |-
55
+ bmJleGVjbG9hZGVyLmg=
56
+ - !binary |-
57
+ cGxhdGZvcm1sYXVuY2hlci5o
58
+ - !binary |-
59
+ cmJfdzMyX2NtZHZlY3Rvci5o
60
+ - !binary |-
61
+ dW5peGxhdW5jaGVyLmg=
62
+ - !binary |-
63
+ dXRpbHNmdW5jcy5o
64
+ - !binary |-
65
+ dmVyc2lvbi5o
66
+ - !binary |-
67
+ aW5jL01ha2VmaWxlLWNvbmYubWs=
68
+ - !binary |-
69
+ aW5jL01ha2VmaWxlLWltcGwubWs=
70
+ - !binary |-
71
+ aW5jL01ha2VmaWxlLXJ1bGVzLm1r
72
+ - !binary |-
73
+ ZXh0Y29uZi5yYg==
74
+ - !binary |-
75
+ bGliL2pydWJ5LWxhdW5jaGVyLnJi
76
+ - !binary |-
77
+ bGliL3J1YnlnZW1zL2RlZmF1bHRzL2pydWJ5X25hdGl2ZS5yYg==
78
+ - !binary |-
79
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL2V4dGNvbmYucmI=
80
+ - !binary |-
81
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL2xpYi9qcnVieS1sYXVu
82
+ Y2hlci5yYg==
83
+ - !binary |-
84
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL2xpYi9ydWJ5Z2Vtcy9k
85
+ ZWZhdWx0cy9qcnVieV9uYXRpdmUucmI=
86
+ - !binary |-
87
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL3NwZWMvbGF1bmNoZXJf
88
+ c3BlYy5yYg==
89
+ - !binary |-
90
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL3NwZWMvc3BlY19oZWxw
91
+ ZXIucmI=
92
+ - !binary |-
93
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL2V4dGNvbmYucmI=
94
+ - !binary |-
95
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL2xpYi9qcnVieS1sYXVu
96
+ Y2hlci5yYg==
97
+ - !binary |-
98
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL2xpYi9ydWJ5Z2Vtcy9k
99
+ ZWZhdWx0cy9qcnVieV9uYXRpdmUucmI=
100
+ - !binary |-
101
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL3BrZy9qcnVieS1sYXVu
102
+ Y2hlci0xLjAuMTItamF2YS9leHRjb25mLnJi
103
+ - !binary |-
104
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL3BrZy9qcnVieS1sYXVu
105
+ Y2hlci0xLjAuMTItamF2YS9saWIvanJ1YnktbGF1bmNoZXIucmI=
106
+ - !binary |-
107
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL3BrZy9qcnVieS1sYXVu
108
+ Y2hlci0xLjAuMTItamF2YS9saWIvcnVieWdlbXMvZGVmYXVsdHMvanJ1Ynlf
109
+ bmF0aXZlLnJi
110
+ - !binary |-
111
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL3BrZy9qcnVieS1sYXVu
112
+ Y2hlci0xLjAuMTItamF2YS9zcGVjL2xhdW5jaGVyX3NwZWMucmI=
113
+ - !binary |-
114
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL3BrZy9qcnVieS1sYXVu
115
+ Y2hlci0xLjAuMTItamF2YS9zcGVjL3NwZWNfaGVscGVyLnJi
116
+ - !binary |-
117
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL3NwZWMvbGF1bmNoZXJf
118
+ c3BlYy5yYg==
119
+ - !binary |-
120
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMy1qYXZhL3NwZWMvc3BlY19oZWxw
121
+ ZXIucmI=
122
+ - !binary |-
123
+ c3BlYy9sYXVuY2hlcl9zcGVjLnJi
124
+ - !binary |-
125
+ c3BlYy9zcGVjX2hlbHBlci5yYg==
126
+ - !binary |-
127
+ cmVzb3VyY2VzL2pydWJ5Lmljbw==
128
+ - !binary |-
129
+ cmVzb3VyY2VzL2pydWJ5LnJj
66
130
  homepage: http://jruby.org
67
131
  licenses: []
68
-
69
- post_install_message:
132
+ post_install_message:
70
133
  rdoc_options: []
71
-
72
- require_paths:
73
- - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: !binary |-
141
+ MA==
75
142
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0"
80
- required_rubygems_version: !ruby/object:Gem::Requirement
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: !binary |-
148
+ MA==
81
149
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: "0"
86
150
  requirements: []
87
-
88
151
  rubyforge_project: jruby-extras
89
- rubygems_version: 1.8.15
90
- signing_key:
152
+ rubygems_version: 1.8.24
153
+ signing_key:
91
154
  specification_version: 3
92
155
  summary: Native launcher for JRuby
93
156
  test_files: []
94
-
157
+ ...