Skip to content

Commit

Permalink
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 0 additions & 8 deletions spec/truffle/tags/core/kernel/exec_tags.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
fails:Kernel#exec raises Errno::ENOENT for an empty string
fails:Kernel#exec raises Errno::ENOENT for a command which does not exist
fails:Kernel#exec raises an ArgumentError if the command includes a null byte
fails:Kernel#exec raises Errno::EACCES when the file does not have execute permissions
fails:Kernel#exec raises Errno::EACCES when passed a directory
fails:Kernel#exec runs the specified command, replacing current process
fails:Kernel#exec sets the current directory when given the :chdir option
fails:Kernel#exec with a single argument subjects the specified command to shell expansion
@@ -14,11 +10,7 @@ fails:Kernel#exec (environment variables) unsets other environment variables whe
fails:Kernel#exec with a command array uses the first element as the command name and the second as the argv[0] value
fails:Kernel#exec with a command array coerces the argument using to_ary
fails:Kernel#exec with a command array raises an ArgumentError if the Array does not have exactly two elements
fails:Kernel.exec raises Errno::ENOENT for an empty string
fails:Kernel.exec raises Errno::ENOENT for a command which does not exist
fails:Kernel.exec raises an ArgumentError if the command includes a null byte
fails:Kernel.exec raises Errno::EACCES when the file does not have execute permissions
fails:Kernel.exec raises Errno::EACCES when passed a directory
fails:Kernel.exec runs the specified command, replacing current process
fails:Kernel.exec sets the current directory when given the :chdir option
fails:Kernel.exec with a single argument subjects the specified command to shell expansion
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Errno;
import org.jcodings.Encoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.common.IRubyWarnings;
@@ -739,8 +740,14 @@ private void exec(RubyContext context, DynamicObject envAsHash, String[] command
try {
process = builder.start();
} catch (IOException e) {
// TODO(cs): proper Ruby exception
throw new JavaException(e);
if (e.getMessage().contains("Permission denied")) {
throw new RaiseException(getContext().getCoreExceptions().errnoError(Errno.EACCES.intValue(), this));
} else if (e.getMessage().contains("No such file or directory")) {
throw new RaiseException(getContext().getCoreExceptions().errnoError(Errno.ENOENT.intValue(), this));
} else {
// TODO(cs): proper Ruby exception
throw new JavaException(e);
}
}

int exitCode = context.getThreadManager().runUntilResult(this, new BlockingAction<Integer>() {

0 comments on commit 77647a5

Please sign in to comment.