diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33095eba..f6b39ddd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,13 +53,9 @@ jobs: if ($bad) { $bad; throw 'gofmt required' } - name: go vet run: go vet ./... + # Guest shell script tests are skipped on Windows (Git's sh is far too slow); Linux and macOS run them. - name: go test - shell: pwsh - run: | - $gitRoot = Split-Path -Parent (Split-Path -Parent (Get-Command git).Source) - $env:Path = "$(Join-Path $gitRoot 'usr\bin');$env:Path" - $env:MODAVD_REQUIRE_INSTALLERX_SH = '1' - go test ./... + run: go test ./... - name: cross-platform vet shell: pwsh run: | @@ -153,6 +149,9 @@ jobs: - name: go vet run: go vet ./... - name: go test + # Linux must run the InstallerX guest script tests, not skip them for a missing tool. + env: + MODAVD_REQUIRE_INSTALLERX_SH: ${{ matrix.os == 'ubuntu-24.04' && '1' || '' }} run: go test ./... create-cancel: diff --git a/internal/emu/appproxy_sh_test.go b/internal/emu/appproxy_sh_test.go index 77e88ac8..34ad10fa 100644 --- a/internal/emu/appproxy_sh_test.go +++ b/internal/emu/appproxy_sh_test.go @@ -21,6 +21,7 @@ func TestReplaceDaemonScriptSh(t *testing.T) { t.Fatalf("a single quote (Manager.su puts the script inside single quotes): %s", s) } } + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/bridge_sh_test.go b/internal/emu/bridge_sh_test.go index d7749209..fccb3f5d 100644 --- a/internal/emu/bridge_sh_test.go +++ b/internal/emu/bridge_sh_test.go @@ -18,6 +18,7 @@ import ( // files: one current, one different, one missing and, where permissions can deny reading (not as root, not on // Windows), one unreadable. Its output goes through payloadStale. func TestBridgeGuestHashScriptSh(t *testing.T) { + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/game_import_parse_test.go b/internal/emu/game_import_parse_test.go index 95153412..c45b83e5 100644 --- a/internal/emu/game_import_parse_test.go +++ b/internal/emu/game_import_parse_test.go @@ -9,6 +9,7 @@ import ( "testing" "modavd/internal/errs" + "modavd/internal/testutil" ) // The functions below take text the source emulator produced, or build commands from it. Nothing here starts adb. @@ -31,6 +32,7 @@ func TestImportQuote(t *testing.T) { } func TestImportQuoteWithRealShell(t *testing.T) { + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/game_import_stage_test.go b/internal/emu/game_import_stage_test.go index 973dfa83..aabc5531 100644 --- a/internal/emu/game_import_stage_test.go +++ b/internal/emu/game_import_stage_test.go @@ -15,12 +15,14 @@ import ( "modavd/internal/errs" "modavd/internal/logx" + "modavd/internal/testutil" ) // posixShell runs guest scripts with a real POSIX shell on this computer (the test is skipped without one). Git for // Windows keeps its tools in ..\usr\bin; Windows' own find.exe and sort.exe must not be the ones that run. func posixShell(t *testing.T) (string, func(script string) (string, error)) { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/game_import_test.go b/internal/emu/game_import_test.go index a876139d..fb7dd8d7 100644 --- a/internal/emu/game_import_test.go +++ b/internal/emu/game_import_test.go @@ -18,6 +18,7 @@ import ( "modavd/internal/errs" "modavd/internal/logx" + "modavd/internal/testutil" ) // scriptedGuest answers the shell commands of the import code the way a guest would, and records every script. @@ -215,6 +216,7 @@ func TestRemoveStaleImportDirsKeepsGoingAfterAFailure(t *testing.T) { // Runs the generated command with a real POSIX shell (skipped without one) on a temporary directory. func TestRemoveStaleImportDirsOnDisk(t *testing.T) { + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/dldisk_sh_test.go b/internal/guest/dldisk_sh_test.go index c564c661..9f08ca5f 100644 --- a/internal/guest/dldisk_sh_test.go +++ b/internal/guest/dldisk_sh_test.go @@ -42,6 +42,7 @@ const ( func newDDGuest(t *testing.T) *ddGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/gles32_sh_test.go b/internal/guest/gles32_sh_test.go index c11fd61f..cc8bdd5e 100644 --- a/internal/guest/gles32_sh_test.go +++ b/internal/guest/gles32_sh_test.go @@ -29,6 +29,7 @@ type glGuest struct { func newGLGuest(t *testing.T) *glGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/installerx_sh_test.go b/internal/guest/installerx_sh_test.go index 83d4ce0d..573011c1 100644 --- a/internal/guest/installerx_sh_test.go +++ b/internal/guest/installerx_sh_test.go @@ -30,6 +30,7 @@ func newIXGuest(t *testing.T) *ixGuest { } t.Skip(reason) } + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { missing("no sh") diff --git a/internal/guest/libfix_sh_test.go b/internal/guest/libfix_sh_test.go index fc45278f..1665f75f 100644 --- a/internal/guest/libfix_sh_test.go +++ b/internal/guest/libfix_sh_test.go @@ -50,6 +50,7 @@ func (l lfLib) args() []string { func newLFGuest(t *testing.T) *lfGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/playstore_sh_test.go b/internal/guest/playstore_sh_test.go index 425f7fcf..6639a2d8 100644 --- a/internal/guest/playstore_sh_test.go +++ b/internal/guest/playstore_sh_test.go @@ -29,6 +29,7 @@ type psGuest struct { func newPSGuest(t *testing.T) *psGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/quietnotifs_sh_test.go b/internal/guest/quietnotifs_sh_test.go index a01487ca..ff624def 100644 --- a/internal/guest/quietnotifs_sh_test.go +++ b/internal/guest/quietnotifs_sh_test.go @@ -37,6 +37,7 @@ const qnStockPolicy = " NetworkPolicy{template=NetworkTemplate: matchRule=CARRI func newQNGuest(t *testing.T) *qnGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/reswatch_sh_test.go b/internal/guest/reswatch_sh_test.go index d697d9d3..7f20aa33 100644 --- a/internal/guest/reswatch_sh_test.go +++ b/internal/guest/reswatch_sh_test.go @@ -53,6 +53,7 @@ const ( func newRWGuest(t *testing.T) *rwGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/vkmode_sh_test.go b/internal/guest/vkmode_sh_test.go index d112c127..21e941a7 100644 --- a/internal/guest/vkmode_sh_test.go +++ b/internal/guest/vkmode_sh_test.go @@ -37,6 +37,7 @@ func vkFiles(pkg string) string { return vkMedia + "/" + pkg + "/files" } func newVKGuest(t *testing.T) *vkGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/testutil/guestsh.go b/internal/testutil/guestsh.go new file mode 100644 index 00000000..663d655e --- /dev/null +++ b/internal/testutil/guestsh.go @@ -0,0 +1,19 @@ +// Copyright 2026 Ji Mao Cai +// SPDX-License-Identifier: AGPL-3.0-or-later + +package testutil + +import ( + "runtime" + "testing" +) + +// SkipGuestShellOnWindows skips a test that runs a guest (Android) shell script in a POSIX sh on this computer. +// The scripts only ever run in the guest, and Linux and macOS CI cover them; Git's sh on Windows starts child +// processes so slowly that these tests took minutes there. +func SkipGuestShellOnWindows(t testing.TB) { + t.Helper() + if runtime.GOOS == "windows" { + t.Skip("guest shell scripts are tested on Linux and macOS; Git's sh on Windows is too slow") + } +}