|
From: David C. <dc...@us...> - 2005-10-02 20:50:43
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8121/src/org/rubypeople/rdt/internal/launching Modified Files: RubyInterpreter.java Added Files: CommandExecutor.java StandardCommandExecutor.java Log Message: Added additional UTs for launching. Moved tests to the correct package. Slight refactoring of launching code. --- NEW FILE: StandardCommandExecutor.java --- /** * */ package org.rubypeople.rdt.internal.launching; import java.io.File; import java.io.IOException; class StandardCommandExecutor implements CommandExecutor { public Process exec(String[] command, File workingDirectory) throws IOException { return Runtime.getRuntime().exec(command, null, workingDirectory); } } --- NEW FILE: CommandExecutor.java --- package org.rubypeople.rdt.internal.launching; import java.io.File; import java.io.IOException; public interface CommandExecutor { public Process exec(String[] command, File workingDirectory) throws IOException; } Index: RubyInterpreter.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** RubyInterpreter.java 25 Sep 2005 17:57:01 -0000 1.13 --- RubyInterpreter.java 1 Oct 2005 22:58:08 -0000 1.14 *************** *** 18,27 **** protected String name; public RubyInterpreter(String aName, IPath validInstallLocation) { ! name = aName; ! installLocation = validInstallLocation; } ! public IPath getInstallLocation() { return installLocation; } --- 18,34 ---- protected String name; + private final CommandExecutor commandExecutor; + public RubyInterpreter(String aName, IPath validInstallLocation) { ! this(aName, validInstallLocation, new StandardCommandExecutor()); } ! public RubyInterpreter(String aName, IPath validInstallLocation, CommandExecutor commandExecutor) { ! name = aName; ! installLocation = validInstallLocation; ! this.commandExecutor = commandExecutor; ! } ! ! public IPath getInstallLocation() { return installLocation; } *************** *** 55,64 **** rubyCmd.add(this.getCommand()); rubyCmd.addAll(args); ! return Runtime.getRuntime().exec((String[]) rubyCmd.toArray(new String[0]), null, workingDirectory); } catch (IOException e) { ! throw new RuntimeException("Unable to execute interpreter: " + args + workingDirectory); } ! catch (IllegalCommandException ex) { ! IStatus errorStatus = new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.OK, ex.getMessage(), null); throw new CoreException(errorStatus) ; } --- 62,73 ---- rubyCmd.add(this.getCommand()); rubyCmd.addAll(args); ! return commandExecutor.exec((String[]) rubyCmd.toArray(new String[0]), workingDirectory); } catch (IOException e) { ! IStatus errorStatus = new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.OK, ! "Unable to execute interpreter: " + args + workingDirectory, e); ! throw new CoreException(errorStatus) ; } ! catch (IllegalCommandException e) { ! IStatus errorStatus = new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e); throw new CoreException(errorStatus) ; } |