jruby-launcher 1.0.14-java → 1.0.15-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.
Files changed (26) hide show
  1. data/argparser.cpp +5 -2
  2. data/inc/Makefile-conf.mk +4 -4
  3. data/lib/jruby-launcher.rb +1 -1
  4. data/pkg/{jruby-launcher-1.0.12-java → jruby-launcher-1.0.15-java}/extconf.rb +0 -0
  5. data/pkg/{jruby-launcher-1.0.13-java → jruby-launcher-1.0.15-java}/lib/jruby-launcher.rb +1 -1
  6. data/pkg/{jruby-launcher-1.0.12-java → jruby-launcher-1.0.15-java}/lib/rubygems/defaults/jruby_native.rb +0 -0
  7. data/pkg/{jruby-launcher-1.0.13-java → jruby-launcher-1.0.15-java}/spec/launcher_spec.rb +15 -6
  8. data/pkg/{jruby-launcher-1.0.12-java → jruby-launcher-1.0.15-java}/spec/spec_helper.rb +8 -2
  9. data/platformlauncher.cpp +4 -3
  10. data/spec/launcher_spec.rb +11 -1
  11. data/spec/spec_helper.rb +2 -2
  12. data/unixlauncher.cpp +3 -1
  13. data/utilsfuncs.cpp +9 -1
  14. data/utilsfuncs.h +1 -0
  15. data/version.h +1 -1
  16. metadata +7 -38
  17. data/pkg/jruby-launcher-1.0.12-java/lib/jruby-launcher.rb +0 -3
  18. data/pkg/jruby-launcher-1.0.12-java/spec/launcher_spec.rb +0 -223
  19. data/pkg/jruby-launcher-1.0.13-java/extconf.rb +0 -7
  20. data/pkg/jruby-launcher-1.0.13-java/lib/rubygems/defaults/jruby_native.rb +0 -4
  21. data/pkg/jruby-launcher-1.0.13-java/pkg/jruby-launcher-1.0.12-java/extconf.rb +0 -7
  22. data/pkg/jruby-launcher-1.0.13-java/pkg/jruby-launcher-1.0.12-java/lib/jruby-launcher.rb +0 -3
  23. data/pkg/jruby-launcher-1.0.13-java/pkg/jruby-launcher-1.0.12-java/lib/rubygems/defaults/jruby_native.rb +0 -4
  24. data/pkg/jruby-launcher-1.0.13-java/pkg/jruby-launcher-1.0.12-java/spec/launcher_spec.rb +0 -223
  25. data/pkg/jruby-launcher-1.0.13-java/pkg/jruby-launcher-1.0.12-java/spec/spec_helper.rb +0 -75
  26. data/pkg/jruby-launcher-1.0.13-java/spec/spec_helper.rb +0 -75
data/argparser.cpp CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  #include <cstring>
6
6
  #include <cstdlib>
7
+ #include <climits>
7
8
  #include <memory>
8
9
  #include <string>
9
10
  #include <unistd.h>
