diff --git a/docs/PRE-RELEASE-TASKS.md b/docs/PRE-RELEASE-TASKS.md index 449ee27..67198bf 100644 --- a/docs/PRE-RELEASE-TASKS.md +++ b/docs/PRE-RELEASE-TASKS.md @@ -114,7 +114,7 @@ These land together because both edit `domain/job.go` and `storage/store.go`. - [x] P6.3 — Re-measure startup → PERFORMANCE.md ### Phase 7 — Roadmap follow-ups -- [ ] P7.1 — Linux test build fix (build-tagged Windows tests) +- [x] P7.1 — Linux test build fix (build-tagged Windows tests) ### Phase 8 — Docs + version - [ ] P8.1 — `docs/DEVELOPMENT.md` diff --git a/src/runner/runner_test.go b/src/runner/runner_test.go index e578823..b1d2b2e 100644 --- a/src/runner/runner_test.go +++ b/src/runner/runner_test.go @@ -10,7 +10,6 @@ import ( "time" "gitea.mixdep.ru/mix/gosentry/src/domain" - "gitea.mixdep.ru/mix/gosentry/src/platform/winproc" ) func echoCommand(message string) string { @@ -322,60 +321,3 @@ func TestRunJobStartOnlyReportsStartFailure(t *testing.T) { } } -func TestDirectCommandDoesNotHideWindow(t *testing.T) { - if runtime.GOOS != "windows" { - t.Skip("Windows window visibility only") - } - - invocation := jobInvocation(context.Background(), domain.Job{ - Command: `C:\Windows\System32\cmd.exe`, - Arguments: "/C\necho visible direct process", - }) - if invocation.hideWindow { - t.Fatal("direct command should not request hidden startup window") - } -} - -func TestShellCommandHidesWindow(t *testing.T) { - if runtime.GOOS != "windows" { - t.Skip("Windows window visibility only") - } - - invocation := jobInvocation(context.Background(), domain.Job{Command: "echo hidden shell process"}) - if !invocation.hideWindow { - t.Fatal("shell command should request hidden startup window") - } - winproc.ConfigureHiddenWindow(invocation.command) - if invocation.command.SysProcAttr == nil || !invocation.command.SysProcAttr.HideWindow { - t.Fatal("expected shell command to be hidden") - } -} - -func TestShellCommandUsesWindowsSafeQuoting(t *testing.T) { - if runtime.GOOS != "windows" { - t.Skip("Windows cmd.exe quoting only") - } - - command := shellCommand(context.Background(), `"C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Local\Programs\FreeFileSync\Jobs\Auto.ffs_batch"`) - winproc.ConfigureHiddenWindow(command) - - want := `cmd.exe /S /C ""C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Local\Programs\FreeFileSync\Jobs\Auto.ffs_batch""` - if command.SysProcAttr == nil { - t.Fatal("expected SysProcAttr") - } - if command.SysProcAttr.CmdLine != want { - t.Fatalf("expected command line %q, got %q", want, command.SysProcAttr.CmdLine) - } -} - -func TestWindowsShellCommandLineQuotesUnquotedProgramPath(t *testing.T) { - if runtime.GOOS != "windows" { - t.Skip("Windows cmd.exe quoting only") - } - - got := windowsShellCommandLine(`C:\Program Files\Joplin\Joplin.exe --profile "D:\Joplin Profile"`) - want := `cmd.exe /S /C ""C:\Program Files\Joplin\Joplin.exe" --profile "D:\Joplin Profile""` - if got != want { - t.Fatalf("expected command line %q, got %q", want, got) - } -} diff --git a/src/runner/runner_windows_test.go b/src/runner/runner_windows_test.go new file mode 100644 index 0000000..6ec730d --- /dev/null +++ b/src/runner/runner_windows_test.go @@ -0,0 +1,53 @@ +//go:build windows + +package runner + +import ( + "context" + "testing" + + "gitea.mixdep.ru/mix/gosentry/src/domain" + "gitea.mixdep.ru/mix/gosentry/src/platform/winproc" +) + +func TestDirectCommandDoesNotHideWindow(t *testing.T) { + invocation := jobInvocation(context.Background(), domain.Job{ + Command: `C:\Windows\System32\cmd.exe`, + Arguments: "/C\necho visible direct process", + }) + if invocation.hideWindow { + t.Fatal("direct command should not request hidden startup window") + } +} + +func TestShellCommandHidesWindow(t *testing.T) { + invocation := jobInvocation(context.Background(), domain.Job{Command: "echo hidden shell process"}) + if !invocation.hideWindow { + t.Fatal("shell command should request hidden startup window") + } + winproc.ConfigureHiddenWindow(invocation.command) + if invocation.command.SysProcAttr == nil || !invocation.command.SysProcAttr.HideWindow { + t.Fatal("expected shell command to be hidden") + } +} + +func TestShellCommandUsesWindowsSafeQuoting(t *testing.T) { + command := shellCommand(context.Background(), `"C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Local\Programs\FreeFileSync\Jobs\Auto.ffs_batch"`) + winproc.ConfigureHiddenWindow(command) + + want := `cmd.exe /S /C ""C:\Program Files\FreeFileSync\FreeFileSync.exe" "D:\Local\Programs\FreeFileSync\Jobs\Auto.ffs_batch""` + if command.SysProcAttr == nil { + t.Fatal("expected SysProcAttr") + } + if command.SysProcAttr.CmdLine != want { + t.Fatalf("expected command line %q, got %q", want, command.SysProcAttr.CmdLine) + } +} + +func TestWindowsShellCommandLineQuotesUnquotedProgramPath(t *testing.T) { + got := windowsShellCommandLine(`C:\Program Files\Joplin\Joplin.exe --profile "D:\Joplin Profile"`) + want := `cmd.exe /S /C ""C:\Program Files\Joplin\Joplin.exe" --profile "D:\Joplin Profile""` + if got != want { + t.Fatalf("expected command line %q, got %q", want, got) + } +}