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

Commits on Jun 16, 2016

  1. Copy the full SHA
    c2c4655 View commit details
  2. [Truffle] Fix the value of __FILE__ for the main script.

    * This might pass a relative path to SourceLoader/SourceCache
      but this is the only file which needs it. It is still "canonical"
      as it's the only relative path.
    eregon committed Jun 16, 2016
    Copy the full SHA
    07cecbb View commit details
6 changes: 6 additions & 0 deletions spec/ruby/language/fixtures/dollar_zero.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
puts $0
puts __FILE__

if $0 == __FILE__
print "OK"
end
7 changes: 7 additions & 0 deletions spec/ruby/language/predefined_spec.rb
Original file line number Diff line number Diff line change
@@ -906,6 +906,13 @@ def obj.foo2; yield; end
$0 = @orig_program_name
end

it "is the path given as the main script and the same as __FILE__" do
script = "fixtures/dollar_zero.rb"
Dir.chdir(File.dirname(__FILE__)) do
ruby_exe(script).should == "#{script}\n#{script}\nOK"
end
end

it "returns the program name" do
$0 = "rbx"
$0.should == "rbx"
1 change: 1 addition & 0 deletions spec/truffle/tags/language/predefined_tags.txt
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ slow:The predefined global constant STDIN has the encodings set by #set_encoding
slow:The predefined global constant STDOUT has the encodings set by #set_encoding
slow:The predefined global constant ARGV contains Strings encoded in locale Encoding
linux:Global variable $0 actually sets the program name
slow:Global variable $0 is the path given as the main script and the same as __FILE__
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ public RubyContext context() {
public abstract static class RunJRubyRootNode extends CoreMethodArrayArgumentsNode {

@Specialization
public Object runJRubyRootNode(VirtualFrame frame, @Cached("create()")IndirectCallNode callNode) {
public Object runJRubyRootNode(VirtualFrame frame, @Cached("create()") IndirectCallNode callNode) {
coreLibrary().getGlobalVariables().put(
"$0",
StringOperations.createString(getContext(),
@@ -100,10 +100,6 @@ public Object runJRubyRootNode(VirtualFrame frame, @Cached("create()")IndirectCa
final Source source;

try {
if (!inputFile.equals("-e")) {
inputFile = new File(inputFile).getCanonicalPath();
}

source = getContext().getSourceCache().getSource(inputFile);
} catch (IOException e) {
throw new RuntimeException(e);
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ public Source load(String canonicalPath) throws IOException {
if (!file.canRead()) {
throw new IOException("Can't read file " + canonicalPath);
}
assert file.getCanonicalPath().equals(canonicalPath) : canonicalPath;
return Source.fromFileName(canonicalPath);
}
}