Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7a73edd2774b
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 715f9bac6798
Choose a head ref
  • 5 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 20, 2016

  1. [test] cleanup command line switches test - avoid -K and let it fail …

    …on Windows
    
    ... for a later review on AppVeyor
    kares committed Mar 20, 2016
    Copy the full SHA
    2e11525 View commit details
  2. Copy the full SHA
    43bf21e View commit details
  3. use throw new ... one-liner

    kares committed Mar 20, 2016
    Copy the full SHA
    5a7c6f1 View commit details
  4. Copy the full SHA
    1214490 View commit details
  5. Copy the full SHA
    715f9ba View commit details
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -419,7 +419,6 @@ private Status handleMainExit(MainExitException mee) {
}

private Status doRunFromMain(Ruby runtime, InputStream in, String filename) {
long now = -1;
try {
doCheckSecurityManager();

@@ -485,10 +484,6 @@ private void doSetContextClassLoader(Ruby runtime) {
}
}

private void doProcessArguments(InputStream in) {
config.processArguments(config.parseShebangOptions(in));
}

private void doPrintProperties() {
if (config.getShouldPrintProperties()) {
config.getOutput().print(OutputStrings.getPropertyHelp());
12 changes: 4 additions & 8 deletions core/src/main/java/org/jruby/util/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
@@ -213,12 +213,10 @@ private void processArgument() {
config.setCurrentDirectory(new File(base, newDir.getPath()).getCanonicalPath());
}
if (!(new File(config.getCurrentDirectory()).isDirectory()) && !config.getCurrentDirectory().startsWith("uri:classloader:")) {
MainExitException mee = new MainExitException(1, "jruby: Can't chdir to " + saved + " (fatal)");
throw mee;
throw new MainExitException(1, "jruby: Can't chdir to " + saved + " (fatal)");
}
} catch (IOException e) {
MainExitException mee = new MainExitException(1, getArgumentError(" -C must be followed by a valid directory"));
throw mee;
throw new MainExitException(1, getArgumentError(" -C must be followed by a valid directory"));
}
break FOR;
case 'd':
@@ -359,14 +357,12 @@ private void processArgument() {
config.setCurrentDirectory(new File(base, newDir.getPath()).getCanonicalPath());
}
if (!(new File(config.getCurrentDirectory()).isDirectory()) && !config.getCurrentDirectory().startsWith("uri:classloader:")) {
MainExitException mee = new MainExitException(1, "jruby: Can't chdir to " + saved + " (fatal)");
throw mee;
throw new MainExitException(1, "jruby: Can't chdir to " + saved + " (fatal)");
}
}
config.setXFlag(true);
} catch (IOException e) {
MainExitException mee = new MainExitException(1, getArgumentError(" -x must be followed by a valid directory"));
throw mee;
throw new MainExitException(1, getArgumentError(" -x must be followed by a valid directory"));
}
break FOR;
case 'X':
88 changes: 38 additions & 50 deletions test/jruby/test_command_line_switches.rb
Original file line number Diff line number Diff line change
@@ -6,14 +6,13 @@
class TestCommandLineSwitches < Test::Unit::TestCase
include TestHelper

# FIXME: currently fails on Windows
if (!WINDOWS and not IS_JAR_EXECUTION)
def test_dash_0_splits_records
output = jruby_with_pipe("echo '1,2,3'", %Q{ -054 --disable-gems -n -e 'puts $_ + " "'})
assert_equal 0, $?.exitstatus
assert_equal "1, ,2, ,3\n ,", output
end
end
def test_dash_0_splits_records
# pend 'FIXME: currently fails on Windows' if WINDOWS

output = jruby_with_pipe("echo '1,2,3'", %Q{ -054 --disable-gems -n -e 'puts $_ + " "'})
assert_equal 0, $?.exitstatus
assert_equal "1, ,2, ,3\n ,", output
end if IS_JAR_EXECUTION

def test_dash_little_c_checks_syntax
with_jruby_shell_spawning do
@@ -35,24 +34,20 @@ def test_dash_little_c_checks_syntax_only

# TODO -l: no idea what line ending processing is
def test_dash_little_n_wraps_script_with_while_gets
# FIXME: currently fails on windows and IBM JDK
unless WINDOWS || IBM_JVM
with_temp_script(%q{ puts "#{$_}#{$_}" }) do |s|
output = IO.popen("echo \"a\nb\" | #{RUBY} -n #{s.path}", "r") { |p| p.read }
assert_equal 0, $?.exitstatus
assert_equal "a\na\nb\nb\n", output
end
# pend 'FIXME: currently fails on Windows and IBM JDK' if WINDOWS # || IBM_JVM
with_temp_script(%q{ puts "#{$_}#{$_}" }) do |s|
output = IO.popen("echo \"a\nb\" | #{RUBY} -n #{s.path}", "r") { |p| p.read }
assert_equal 0, $?.exitstatus
assert_equal "a\na\nb\nb\n", output
end
end

def test_dash_little_p_wraps_script_with_while_gets_and_prints
# FIXME: currently fails on Windows and IBM JDK
unless WINDOWS || IBM_JVM
with_temp_script(%q{ puts "#{$_}#{$_}" }) do |s|
output = IO.popen("echo \"a\nb\" | #{RUBY} -p #{s.path}", "r") { |p| p.read }
assert_equal 0, $?.exitstatus
assert_equal "a\na\na\nb\nb\nb\n", output
end
# pend 'FIXME: currently fails on Windows and IBM JDK' if WINDOWS # || IBM_JVM
with_temp_script(%q{ puts "#{$_}#{$_}" }) do |s|
output = IO.popen("echo \"a\nb\" | #{RUBY} -p #{s.path}", "r") { |p| p.read }
assert_equal 0, $?.exitstatus
assert_equal "a\na\na\nb\nb\nb\n", output
end
end

