Skip to content

Commit

Permalink
Force to kill test when ClientDisconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Oct 1, 2024
1 parent f77df9c commit a0e50f9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Features
- Support `TestAdapter` custom executer.
- Support environment variables to overwrite settings in the `TestAdapter`. (Fix: #57)
### App
- Force to kill test when `ClientDisconnected`.
### Command
- Update to use `JsonService` implementation to use `Newtonsoft.Json` in the domain.
- Update `ProcessStart` with `GetProcesses` to enable kill process.
Expand All @@ -18,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add Environment variable for process arguments `RICAUN_REVITTEST_CONSOLE_PROCESS_ARGUMENTS`.
### Shared
- Update to use `ricaun.NamedPipeWrapper.Json` version `1.8.0`.
- Add `ClientDisconnected` in `PipeProcessServer`.
### TestAdapter
- Use `LocalExtensionData` to store `TestModel` result.
- Add `EnvironmentSettings` to overwrite settings in the `TestAdapter`.
Expand Down
16 changes: 16 additions & 0 deletions ricaun.RevitTest.Application/Revit/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ private static void PipeTestServer_Initialize()
response.Tests = null;
});

PipeTestServer.ClientDisconnected = () =>
{
try
{
if (IsTestRunning)
{
Log.WriteLine("PipeTestServer: ClientDisconnected - TestEngine.KillTests");
ricaun.NUnit.TestEngine.Result = new TestModelResult((test) =>
{
throw new Exception("Client disconnect, TestEngine.Kill to ignore test result.");
});
}
}
catch { }
};

var initializeServer = PipeTestServer.Initialize();

if (initializeServer)
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions ricaun.RevitTest.Shared/PipeProcessServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ public bool Initialize()
namedPipe = new NamedPipeServer<TClient, TServer>(pipeName);
namedPipe.ClientConnected += OnClientConnected;
namedPipe.ClientMessage += OnClientMessage;
namedPipe.ClientDisconnected += OnClientDisconnected;
namedPipe.NamedPipeDebug();
namedPipe.Start();
}
return namedPipe != null;
}

public Action ClientDisconnected { get; set; }

private void OnClientDisconnected(NamedPipeConnection<TClient, TServer> connection)
{
ClientDisconnected?.Invoke();
}

public void Update(Action<TServer> response)
{
if (ServerMessage is null) ServerMessage = new TServer();
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit a0e50f9

Please sign in to comment.