Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Change IronPython and IronRuby Run without Debugger menu option to pa…
Browse files Browse the repository at this point in the history
…use the console output after the run is complete.
  • Loading branch information
mrward committed Sep 24, 2010
1 parent 3d40273 commit ee134f9
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 30 deletions.
Expand Up @@ -48,7 +48,8 @@ public override void Run()
if (Debug) {
debugger.Start(processStartInfo);
} else {
debugger.StartWithoutDebugging(processStartInfo);
PauseCommandPromptProcessStartInfo pauseCommandPrompt = new PauseCommandPromptProcessStartInfo(processStartInfo);
debugger.StartWithoutDebugging(pauseCommandPrompt.ProcessStartInfo);
}
}

Expand Down
Expand Up @@ -50,18 +50,18 @@ public void Run_PythonFileOpen_DebuggerStartWithoutDebuggingMethodCalled()
}

[Test]
public void Run_PythonFileOpen_IronPythonConsoleFileNamePassedToDebugger()
public void Run_PythonFileOpen_CommandPromptExePassedToDebugger()
{
string fileName = debugger.ProcessStartInfo.FileName;
string expectedFileName = @"C:\IronPython\ipy.exe";
string expectedFileName = "cmd.exe";
Assert.AreEqual(expectedFileName, fileName);
}

[Test]
public void Run_PythonFileOpen_PythonFileNamePassedToIronPythonConsole()
public void Run_PythonFileOpen_IronPythonConsoleAndPythonFileNameAndPausePassedAsCommandLineArguments()
{
string args = debugger.ProcessStartInfo.Arguments;
string expectedArgs = "\"C:\\Projects\\test.py\"";
string expectedArgs = "/c \"C:\\IronPython\\ipy.exe \"C:\\Projects\\test.py\"\" & pause";
Assert.AreEqual(expectedArgs, args);
}

