-
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented debugging support for roslyn script sessions
- Loading branch information
1 parent
b7400a6
commit 659c665
Showing
29 changed files
with
778 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Diagnostics; | ||
using Cake.Scripting; | ||
using NSubstitute; | ||
|
||
namespace Cake.Tests.Fixtures | ||
{ | ||
internal sealed class DebugScriptHostFixture | ||
{ | ||
public ICakeEngine Engine { get; set; } | ||
public ICakeContext Context { get; set; } | ||
public ICakeReportPrinter Printer { get; set; } | ||
public ICakeLog Log { get; set; } | ||
public IDebugger Debugger { get; set; } | ||
|
||
public DebugScriptHostFixture() | ||
{ | ||
Engine = Substitute.For<ICakeEngine>(); | ||
Context = Substitute.For<ICakeContext>(); | ||
Printer = Substitute.For<ICakeReportPrinter>(); | ||
Log = Substitute.For<ICakeLog>(); | ||
Debugger = Substitute.For<IDebugger>(); | ||
} | ||
|
||
public DebugScriptHost CreateHost() | ||
{ | ||
return new DebugScriptHost(Engine, Context, Printer, Log, Debugger); | ||
} | ||
|
||
public CakeReport RunTarget(string target) | ||
{ | ||
return CreateHost().RunTarget(target); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System; | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Scripting; | ||
using Cake.Tests.Fixtures; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Cake.Tests.Unit.Scripting | ||
{ | ||
public sealed class DebugScriptHostTests | ||
{ | ||
public sealed class TheRunTargetMethod | ||
{ | ||
[Fact] | ||
public void Should_Proxy_Call_To_Engine() | ||
{ | ||
// Given | ||
var fixture = new DebugScriptHostFixture(); | ||
var engine = fixture.Engine; | ||
var context = fixture.Context; | ||
|
||
// When | ||
fixture.RunTarget("Target"); | ||
|
||
// Then | ||
engine.Received(1).RunTarget(context, Arg.Any<DefaultExecutionStrategy>(), "Target"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Print_Report() | ||
{ | ||
// Given | ||
var fixture = new DebugScriptHostFixture(); | ||
var engine = fixture.Engine; | ||
var context = fixture.Context; | ||
var printer = fixture.Printer; | ||
|
||
var report = new CakeReport(); | ||
report.Add("Target", TimeSpan.FromSeconds(1)); | ||
engine.RunTarget(context, Arg.Any<DefaultExecutionStrategy>(), "Target").Returns(report); | ||
|
||
// When | ||
fixture.RunTarget("Target"); | ||
|
||
// Then | ||
printer.Received(1).Write(report); | ||
} | ||
|
||
[Fact] | ||
public void Should_Not_Print_Report_That_Is_Null() | ||
{ | ||
// Given | ||
var fixture = new DebugScriptHostFixture(); | ||
var engine = fixture.Engine; | ||
var context = fixture.Context; | ||
var printer = fixture.Printer; | ||
|
||
var report = new CakeReport(); | ||
report.Add("Target", TimeSpan.FromSeconds(1)); | ||
engine.RunTarget(context, Arg.Any<DefaultExecutionStrategy>(), "Target").Returns((CakeReport)null); | ||
|
||
// When | ||
fixture.RunTarget("Target"); | ||
|
||
// Then | ||
printer.Received(0).Write(Arg.Any<CakeReport>()); | ||
} | ||
|
||
[Fact] | ||
public void Should_Not_Print_Report_That_Is_Empty() | ||
{ | ||
// Given | ||
var fixture = new DebugScriptHostFixture(); | ||
var engine = fixture.Engine; | ||
var context = fixture.Context; | ||
var printer = fixture.Printer; | ||
|
||
var report = new CakeReport(); | ||
report.Add("Target", TimeSpan.FromSeconds(1)); | ||
engine.RunTarget(context, Arg.Any<DefaultExecutionStrategy>(), "Target").Returns(new CakeReport()); | ||
|
||
// When | ||
fixture.RunTarget("Target"); | ||
|
||
// Then | ||
printer.Received(0).Write(Arg.Any<CakeReport>()); | ||
} | ||
|
||
[Fact] | ||
public void Should_Report_Correct_Process_Id() | ||
{ | ||
// Given | ||
var fixture = new DebugScriptHostFixture(); | ||
var debugger = fixture.Debugger; | ||
var log = fixture.Log; | ||
var pid = 1234567; | ||
|
||
debugger.GetProcessId().Returns(pid); | ||
|
||
// When | ||
fixture.RunTarget("Target"); | ||
|
||
// Then | ||
log.Received(1).Information(Verbosity.Quiet, Arg.Any<string>(), pid); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.