@@ -193,8 +194,10 @@ bool ArgParser::initPlatformDir() {
193
194
  if (!found) { // try via PATH search
194
195
  logMsg("initPlatformDir: trying to find executable on PATH");
195
196
  std::string location = findOnPath(platformDir.c_str());
196
- strncpy(path, location.c_str(), PATH_MAX);
197
- found = true;
197
+ if (location.size() > 0) {
198
+ strncpy(path, location.c_str(), PATH_MAX);
199
+ found = true;
200
+ }
198
201
  }
199
202
 
200
203
  // Check if bin/jruby file exists; this logs a message if not found
data/inc/Makefile-conf.mk CHANGED
@@ -32,7 +32,7 @@ OBJECTFILES = ${OBJECTDIR}/argparser.o \
32
32
 
33
33
  ifdef JAVA_HOME
34
34
  JAVA_INCLUDE = $(subst \,/,${JAVA_HOME})/include
35
- INCLUDES = -I${JAVA_INCLUDE}
35
+ INCLUDES = "-I${JAVA_INCLUDE}"
36
36
  endif
37
37
 
38
38
  ifdef MINGW
@@ -40,7 +40,7 @@ OBJECTFILES += ${OBJECTDIR}/utilsfuncswin.o \
40
40
  ${OBJECTDIR}/platformlauncher.o \
41
41
  ${OBJECTDIR}/jvmlauncher.o \
42
42
  ${OBJECTDIR}/jruby.o
43
- INCLUDES += -I${JAVA_INCLUDE}/win32
43
+ INCLUDES += "-I${JAVA_INCLUDE}/win32"
44
44
  else
45
45
  OBJECTFILES += ${OBJECTDIR}/unixlauncher.o
46
46
  endif
@@ -51,10 +51,10 @@ CXXFLAGS = $(CFLAGS)
51
51
 
52
52
  # Compiler Flags
53
53
  ifeq (mingw,$(CONF))
54
- CFLAGS += -m32 -mno-cygwin -s
54
+ CFLAGS += -m32 -s
55
55
  endif
56
56
  ifeq (mingw64,$(CONF))
57
- CFLAGS += -m64 -mno-cygwin -s
57
+ CFLAGS += -m64 -s
58
58
  endif
59
59
 
60
60
  # Resources
@@ -1,3 +1,3 @@
1
1
  module JRubyLauncher
2
- VERSION = "1.0.14"
2
+ VERSION = "1.0.15"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module JRubyLauncher
2
- VERSION = "1.0.13"
2
+ VERSION = "1.0.15"
3
3
  end
@@ -49,6 +49,16 @@ describe "JRuby native launcher" do
49
49
  end
50
50
  end
51
51
 
52
+ it "should drop the backslashes at the end of JAVA_HOME" do
53
+ with_environment "JAVA_HOME" => File.join("some", "java", "home\\\\") do
54
+ if windows?
55
+ jruby_launcher_args("").join.should =~ %r{some/java/home}
56
+ else
57
+ jruby_launcher_args("").first.should == File.join("some", "java", "home", "bin", "java")
58
+ end
59
+ end
60
+ end
61
+
52
62
  it "should complain about a missing log argument" do
53
63
  jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
54
64
  jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
@@ -102,16 +112,15 @@ describe "JRuby native launcher" do
102
112
 
103
113
  it "should add the contents of the CLASSPATH environment variable" do
104
114
  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/
115
+ classpath_arg(jruby_launcher_args("")).should =~ /some.jar/
107
116
  end
108
117
  end
109
118
 
110
119
  it "should add the classpath elements in proper order" do
111
120
  s = File::PATH_SEPARATOR
112
121
  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/
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/
115
124
  end
116
125
  end
117
126
 
@@ -157,7 +166,7 @@ describe "JRuby native launcher" do
157
166
  end
158
167
 
159
168
  # JRUBY-4608
160
- if Config::CONFIG['target_os'] =~ /darwin/i
169
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
161
170
  it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
162
171
  jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
163
172
  with_environment "JAVA_ENCODING" => "MacRoman" do
@@ -189,7 +198,7 @@ describe "JRuby native launcher" do
189
198
 
190
199
  # JRUBY-4709
191
200
  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 =~
201
+ classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true")).should =~
193
202
  if windows?
194
203
  /;$/
195
204
  else
@@ -9,10 +9,10 @@ end
9
9
 
10
10
  module JRubyLauncherHelper
11
11
  JRUBY_EXE = ''
12
- WINDOWS = Config::CONFIG['target_os'] =~ /mswin/
12
+ WINDOWS = RbConfig::CONFIG['target_os'] =~ /mswin/
13
13
 
14
14
  def self.check_executable_built
15
- exe = File.expand_path("../../jruby", __FILE__) + Config::CONFIG['EXEEXT']
15
+ exe = File.expand_path("../../jruby", __FILE__) + RbConfig::CONFIG['EXEEXT']
16
16
  unless File.executable?(exe)
17
17
  raise "Error: launcher executable not built; type `make' before continuing."
18
18
  end
@@ -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/platformlauncher.cpp CHANGED
@@ -54,8 +54,8 @@ extern "C" int nailgunClientMain(int argc, char *argv[], char *env[]);
54
54
  PlatformLauncher::PlatformLauncher()
55
55
  : ArgParser()
56
56
  , suppressConsole(false)
57
- , separateProcess(false)
58
57
  {
58
+ separateProcess = false;
59
59
  }
60
60
 
61
61
  PlatformLauncher::PlatformLauncher(const PlatformLauncher& orig)
@@ -218,8 +218,9 @@ bool PlatformLauncher::checkJDKHome() {
218
218
 
219
219
  if (jdkhome.empty()) {
220
220
  logMsg("-Xjdkhome is not set, checking for %%JAVA_HOME%%...");
221
- char *javaHome = getenv("JAVA_HOME");
222
- if (javaHome) {
221
+ char *origJavaHome = getenv("JAVA_HOME");
222
+ if (origJavaHome) {
223
+ const char *javaHome = trimTrailingBackslashes(origJavaHome).c_str();
223
224
  logMsg("%%JAVA_HOME%% is set: %s", javaHome);
224
225
  if (!jvmLauncher.initialize(javaHome)) {
225
226
  logMsg("ERROR: Cannot locate java installation, specified by JAVA_HOME: %s", javaHome);
@@ -49,6 +49,16 @@ describe "JRuby native launcher" do
49
49
  end
50
50
  end
51
51
 
52
+ it "should drop the backslashes at the end of JAVA_HOME" do
53
+ with_environment "JAVA_HOME" => File.join("some", "java", "home\\\\") do
54
+ if windows?
55
+ jruby_launcher_args("").join.should =~ %r{some/java/home}
56
+ else
57
+ jruby_launcher_args("").first.should == File.join("some", "java", "home", "bin", "java")
58
+ end
59
+ end
60
+ end
61
+
52
62
  it "should complain about a missing log argument" do
53
63
  jruby_launcher("-Xtrace 2>&1").should =~ /Argument is missing for "-Xtrace"/
54
64
  jruby_launcher("-Xtrace -- 2>&1").should =~ /Argument is missing for "-Xtrace"/
@@ -156,7 +166,7 @@ describe "JRuby native launcher" do
156
166
  end
157
167
 
158
168
  # JRUBY-4608
159
- if Config::CONFIG['target_os'] =~ /darwin/i
169
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
160
170
  it "includes file.encoding=UTF-8 on Mac if JAVA_ENCODING is not set" do
161
171
  jruby_launcher_args("-e true").should include("-Dfile.encoding=UTF-8")
162
172
  with_environment "JAVA_ENCODING" => "MacRoman" do
data/spec/spec_helper.rb CHANGED
@@ -9,10 +9,10 @@ end
9
9
 
10
10
  module JRubyLauncherHelper
11
11
  JRUBY_EXE = ''
12
- WINDOWS = Config::CONFIG['target_os'] =~ /mswin/
12
+ WINDOWS = RbConfig::CONFIG['target_os'] =~ /mswin/
13
13
 
14
14
  def self.check_executable_built
15
- exe = File.expand_path("../../jruby", __FILE__) + Config::CONFIG['EXEEXT']
15
+ exe = File.expand_path("../../jruby", __FILE__) + RbConfig::CONFIG['EXEEXT']
16
16
  unless File.executable?(exe)
17
17
  raise "Error: launcher executable not built; type `make' before continuing."
18
18
  end
data/unixlauncher.cpp CHANGED
@@ -52,7 +52,9 @@ int UnixLauncher::run(int argc, char* argv[], char* envp[]) {
52
52
  if (!jdkhome.empty()) {
53
53
  java = jdkhome + "/bin/java";
54
54
  } else if (getenv("JAVA_HOME") != NULL) {
55
- java = string(getenv("JAVA_HOME")) + "/bin/java";
55
+ string java_home = string(getenv("JAVA_HOME"));
56
+ java_home = trimTrailingBackslashes(java_home);
57
+ java = java_home + "/bin/java";
56
58
  } else {
57
59
  java = findOnPath("java");
58
60
  }
data/utilsfuncs.cpp CHANGED
@@ -144,7 +144,7 @@ string findOnPath(const char* name) {
144
144
 
145
145
  start = sep + 1;
146
146
  }
147
- return NULL;
147
+ return "";
148
148
  }
149
149
 
150
150
  const char* getSysError(char *str, int strSize) {
@@ -269,3 +269,11 @@ void printListToConsole(list<string> values) {
269
269
  std::cout << *it << std::endl;
270
270
  }
271
271
  }
272
+
273
+ string trimTrailingBackslashes(string orig) {
274
+ while (orig.size() > 0 &&
275
+ orig.at(orig.size() - 1) == '\\') {
276
+ orig.erase(orig.size() - 1);
277
+ }
278
+ return orig;
279
+ }
data/utilsfuncs.h CHANGED
@@ -59,6 +59,7 @@ void addToArgList(std::list<std::string> & args, int argc, char ** argv);
59
59
  std::string findOnPath(const char* name);
60
60
  bool checkDirectory(const char* path);
61
61
  void printListToConsole(std::list<std::string> l);
62
+ std::string trimTrailingBackslashes(std::string orig);
62
63
 
63
64
  #ifndef WIN32
64
65
  #define FILE_SEP '/'
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.14"
9
+ #define JRUBY_LAUNCHER_VERSION "1.0.15"
10
10
 
11
11
  #endif // ! _VERSION_H_
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jruby-launcher
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.14
5
+ version: 1.0.15
6
6
  platform: java
7
7
  authors:
8
8
  - Nick Sieger
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-04 00:00:00.000000000 Z
13
+ date: 2012-08-04 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Builds and installs a native launcher for JRuby on your system
16
16
  email:
@@ -76,48 +76,18 @@ files:
76
76
  - !binary |-
77
77
  bGliL3J1YnlnZW1zL2RlZmF1bHRzL2pydWJ5X25hdGl2ZS5yYg==
78
78
  - !binary |-
79
- cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL2V4dGNvbmYucmI=
79
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL2V4dGNvbmYucmI=
80
80
  - !binary |-
81
- cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL2xpYi9qcnVieS1sYXVu
81
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL2xpYi9qcnVieS1sYXVu
82
82
  Y2hlci5yYg==
83
83
  - !binary |-
84
- cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL2xpYi9ydWJ5Z2Vtcy9k
84
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL2xpYi9ydWJ5Z2Vtcy9k
85
85
  ZWZhdWx0cy9qcnVieV9uYXRpdmUucmI=
86
86
  - !binary |-
87
- cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xMi1qYXZhL3NwZWMvbGF1bmNoZXJf
87
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL3NwZWMvbGF1bmNoZXJf
88
88
  c3BlYy5yYg==
89
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
90
+ cGtnL2pydWJ5LWxhdW5jaGVyLTEuMC4xNS1qYXZhL3NwZWMvc3BlY19oZWxw
121
91
  ZXIucmI=
122
92
  - !binary |-
123
93
  c3BlYy9sYXVuY2hlcl9zcGVjLnJi
@@ -154,4 +124,3 @@ signing_key:
154
124
  specification_version: 3
155
125
  summary: Native launcher for JRuby
156
126
  test_files: []
157
- ...
@@ -1,3 +0,0 @@
1
- module JRubyLauncher
2
- VERSION = "1.0.12"
3
- end
@@ -1,223 +0,0 @@
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
@@ -1,7 +0,0 @@
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}
@@ -1,4 +0,0 @@
1
- class Gem::ConfigFile
2
- PLATFORM_DEFAULTS['install'] = '--no-rdoc --no-ri'
3
- PLATFORM_DEFAULTS['update'] = '--no-rdoc --no-ri'
4
- end
@@ -1,7 +0,0 @@
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}
@@ -1,3 +0,0 @@
1
- module JRubyLauncher
2
- VERSION = "1.0.12"
3
- end
@@ -1,4 +0,0 @@
1
- class Gem::ConfigFile
2
- PLATFORM_DEFAULTS['install'] = '--no-rdoc --no-ri'
3
- PLATFORM_DEFAULTS['update'] = '--no-rdoc --no-ri'
4
- end
@@ -1,223 +0,0 @@
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
@@ -1,75 +0,0 @@
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
@@ -1,75 +0,0 @@
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