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: 445303211985^
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f015910fd917
Choose a head ref
  • 5 commits
  • 8 files changed
  • 1 contributor

Commits on Oct 10, 2014

  1. Copy the full SHA
    4453032 View commit details
  2. Copy the full SHA
    9fe0120 View commit details
  3. Copy the full SHA
    8499cf8 View commit details
  4. Copy the full SHA
    a486ddc View commit details
  5. Copy the full SHA
    f015910 View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@ public void tryProcessArgumentsWithRubyopts() {

if (rubyopt.split("\\s").length != 0) {
String[] rubyoptArgs = rubyopt.split("\\s+");
new ArgumentProcessor(rubyoptArgs, false, true, this).processArguments();
new ArgumentProcessor(rubyoptArgs, false, true, true, this).processArguments();
}
} catch (SecurityException se) {
// ignore and do nothing
34 changes: 32 additions & 2 deletions core/src/main/java/org/jruby/util/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
@@ -72,15 +72,16 @@ public String toString() {
private List<Argument> arguments;
private int argumentIndex = 0;
private boolean processArgv;
private final boolean rubyOpts;
RubyInstanceConfig config;
private boolean endOfArguments = false;
private int characterIndex = 0;

public ArgumentProcessor(String[] arguments, RubyInstanceConfig config) {
this(arguments, true, false, config);
this(arguments, true, false, false, config);
}

public ArgumentProcessor(String[] arguments, boolean processArgv, boolean dashed, RubyInstanceConfig config) {
public ArgumentProcessor(String[] arguments, boolean processArgv, boolean dashed, boolean rubyOpts, RubyInstanceConfig config) {
this.config = config;
this.arguments = new ArrayList<Argument>();
if (arguments != null && arguments.length > 0) {
@@ -89,6 +90,7 @@ public ArgumentProcessor(String[] arguments, boolean processArgv, boolean dashed
}
}
this.processArgv = processArgv;
this.rubyOpts = rubyOpts;
}

public void processArguments() {
@@ -161,6 +163,7 @@ private void processArgument() {
switch (argument.charAt(characterIndex)) {
case '0':
{
disallowedInRubyOpts(argument);
String temp = grabOptionalValue();
if (null == temp) {
config.setRecordSeparator("\u0000");
@@ -184,9 +187,11 @@ private void processArgument() {
config.setSplit(true);
break;
case 'c':
disallowedInRubyOpts(argument);
config.setShouldCheckSyntax(true);
break;
case 'C':
disallowedInRubyOpts(argument);
try {
String saved = grabValue(getArgumentError(" -C must be followed by a directory expression"));
File base = new File(config.getCurrentDirectory());
@@ -210,6 +215,7 @@ private void processArgument() {
config.setVerbosity(RubyInstanceConfig.Verbosity.TRUE);
break;
case 'e':
disallowedInRubyOpts(argument);
config.getInlineScript().append(grabValue(getArgumentError(" -e must be followed by an expression to report")));
config.getInlineScript().append('\n');
config.setHasInlineScript(true);
@@ -218,13 +224,16 @@ private void processArgument() {
processEncodingOption(grabValue(getArgumentError("unknown encoding name")));
break FOR;
case 'F':
disallowedInRubyOpts(argument);
config.setInputFieldSeparator(grabValue(getArgumentError(" -F must be followed by a pattern for input field separation")));
break FOR;
case 'h':
disallowedInRubyOpts(argument);
config.setShouldPrintUsage(true);
config.setShouldRunInterpreter(false);
break;
case 'i':
disallowedInRubyOpts(argument);
config.setInPlaceBackupExtension(grabOptionalValue());
if (config.getInPlaceBackupExtension() == null) {
config.setInPlaceBackupExtension("");
@@ -257,13 +266,16 @@ private void processArgument() {

break;
case 'l':
disallowedInRubyOpts(argument);
config.setProcessLineEnds(true);
break;
case 'n':
disallowedInRubyOpts(argument);
config.setAssumeLoop(true);
config.setKernelGsubDefined(true);
break;
case 'p':
disallowedInRubyOpts(argument);
config.setAssumePrinting(true);
config.setAssumeLoop(true);
config.setKernelGsubDefined(true);
@@ -272,12 +284,14 @@ private void processArgument() {
config.getRequiredLibraries().add(grabValue(getArgumentError("-r must be followed by a package to require")));
break FOR;
case 's':
disallowedInRubyOpts(argument);
config.setArgvGlobalsOn(true);
break;
case 'G':
config.setLoadGemfile(true);
break;
case 'S':
disallowedInRubyOpts(argument);
runBinScript();
break FOR;
case 'T':
@@ -316,6 +330,7 @@ private void processArgument() {
break FOR;
}
case 'x':
disallowedInRubyOpts(argument);
try {
String saved = grabOptionalValue();
if (saved != null) {
@@ -338,6 +353,7 @@ private void processArgument() {
}
break FOR;
case 'X':
disallowedInRubyOpts(argument);
String extendedOption = grabOptionalValue();
if (extendedOption == null) {
if (SafePropertyAccessor.getBoolean("jruby.launcher.nopreamble", false)) {
@@ -370,6 +386,7 @@ private void processArgument() {
}
break FOR;
case 'y':
disallowedInRubyOpts(argument);
config.setParserDebug(true);
break FOR;
case '-':
@@ -383,10 +400,12 @@ private void processArgument() {
config.getError().println("warning: " + argument + " ignored");
break FOR;
} else if (argument.equals("--copyright")) {
disallowedInRubyOpts(argument);
config.setShowCopyright(true);
config.setShouldRunInterpreter(false);
break FOR;
} else if (argument.equals("--debug")) {
disallowedInRubyOpts(argument);
RubyInstanceConfig.FULL_TRACE_ENABLED = true;
config.setCompileMode(RubyInstanceConfig.CompileMode.OFF);
break FOR;
@@ -395,6 +414,7 @@ private void processArgument() {
config.setVerbosity(RubyInstanceConfig.Verbosity.TRUE);
break;
} else if (argument.equals("--help")) {
disallowedInRubyOpts(argument);
config.setShouldPrintUsage(true);
config.setShouldRunInterpreter(false);
break;
@@ -403,6 +423,7 @@ private void processArgument() {
config.setShouldRunInterpreter(false);
break;
} else if (argument.equals("--version")) {
disallowedInRubyOpts(argument);
config.setShowVersion(true);
config.setShouldRunInterpreter(false);
break FOR;
@@ -529,6 +550,9 @@ private void processArgument() {
} else if (argument.equals("--client")) {
// ignore this...can't do anything with it after boot
break FOR;
} else if (argument.equals("--yydebug") && Options.COMPLIANCE_STRICT.load()) {
disallowedInRubyOpts(argument);
config.setParserDebug(true);
} else {
if (argument.equals("--")) {
// ruby interpreter compatibilty
@@ -543,6 +567,12 @@ private void processArgument() {
}
}

private void disallowedInRubyOpts(String option) {
if (rubyOpts && Options.COMPLIANCE_STRICT.load()) {
throw new MainExitException(1, "jruby: invalid switch in RUBYOPT: " + option + " (RuntimeError)");
}
}

private void errorMissingDisable() {
MainExitException mee;
mee = new MainExitException(1, "missing argument for --disable\n");
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/util/cli/Category.java
Original file line number Diff line number Diff line change
@@ -45,7 +45,8 @@ public enum Category {
DEBUG("debugging and logging"),
JAVA_INTEGRATION("java integration"),
PROFILING("profiling"),
CLI("command line options");
CLI("command line options"),
COMPLIANCE("compliance options");

Category(String desc) {
this.desc = desc;
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -244,6 +244,8 @@ public class Options {
public static final Option<Boolean> CLI_STRIP_HEADER = bool(CLI, "cli.strip.header", false, "Strip text before shebang in script. Same as -x.");
public static final Option<Boolean> CLI_LOAD_GEMFILE = bool(CLI, "cli.load.gemfile", false, "Load a bundler Gemfile in cwd before running. Same as -G.");

public static final Option<Boolean> COMPLIANCE_STRICT = bool(COMPLIANCE, "compliance.strict", false, "Comply strictly with RubySpec.");

static {
// FIXME: JIT only on when invokedynamic would be one...need non-indy JIT
if (!COMPILE_INVOKEDYNAMIC.load()) {
5 changes: 5 additions & 0 deletions spec/truffle/spec-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# Workaround for RubySpec #292

bin/jruby -X+T -Xparser.warn.useless_use_of=false -Xparser.warn.not_reached=false -Xparser.warn.grouped_expressions=false -Xparser.warn.shadowing_local=false -Xparser.warn.regex_condition=false -Xparser.warn.argument_prefix=false -Xcompliance.strict=true -J-ea "$@"
20 changes: 1 addition & 19 deletions spec/truffle/tags/language/predefined_tags.txt
Original file line number Diff line number Diff line change
@@ -44,25 +44,6 @@ fails:Processing RUBYOPT sets $VERBOSE to false for '-W1'
fails:Processing RUBYOPT sets $VERBOSE to true for '-W2'
fails:Processing RUBYOPT requires the file for '-r'
fails:Processing RUBYOPT raises a RuntimeError for '-a'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-p'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-n'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-y'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-c'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-s'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-h'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '--help'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-l'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-S'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-e'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-i'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-x'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-C'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-X'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-F'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '-0'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '--copyright'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '--version'
fails(inherited):Processing RUBYOPT raises a RuntimeError for '--yydebug'
fails:The predefined global constant STDERR has nil for the external encoding despite Encoding.default_external being changed
fails:The predefined global constant STDERR has the encodings set by #set_encoding
fails:The predefined global constant ARGV contains Strings encoded in locale Encoding
@@ -81,3 +62,4 @@ fails:The predefined global constant STDIN has the encodings set by #set_encodin
fails:The predefined global constant STDIN has the same external encoding as Encoding.default_external when that encoding is changed
fails:The predefined global constant STDIN has the same external encoding as Encoding.default_external
fails:Processing RUBYOPT prints the version number for '-v'
fails:Processing RUBYOPT adds the -I path to $LOAD_PATH
78 changes: 44 additions & 34 deletions test/pom.rb
Original file line number Diff line number Diff line change
@@ -152,27 +152,32 @@
'<arg value="-Xparser.warn.shadowing_local=false" />' +
'<arg value="-Xparser.warn.regex_condition=false" />' +
'<arg value="-Xparser.warn.argument_prefix=false" />' +
'<arg value="-Xcompliance.strict=true" />' +
'<arg value="-J-ea" />' +
'<arg value="spec/mspec/bin/mspec" />' +
'<arg value="run" />' +
'<arg value="-t" />' +
'<arg value="bin/jruby" />' +
'<arg value="-T" />' +
'<arg value="-X+T" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.useless_use_of=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.not_reached=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.grouped_expressions=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.shadowing_local=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.regex_condition=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.argument_prefix=false" />' +
'<arg value="-T" />' +
'<arg value="-J-ea" />' +
# Workaround for RubySpec #292
'<arg value="spec/mspec/bin/mspec" />' +
#'<arg value="bin/jruby" />' +
#'<arg value="-T" />' +
#'<arg value="-X+T" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.useless_use_of=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.not_reached=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.grouped_expressions=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.shadowing_local=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.regex_condition=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.argument_prefix=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xcompliance.strict=true" />' +
#'<arg value="-T" />' +
#'<arg value="-J-ea" />' +
'<arg value="--config" />' +
'<arg value="spec/truffle/truffle.mspec" />' +
'<arg value="--excl-tag" />' +
@@ -200,27 +205,32 @@
'<arg value="-Xparser.warn.shadowing_local=false" />' +
'<arg value="-Xparser.warn.regex_condition=false" />' +
'<arg value="-Xparser.warn.argument_prefix=false" />' +
'<arg value="-Xcompliance.strict=true" />' +
'<arg value="-J-ea" />' +
'<arg value="spec/mspec/bin/mspec" />' +
'<arg value="run" />' +
'<arg value="-t" />' +
'<arg value="bin/jruby" />' +
'<arg value="-T" />' +
'<arg value="-X+T" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.useless_use_of=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.not_reached=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.grouped_expressions=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.shadowing_local=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.regex_condition=false" />' +
'<arg value="-T" />' +
'<arg value="-Xparser.warn.argument_prefix=false" />' +
'<arg value="-T" />' +
'<arg value="-J-ea" />' +
# Workaround for RubySpec #292
'<arg value="spec/mspec/bin/mspec" />' +
#'<arg value="bin/jruby" />' +
#'<arg value="-T" />' +
#'<arg value="-X+T" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.useless_use_of=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.not_reached=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.grouped_expressions=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.shadowing_local=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.regex_condition=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xparser.warn.argument_prefix=false" />' +
#'<arg value="-T" />' +
#'<arg value="-Xcompliance.strict=true" />' +
#'<arg value="-T" />' +
#'<arg value="-J-ea" />' +
'<arg value="--config" />' +
'<arg value="spec/truffle/truffle.mspec" />' +
'<arg value="--excl-tag" />' +
Loading