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
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions internal/emu/appproxy_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/emu/bridge_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions internal/emu/game_import_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions internal/emu/game_import_stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions internal/emu/game_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/dldisk_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/gles32_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/installerx_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/libfix_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/playstore_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/quietnotifs_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/reswatch_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions internal/guest/vkmode_sh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
19 changes: 19 additions & 0 deletions internal/testutil/guestsh.go
Original file line number Diff line number Diff line change
@@ -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")
}
}
Loading