Skip to content

Commit

Permalink
Showing 5 changed files with 25 additions and 7 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -109,6 +109,3 @@ class MSpecScript
set :files, get(:language) + get(:core) + get(:rubysl)

end

# TODO (nirvdrum 11-Feb-15) Remove this hack once our File.expand_path doesn't translate '\' & '/' ... until then, we need feed this path through it to get consistent results in the specs.
SPEC_TEMP_DIR = File.expand_path "#{File.expand_path(Dir.pwd)}/rubyspec_temp"
Original file line number Diff line number Diff line change
@@ -277,7 +277,7 @@ public ExpandPathNode(ExpandPathNode prev) {

@Specialization
public RubyString expandPath(RubyString path, @SuppressWarnings("unused") UndefinedPlaceholder dir) {
return getContext().makeString(RubyFile.expandPath(path.toString()));
return getContext().makeString(RubyFile.expandPath(getContext(), path.toString()));
}

@Specialization
Original file line number Diff line number Diff line change
@@ -72,6 +72,8 @@ public class RubyContext extends ExecutionContext {

private final AtomicLong nextObjectID = new AtomicLong(ObjectIDOperations.FIRST_OBJECT_ID);

private final boolean runningOnWindows;

public RubyContext(Ruby runtime) {
assert runtime != null;

@@ -116,6 +118,8 @@ public RubyContext(Ruby runtime) {
if (Options.TRUFFLE_STACK_SERVER_PORT.load() != 0) {
new StackServerManager(this, Options.TRUFFLE_STACK_SERVER_PORT.load()).start();
}

runningOnWindows = System.getProperty("os.name").toLowerCase().indexOf("win") >= 0;
}

public Shape getEmptyShape() {
@@ -142,6 +146,10 @@ public static String checkClassVariableName(RubyContext context, String name, Ru
return name;
}

public boolean isRunningOnWindows() {
return runningOnWindows;
}

public void loadFile(String fileName, RubyNode currentNode) {
if (new File(fileName).isAbsolute()) {
loadFileAbsolute(fileName, currentNode);
17 changes: 15 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/runtime/core/RubyFile.java
Original file line number Diff line number Diff line change
@@ -49,8 +49,21 @@ public void close() {
}
}

public static String expandPath(String fileName) {
return expandPath(fileName, null);
public static String expandPath(RubyContext context, String fileName) {
RubyNode.notDesignedForCompilation();

// TODO (nirvdrum 11-Feb-15) This needs to work on Windows without calling into non-Truffle JRuby.
if (context.isRunningOnWindows()) {
final org.jruby.RubyString path = context.toJRuby(context.makeString(fileName));
final org.jruby.RubyString expanded = (org.jruby.RubyString) org.jruby.RubyFile.expand_path19(
context.getRuntime().getCurrentContext(),
null,
new org.jruby.runtime.builtin.IRubyObject[] { path });

return expanded.asJavaString();
} else {
return expandPath(fileName, null);
}
}

public static String expandPath(String fileName, String dir) {
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ private boolean requireFile(String fileName, RubyNode currentNode) throws IOExce
return false;
}

final String expandedPath = RubyFile.expandPath(fileName);
final String expandedPath = RubyFile.expandPath(context, fileName);

for (Object loaded : Arrays.asList(context.getCoreLibrary().getLoadedFeatures().slowToArray())) {
if (loaded.toString().equals(expandedPath)) {

0 comments on commit fec1f7a

Please sign in to comment.