Expand Down
2 changes: 1 addition & 1 deletion src/AddIns/BackendBindings/Ruby/RubyBinding.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.6511
# SharpDevelop 4.0.0.6676
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding", "RubyBinding\Project\RubyBinding.csproj", "{C896FFFF-5B6C-4B0E-B6DF-049865F501B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding.Tests", "RubyBinding\Test\RubyBinding.Tests.csproj", "{01DF0475-0CB2-4E81-971B-BADC60CDE3A5}"
Expand Down
Expand Up @@ -43,10 +43,12 @@ public RunRubyCommand(IScriptingWorkbench workbench, RubyAddInOptions options, I

public override void Run()
{
ProcessStartInfo processStartInfo = CreateProcessStartInfo();
if (debug) {
debugger.Start(CreateProcessStartInfo());
debugger.Start(processStartInfo);
} else {
debugger.StartWithoutDebugging(CreateProcessStartInfo());
PauseCommandPromptProcessStartInfo commandPrompt = new PauseCommandPromptProcessStartInfo(processStartInfo);
debugger.StartWithoutDebugging(commandPrompt.ProcessStartInfo);
}
}

Expand Down
Expand Up @@ -13,13 +13,13 @@
namespace RubyBinding.Tests.Gui
{
[TestFixture]
public class DebugRubyCommandTestFixture
public class DebugRubyCommandTests
{
MockDebugger debugger;
RunDebugRubyCommand command;

[TestFixtureSetUp]
public void SetUpFixture()
[SetUp]
public void Init()
{
MockWorkbench workbench = MockWorkbench.CreateWorkbenchWithOneViewContent(@"C:\Projects\test.rb");

Expand All @@ -33,21 +33,28 @@ public void SetUpFixture()
}

[Test]
public void DebuggerStartMethodCalled()
public void Run_RubyFileOpen_DebuggerStartMethodCalled()
{
Assert.IsTrue(debugger.StartMethodCalled);
bool startMethodCalled = debugger.StartMethodCalled;
Assert.IsTrue(startMethodCalled);
}

[Test]
public void ProcessInfoFileNameContainsPathToIronRubyConsole()
public void Run_RubyFileOpen_ProcessInfoFileNameContainsPathToIronRubyConsole()
{
Assert.AreEqual(@"C:\IronRuby\ir.exe", debugger.ProcessStartInfo.FileName);
string fileName = debugger.ProcessStartInfo.FileName;
string expectedFileName = @"C:\IronRuby\ir.exe";

Assert.AreEqual(expectedFileName, fileName);
}

[Test]
public void ProcessInfoArgsHasDebugArgument()
public void Run_RubyFileOpen_ProcessInfoArgsHasDebugArgument()
{
Assert.AreEqual("-D test.rb", debugger.ProcessStartInfo.Arguments);
string arguments = debugger.ProcessStartInfo.Arguments;
string expectedArguments = "-D test.rb";

Assert.AreEqual(expectedArguments, arguments);
}
}
}
Expand Up @@ -22,8 +22,8 @@ public class RunRubyCommandTests
MockDebugger debugger;
RunRubyCommand command;

[TestFixtureSetUp]
public void SetUpFixture()
[SetUp]
public void Init()
{
MockWorkbench workbench = MockWorkbench.CreateWorkbenchWithOneViewContent(@"C:\Projects\test.rb");

Expand All @@ -37,33 +37,42 @@ public void SetUpFixture()
}

[Test]
public void RunRubyCommandIsAbstractCommand()
public void Run_RubyFileOpen_RubyCommandIsAbstractCommand()
{
Assert.IsNotNull(command as AbstractCommand);
AbstractCommand abstractCommand = command as AbstractCommand;
Assert.IsNotNull(abstractCommand);
}

[Test]
public void DebuggerStartWithoutDebuggingMethodCalled()
public void Run_RubyFileOpen_DebuggerStartWithoutDebuggingMethodCalled()
{
Assert.IsTrue(debugger.StartWithoutDebuggingMethodCalled);
bool startCalled = debugger.StartWithoutDebuggingMethodCalled;
Assert.IsTrue(startCalled);
}

[Test]
public void ProcessInfoFileNameIsIronRubyConsole()
public void Run_RubyFileOpen_ProcessInfoFileNameIsIronRubyConsole()
{
Assert.AreEqual(@"C:\IronRuby\ir.exe", debugger.ProcessStartInfo.FileName);
string fileName = debugger.ProcessStartInfo.FileName;
string expectedFileName = "cmd.exe";
Assert.AreEqual(expectedFileName, fileName);
}

[Test]
public void ProcessInfoArgsContainsFileNameActiveInTextEditor()
public void Run_RubyFileOpen_ProcessInfoArgsContainsFileNameActiveInTextEditor()
{
Assert.AreEqual("test.rb", debugger.ProcessStartInfo.Arguments);
string arguments = debugger.ProcessStartInfo.Arguments;
string expectedArguments = "/c \"C:\\IronRuby\\ir.exe test.rb\" & pause";

Assert.AreEqual(expectedArguments, arguments);
}

[Test]
public void WorkingDirectoryIsSameDirectoryAsFileBeingRun()
public void Run_RubyFileOpen_WorkingDirectoryIsSameDirectoryAsFileBeingRun()
{
Assert.AreEqual(@"C:\Projects", debugger.ProcessStartInfo.WorkingDirectory);
string directory = debugger.ProcessStartInfo.WorkingDirectory;
string expectedDirectory = @"C:\Projects";
Assert.AreEqual(expectedDirectory, directory);
}
}
}
Expand Up @@ -266,7 +266,7 @@
<Compile Include="Designer\RubyPropertyAssignmentToStringTests.cs" />
<Compile Include="Designer\TextBoxNotAddedToFormTestFixture.cs" />
<Compile Include="Designer\UnknownTypeTestFixture.cs" />
<Compile Include="Gui\DebugRunRubyCommandTestFixture.cs" />
<Compile Include="Gui\DebugRunRubyCommandTests.cs" />
<Compile Include="Gui\RubyIndentationTests.cs" />
<Compile Include="Gui\RubyOptionsPanelTestFixture.cs" />
<Compile Include="Gui\RunRubyCommandTests.cs" />
Expand Down
Expand Up @@ -80,6 +80,7 @@
<Compile Include="Src\IScriptingDesignerGenerator.cs" />
<Compile Include="Src\IScriptingFileService.cs" />
<Compile Include="Src\IScriptingWorkbench.cs" />
<Compile Include="Src\PauseCommandPromptProcessStartInfo.cs" />
<Compile Include="Src\ScriptingCodeBuilder.cs" />
<Compile Include="Src\ScriptingConsole.cs" />
<Compile Include="Src\ScriptingConsoleCompletionData.cs" />
Expand Down
@@ -0,0 +1,35 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)

using System;
using System.Diagnostics;

namespace ICSharpCode.Scripting
{
public class PauseCommandPromptProcessStartInfo
{
ProcessStartInfo processStartInfo;

public PauseCommandPromptProcessStartInfo(ProcessStartInfo processStartInfo)
{
this.processStartInfo = processStartInfo;
ChangeProcessStartInfoToPauseCommandPrompt();
}

public ProcessStartInfo ProcessStartInfo {
get { return processStartInfo; }
}

void ChangeProcessStartInfoToPauseCommandPrompt()
{
processStartInfo.Arguments = GetArguments();
processStartInfo.FileName = "cmd.exe";
}

string GetArguments()
{
return String.Format("/c \"{0} {1}\" & pause",
processStartInfo.FileName, processStartInfo.Arguments);
}
}
}

0 comments on commit ee134f9

Please sign in to comment.