Skip to content

Commit

Permalink
Trying tests in the build action
Browse files Browse the repository at this point in the history
  • Loading branch information
lowleveldesign committed Dec 5, 2024
1 parent 706c7f3 commit 3758218
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ jobs:
with:
dotnet-version: '9.0.x' # SDK Version to use.

# Lots of tests now require a GUI environment - I need to categorize them and allow only a small set here
# - run: dotnet test -c release
# working-directory: ./procgov-tests
- run: dotnet test -c release --filter "FullyQualifiedName~ProcessGovernor.Tests.Code.ProgramTests"
working-directory: ./procgov-tests

- run: dotnet publish -c release -r win-x64
working-directory: ./procgov
Expand Down
2 changes: 1 addition & 1 deletion procgov-tests/Code/ProgramTests_CmdApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static async Task CmdAppAttachProcessAndUpdateJob()
{
using var cts = new CancellationTokenSource(10000);

var (cmd, cmdMainThreadHandle) = ProcessModule.CreateSuspendedProcess(["cmd.exe"], false, []);
var (cmd, cmdMainThreadHandle) = ProcessModule.CreateSuspendedProcess(["cmd.exe", "/c", "pause 4"], false, []);
try
{
PInvoke.ResumeThread(cmdMainThreadHandle);
Expand Down
13 changes: 9 additions & 4 deletions procgov-tests/Code/ProgramTests_Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,15 @@ public static async Task ServiceChildProcessLimit()
// sure that it will treat our newly started process as new
await Task.Delay(Program.ServiceProcessObserverIntervalInMilliseconds * 2, cts.Token);


const int ChildProcessTimeoutSeconds = 4;
const int ChildProcessTimeoutSeconds = Program.ServiceProcessObserverIntervalInMilliseconds * 3 / 1000;
// the monitor should start with the first monitored process
using var monitoredProcess = Process.Start("cmd.exe", $"/c timeout /T {ChildProcessTimeoutSeconds} && winver.exe");
using var monitoredProcess = Process.Start(new ProcessStartInfo()
{
FileName = "cmd.exe",
Arguments = $"/c timeout /T {ChildProcessTimeoutSeconds} && winver.exe",
UseShellExecute = true
});
Debug.Assert(monitoredProcess != null);
Program.Logger.TraceInformation($"[test] {nameof(monitoredProcess)}.Id = {monitoredProcess.Id}");

// give it time to discover a new process
Expand All @@ -288,7 +293,7 @@ public static async Task ServiceChildProcessLimit()

await Task.Delay((ChildProcessTimeoutSeconds + 1) * 1000, cts.Token);

using var childProcess = Process.GetProcessesByName("winver").First(p => p.StartTime > monitoredProcess.StartTime);
using var childProcess = Process.GetProcessesByName("winver").First(p => p.StartTime >= monitoredProcess.StartTime);
Program.Logger.TraceInformation($"[test] {nameof(childProcess)}.Id = {childProcess.Id}");

try
Expand Down

0 comments on commit 3758218

Please sign in to comment.