Skip to content

Commit

Permalink
chore: Misc minor fixes + improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Oct 17, 2023
1 parent c9eb3bf commit ee0f40e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.5" />

<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>

<Import Project="..\..\shared\uno.ui.runtimetests.engine.Shared.projitems" Label="Shared" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.5" />

<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>

<Import Project="..\..\shared\uno.ui.runtimetests.engine.Shared.projitems" Label="Shared" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static Process SetupProcess(
public static async Task WaitForExitWithCancellationAsync(this Process process, CancellationToken ct)
{
await using var cancel = ct.Register(process.Close);
await process.WaitForExitAsync(ct);
await process.WaitForExitAsync(CancellationToken.None); // If the ct has been cancelled, we want to wait for exit!
}

public static void EnsureSuccess(this Process process, ILogger log, StringBuilder error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,18 @@ internal static async Task<TestCaseResult[]> RunTest(UnitTestEngineConfig config
var resultFile = await RunLocalApp("127.0.0.1", devServer.Port, config, isAppVisible, ct);

// Finally, read the test results
var results = await JsonSerializer.DeserializeAsync<TestCaseResult[]>(File.OpenRead(resultFile), cancellationToken: ct);

return results ?? Array.Empty<TestCaseResult>();
try
{
var results = await JsonSerializer.DeserializeAsync<TestCaseResult[]>(File.OpenRead(resultFile), cancellationToken: ct);

return results ?? Array.Empty<TestCaseResult>();
}
catch (JsonException error)
{
throw new InvalidOperationException(
$"Failed to deserialize the test results from '{resultFile}', this usually indicates that the secondary app has been closed (or crashed) before the end of the test suit.",
error);
}
}

private static async Task<string> RunLocalApp(string devServerHost, int devServerPort, UnitTestEngineConfig config, bool isAppVisible, CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ public static partial class HotReloadHelper
throw new InvalidOperationException("The project file path could not be found.");
}

var projectDir = Path.GetDirectoryName(projectFile);
#if __SKIA__
if (!File.Exists(projectFile)) // Sanity!
{
throw new InvalidOperationException("Unable to find project file.");
}

var projectDir = Path.GetDirectoryName(projectFile);
if (!Directory.Exists(projectDir))
{
throw new InvalidOperationException("Unable to find project directory.");
Expand Down

0 comments on commit ee0f40e

Please sign in to comment.