Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[wasm][debugger][tests] Merge SingleSessionTestBase=>DebuggerTestBase
.. since it isn't required any more.
  • Loading branch information
radical committed Nov 20, 2020
commit 545ed84910858889aa7226c2f00150800ea4e837
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DebuggerTests
{

public class ArrayTests : SingleSessionTestBase
public class ArrayTests : DebuggerTestBase
{

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ namespace DebuggerTests
{
public class BadHarnessInitTests : DebuggerTestBase
{
internal Inspector insp;
protected Dictionary<string, string> scripts;

public BadHarnessInitTests(string driver = "debugger-driver.html") : base(driver)
{
insp = new Inspector();
scripts = SubscribeToScripts(insp);
}
public override async Task InitializeAsync() => await Task.CompletedTask;

[Fact]
public async Task InvalidInitCommands()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DebuggerTests
{

public class CallFunctionOnTests : SingleSessionTestBase
public class CallFunctionOnTests : DebuggerTestBase
{

// This tests `callFunctionOn` with a function that the vscode-js-debug extension uses
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/DateTimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace DebuggerTests
{
public class DateTimeList : SingleSessionTestBase
public class DateTimeList : DebuggerTestBase
{

[Theory]
Expand Down
34 changes: 31 additions & 3 deletions src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

namespace DebuggerTests
{
public class DebuggerTestBase
public class DebuggerTestBase : IAsyncLifetime
{
protected Task startTask;
protected Inspector insp;
protected Dictionary<string, string> scripts;

static string s_debuggerTestAppPath;
protected static string DebuggerTestAppPath
Expand Down Expand Up @@ -73,9 +75,35 @@ static string FindChromePath()

public DebuggerTestBase(string driver = "debugger-driver.html")
{
insp = new Inspector();
scripts = SubscribeToScripts(insp);

startTask = TestHarnessProxy.Start(FindChromePath(), DebuggerTestAppPath, driver);
}

public virtual async Task InitializeAsync()
{
Func<InspectorClient, CancellationToken, List<(string, Task<Result>)>> fn = (client, token) =>
{
Func<string, (string, Task<Result>)> getInitCmdFn = (cmd) => (cmd, client.SendCommand(cmd, null, token));
var init_cmds = new List<(string, Task<Result>)>
{
getInitCmdFn("Profiler.enable"),
getInitCmdFn("Runtime.enable"),
getInitCmdFn("Debugger.enable"),
getInitCmdFn("Runtime.runIfWaitingForDebugger")
};

return init_cmds;
};

await Ready();
await insp.OpenSessionAsync(fn);
ctx = new DebugTestContext(insp.Client, insp, insp.Token, scripts);
}

public virtual async Task DisposeAsync() => await insp.ShutdownAsync().ConfigureAwait(false);

public Task Ready() => startTask;

internal DebugTestContext ctx;
Expand Down Expand Up @@ -107,7 +135,7 @@ internal Dictionary<string, string> SubscribeToScripts(Inspector insp)
}

internal async Task CheckInspectLocalsAtBreakpointSite(string url_key, int line, int column, string function_name, string eval_expression,
Action<JToken>? test_fn = null, Func<JObject, Task>? wait_for_event_fn = null, bool use_cfo = false)
Action<JToken> test_fn = null, Func<JObject, Task> wait_for_event_fn = null, bool use_cfo = false)
{
ctx.UseCallFunctionOnBeforeGetProperties = use_cfo;

Expand Down Expand Up @@ -140,7 +168,7 @@ await EvaluateAndCheck(

// sets breakpoint by method name and line offset
internal async Task CheckInspectLocalsAtBreakpointSite(string type, string method, int line_offset, string bp_function_name, string eval_expression,
Action<JToken>? locals_fn = null, Func<JObject, Task>? wait_for_event_fn = null, bool use_cfo = false, string assembly = "debugger-test.dll", int col = 0)
Action<JToken> locals_fn = null, Func<JObject, Task> wait_for_event_fn = null, bool use_cfo = false, string assembly = "debugger-test.dll", int col = 0)
{
ctx.UseCallFunctionOnBeforeGetProperties = use_cfo;

Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/DelegateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DebuggerTests
{

public class DelegateTests : SingleSessionTestBase
public class DelegateTests : DebuggerTestBase
{

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace DebuggerTests
{
// TODO: static async, static method args
public class EvaluateOnCallFrameTests : SingleSessionTestBase
public class EvaluateOnCallFrameTests : DebuggerTestBase
{
public static IEnumerable<object[]> InstanceMethodsTestData(string type_name)
{
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/ExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DebuggerTests
{

public class ExceptionTests : SingleSessionTestBase
public class ExceptionTests : DebuggerTestBase
{
[Fact]
public async Task ExceptionTestAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace DebuggerTests
{
public class GetPropertiesTests : SingleSessionTestBase
public class GetPropertiesTests : DebuggerTestBase
{
public static TheoryData<string, bool?, bool?, string[], Dictionary<string, (JObject, bool)>, bool> ClassGetPropertiesTestData(bool is_async)
{
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/HarnessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace DebuggerTests
{
public class HarnessTests : SingleSessionTestBase
public class HarnessTests : DebuggerTestBase
{
[Fact]
public async Task TimedOutWaitingForInvalidBreakpoint()
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/MonoJsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace DebuggerTests
{
public class MonoJsTests : SingleSessionTestBase
public class MonoJsTests : DebuggerTestBase
{
[Fact]
public async Task FixupNameValueObjectsWithMissingParts()
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/PointerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DebuggerTests
{

public class PointerTests : SingleSessionTestBase
public class PointerTests : DebuggerTestBase
{

public static TheoryData<string, string, string, int, string, bool> PointersTestData =>
Expand Down
50 changes: 0 additions & 50 deletions src/mono/wasm/debugger/DebuggerTestSuite/SingleSessionTestBase.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace DebuggerTests
{
public class SteppingTests : SingleSessionTestBase
public class SteppingTests : DebuggerTestBase
{
[Fact]
public async Task TrivalStepping()
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace DebuggerTests
{

public class SourceList : SingleSessionTestBase
public class SourceList : DebuggerTestBase
{

[Fact]
Expand Down