@@ -106,7 +101,6 @@ def test_dash_big_S_resolves_absolute___FILE___correctly
end

def test_dash_big_S_resolves_relative___FILE___correctly

with_temp_script(%q{puts __FILE__}) do |s|
Dir.chdir(Dir.tmpdir) do
relative_tmp = File.basename(s.path)
@@ -120,7 +114,7 @@ def test_dash_big_S_resolves_relative___FILE___correctly

def test_dash_little_v_version_verbose_T_taint_d_debug_K_kcode_r_require_b_benchmarks_a_splitsinput_I_loadpath_C_cwd_F_delimeter_J_javaprop_19
e_line = 'puts $VERBOSE, $SAFE, $DEBUG, Encoding.default_external, $F.join(59.chr), $LOAD_PATH.join(44.chr), Dir.pwd, Java::java::lang::System.getProperty(:foo.to_s)'
args = "-v -T3 -d -Ku -a -n -Ihello -C .. -F, -e #{q + e_line + q}"
args = "-v -T3 -d -a -n -Ihello -C .. -F, -e #{q + e_line + q}"
# the options at the end will add -J-Dfoo=bar to the args
lines = jruby_with_pipe("echo 1,2,3", args, :foo => 'bar').split("\n")
assert_equal 0, $?.exitstatus, "failed execution with output:\n#{lines}"
@@ -157,7 +151,7 @@ def test_dash_big_C
end

def test_dash_big_C_error
out = jruby('-CaeAEUAOEUAeu_NOT_EXIST_xxx -e "puts Dir.pwd"').rstrip
out = jruby('-CaeAEUAOEUAeu_NOT_EXIST_xxx -e "puts Dir.pwd" 2>&1').rstrip
assert_equal 1, $?.exitstatus
assert_match /chdir.*fatal/, out
end
@@ -284,37 +278,31 @@ def test_blank_arg_ends_arg_processing
end

# JRUBY-4288
if (WINDOWS)
def test_case_insensitive_jruby
weird_jruby = '"' + File.join([RbConfig::CONFIG['bindir'], 'jRuBy']) << RbConfig::CONFIG['EXEEXT'] + '"'
with_jruby_shell_spawning do
res = `cmd.exe /c #{weird_jruby} -e "puts 1"`.rstrip
assert_equal '1', res
assert_equal 0, $?.exitstatus
end
def test_case_insensitive_jruby
weird_jruby = '"' + File.join([RbConfig::CONFIG['bindir'], 'jRuBy']) << RbConfig::CONFIG['EXEEXT'] + '"'
with_jruby_shell_spawning do
res = `cmd.exe /c #{weird_jruby} -e "puts 1"`.rstrip
assert_equal '1', res
assert_equal 0, $?.exitstatus
end
end
end if WINDOWS

# JRUBY-4289
if (WINDOWS)
def test_uppercase_exe
weird_jruby = '"' + File.join([RbConfig::CONFIG['bindir'], 'jRuBy']) << '.ExE' + '"'
with_jruby_shell_spawning do
res = `#{weird_jruby} -e "puts 1"`.rstrip
assert_equal '1', res
assert_equal 0, $?.exitstatus
end
def test_uppercase_exe
weird_jruby = '"' + File.join([RbConfig::CONFIG['bindir'], 'jRuBy']) << '.ExE' + '"'
with_jruby_shell_spawning do
res = `#{weird_jruby} -e "puts 1"`.rstrip
assert_equal '1', res
assert_equal 0, $?.exitstatus
end
end
end if WINDOWS

# JRUBY-4290
if (WINDOWS)
def test_uppercase_in_process
version = `rUbY.ExE -v`.rstrip
assert_equal 0, $?.exitstatus
assert_match /java/, version
end
end
def test_uppercase_in_process
version = `rUbY.ExE -v`.rstrip
assert_equal 0, $?.exitstatus
assert_match /java/, version
end if WINDOWS

# JRUBY-4783
def test_rubyopts_with_require
12 changes: 9 additions & 3 deletions test/jruby/test_helper.rb
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ def jruby(*args)
args = args[0..-2]
end
options.each { |k,v| args.unshift "-J-D#{k}=\"#{v}\"" } unless RUBY =~ /-cp /
with_jruby_shell_spawning { `#{interpreter(options)} #{args.join(' ')}` }
with_jruby_shell_spawning { sh "#{interpreter(options)} #{args.join(' ')}" }
end

def jruby_with_pipe(pipe, *args)
@@ -76,9 +76,15 @@ def jruby_with_pipe(pipe, *args)
args = args[0..-2]
end
options.each { |k,v| args.unshift "-J-D#{k}=\"#{v}\"" } unless RUBY =~ /-cp /
with_jruby_shell_spawning { `#{pipe} | #{interpreter(options)} #{args.join(' ')}` }
with_jruby_shell_spawning { sh "#{pipe} | #{interpreter(options)} #{args.join(' ')}" }
end

def sh(cmd)
puts cmd if $VERBOSE
return `#{cmd}`
end
private :sh

def with_temp_script(script, filename="test-script")
Tempfile.open([filename, ".rb"]) do |f|
begin
@@ -138,4 +144,4 @@ def skip(msg = nil)
end
end

end
end