Skip to content

Commit d237173

Browse files
committed
asd
1 parent 16e3b3f commit d237173

6 files changed

Lines changed: 53 additions & 16 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ jobs:
7171
xvfb-run -a dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj \
7272
-c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} \
7373
--logger "trx;LogFileName=TestResults.trx" \
74+
--logger "GitHubActions" \
7475
--results-directory test-results
7576
7677
- name: Run tests (Windows)
7778
if: runner.os == 'Windows'
7879
continue-on-error: true
7980
run: |
8081
New-Item -ItemType Directory -Force -Path test-results | Out-Null
81-
dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} --logger "trx;LogFileName=TestResults.trx" --results-directory test-results
82+
dotnet test src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj -c Release --no-build -r ${{ matrix.rid }} -p:RuntimeIdentifier=${{ matrix.rid }} --logger "trx;LogFileName=TestResults.trx" --logger "GitHubActions" --results-directory test-results
8283
8384
- name: Upload raw test results
8485
if: always()

src/ElectronNET.API/Runtime/Controllers/RuntimeControllerDotNetFirst.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ private void ElectronProcess_Stopped(object sender, EventArgs e)
8282

8383
private void HandleStopped()
8484
{
85-
if (this.socketBridge.State != LifetimeState.Stopped)
85+
if (this.socketBridge != null && this.socketBridge.State != LifetimeState.Stopped)
8686
{
8787
this.socketBridge.Stop();
8888
}
89-
else if (this.electronProcess.State != LifetimeState.Stopped)
89+
else if (this.electronProcess != null && this.electronProcess.State != LifetimeState.Stopped)
9090
{
9191
this.electronProcess.Stop();
9292
}

src/ElectronNET.API/Runtime/StartupManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,19 @@ private BuildInfo GatherBuildInfo()
132132

133133
if (electronAssembly == null)
134134
{
135+
Console.WriteLine("GatherBuildInfo: Early exit");
135136
return buildInfo;
136137
}
137138

138139
if (electronAssembly.GetName().Name == "testhost" || electronAssembly.GetName().Name == "ReSharperTestRunner")
139140
{
141+
Console.WriteLine("GatherBuildInfo: Detected testhost");
140142
electronAssembly = AppDomain.CurrentDomain.GetData("ElectronTestAssembly") as Assembly ?? electronAssembly;
141143
}
144+
else
145+
{
146+
Console.WriteLine("GatherBuildInfo: No testhost detected: " + electronAssembly.GetName().Name);
147+
}
142148

143149
var attributes = electronAssembly.GetCustomAttributes<AssemblyMetadataAttribute>().ToList();
144150

src/ElectronNET.IntegrationTests/ElectronFixture.cs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,46 @@ public class ElectronFixture : IAsyncLifetime
1111

1212
public async Task InitializeAsync()
1313
{
14-
AppDomain.CurrentDomain.SetData("ElectronTestAssembly", Assembly.GetExecutingAssembly());
15-
var runtimeController = ElectronNetRuntime.RuntimeController;
16-
await runtimeController.Start();
17-
await runtimeController.WaitReadyTask;
18-
19-
// create hidden window for tests (avoid showing UI)
20-
this.MainWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
14+
try
2115
{
22-
Show = false,
23-
Width = 800,
24-
Height = 600,
25-
}, "about:blank");
16+
Console.Error.WriteLine("[ElectronFixture] InitializeAsync: start");
17+
AppDomain.CurrentDomain.SetData("ElectronTestAssembly", Assembly.GetExecutingAssembly());
18+
Console.Error.WriteLine("[ElectronFixture] Acquire RuntimeController");
19+
var runtimeController = ElectronNetRuntime.RuntimeController;
20+
Console.Error.WriteLine("[ElectronFixture] Starting Electron runtime...");
21+
await runtimeController.Start();
22+
Console.Error.WriteLine("[ElectronFixture] Waiting for Ready...");
23+
await runtimeController.WaitReadyTask;
24+
Console.Error.WriteLine("[ElectronFixture] Runtime Ready");
2625

27-
// Clear potential cache side-effects
28-
await this.MainWindow.WebContents.Session.ClearCacheAsync();
26+
// create hidden window for tests (avoid showing UI)
27+
Console.Error.WriteLine("[ElectronFixture] Creating hidden BrowserWindow");
28+
this.MainWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
29+
{
30+
Show = false,
31+
Width = 800,
32+
Height = 600,
33+
}, "about:blank");
34+
35+
Console.Error.WriteLine("[ElectronFixture] Clearing session cache");
36+
await this.MainWindow.WebContents.Session.ClearCacheAsync();
37+
Console.Error.WriteLine("[ElectronFixture] InitializeAsync: done");
38+
}
39+
catch (Exception ex)
40+
{
41+
Console.Error.WriteLine("[ElectronFixture] InitializeAsync: exception");
42+
Console.Error.WriteLine(ex.ToString());
43+
throw;
44+
}
2945
}
3046

3147
public async Task DisposeAsync()
3248
{
3349
var runtimeController = ElectronNetRuntime.RuntimeController;
50+
Console.Error.WriteLine("[ElectronFixture] Stopping Electron runtime...");
3451
await runtimeController.Stop();
3552
await runtimeController.WaitStoppedTask;
53+
Console.Error.WriteLine("[ElectronFixture] Runtime stopped");
3654
}
3755
}
3856

src/ElectronNET.IntegrationTests/ElectronNET.IntegrationTests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
<ParallelizeTestCollections>false</ParallelizeTestCollections>
3838
</PropertyGroup>
3939

40+
<ItemGroup>
41+
<None Update="xunit.runner.json">
42+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
43+
</None>
44+
</ItemGroup>
45+
4046
<Import Project="..\ElectronNET\build\ElectronNET.targets" Condition="$(ElectronNetDevMode)" />
4147

4248
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3+
"diagnosticMessages": true,
4+
"parallelizeTestCollections": false,
5+
"longRunningTestSeconds": 60
6+
}

0 commit comments

Comments
 (0)