Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ jobs:
dotnet-version: 10.0.x

- name: Build
id: build
run: dotnet build GameServer.slnx -c Release

- name: Data tests
run: dotnet test tests/GameServer.Data.Tests -c Release --no-build

# Each suite runs when the build worked, whatever the suite before it did: one failure does not hide the others.
- name: Core tests
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: dotnet test tests/GameServer.Core.Tests -c Release --no-build

- name: Gateway tests
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: dotnet test tests/GameServer.Gateway.Tests -c Release --no-build
4 changes: 3 additions & 1 deletion src/GameServer.Host/GameHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ private async Task AcceptLoop()
{
TcpClient c;
try { c = await _listener.AcceptTcpClientAsync(_cts.Token); }
catch (OperationCanceledException) { break; }
// DisposeAsync cancels and then stops the listener. An accept that starts between the two, or is cut off
// by the stop, fails with the socket's own exception instead of the cancellation: either way, shutting down.
catch (Exception) when (_cts.IsCancellationRequested) { break; }
_ = Serve(c);
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/GameServer.Core.Tests/FileHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ static class FileHold
public static FileStream For(string path, FileShare share, int ms)
{
var stream = new FileStream(path, FileMode.Open, FileAccess.Read, share);
_ = Task.Delay(ms).ContinueWith(_ => stream.Dispose());
// A thread of its own: on the thread pool the release waited behind the other tests' work, and on a busy
// two-core machine it came after the save had given up (2 s), which failed the test that expects the save.
new Thread(() => { Thread.Sleep(ms); stream.Dispose(); }) { IsBackground = true }.Start();
return stream;
}
}
Loading