refactor(ioscompanion): inline xcodegenArgs, drop tautological argv tests

This commit is contained in:
pj committed 2026-06-09 18:21:52 +05:30
1 parent 27e2cbf956
commit 9082ad906c
3 files changed
+1 -71

No files matched your search

@@ -195,15 +195,3 @@ func TestDeviceCloseStopsRunnerAndTunnel(t *testing.T) {
t.Fatal("Close must close the usbmux tunnel")
}
}
func equalArgs(got, want []string) bool {
if len(got) != len(want) {
return false
}
for i := range got {
if got[i] != want[i] {
return false
}
}
return true
}
+1 -6
View File
@@ -176,7 +176,7 @@ func (d *Driver) buildDeviceRunnerIfNeeded(ctx context.Context, companionDir, de
return nil
}
if out, genErr := runQuiet(ctx, companionDir, xcodegenArgs(filepath.Join(companionDir, "project.yml"))...); genErr != nil {
if out, genErr := runQuiet(ctx, companionDir, "xcodegen", "--spec", filepath.Join(companionDir, "project.yml")); genErr != nil {
return fmt.Errorf("xcodegen: %w: %s", genErr, strings.TrimSpace(string(out)))
}
@@ -204,11 +204,6 @@ func buildCacheKey(companionDir string, creds signingCredentials) (string, error
return hex.EncodeToString(sum[:]), nil
}
// xcodegenArgs regenerates the runner project from its spec.
func xcodegenArgs(specPath string) []string {
return []string{"xcodegen", "--spec", specPath}
}
// buildForTestingArgs builds the runner for a generic device destination, signed
// through the App Store Connect API key with automatic provisioning. A generic
// destination keeps the build off any specific booted device; the wildcard dev
@@ -7,59 +7,6 @@ import (
"testing"
)
func TestBuildForTestingArgs(t *testing.T) {
creds := signingCredentials{team: "TEAM1", authKeyPath: "/k/AuthKey.p8", authKeyID: "KID", authIssuerID: "ISS"}
args := buildForTestingArgs("/p/CompanionRunner.xcodeproj", "/d/derived", creds)
joined := strings.Join(args, " ")
for _, want := range []string{
"xcodebuild build-for-testing",
"-project /p/CompanionRunner.xcodeproj",
"-scheme CompanionRunner",
"-destination generic/platform=iOS",
"-derivedDataPath /d/derived",
"-allowProvisioningUpdates",
"-authenticationKeyPath /k/AuthKey.p8",
"-authenticationKeyID KID",
"-authenticationKeyIssuerID ISS",
"CODE_SIGNING_ALLOWED=YES",
"CODE_SIGNING_REQUIRED=YES",
"CODE_SIGN_STYLE=Automatic",
"DEVELOPMENT_TEAM=TEAM1",
"GENERATE_INFOPLIST_FILE=YES",
} {
if !strings.Contains(joined, want) {
t.Errorf("build args missing %q in %q", want, joined)
}
}
}
func TestTestWithoutBuildingArgs(t *testing.T) {
creds := signingCredentials{team: "TEAM1", authKeyPath: "/k/AuthKey.p8", authKeyID: "KID", authIssuerID: "ISS"}
args := testWithoutBuildingArgs("/x/run.xctestrun", "00008140-HW", creds)
joined := strings.Join(args, " ")
for _, want := range []string{
"xcodebuild test-without-building",
"-xctestrun /x/run.xctestrun",
"-destination platform=iOS,id=00008140-HW",
"-allowProvisioningUpdates",
"-authenticationKeyPath /k/AuthKey.p8",
"-authenticationKeyID KID",
"-authenticationKeyIssuerID ISS",
} {
if !strings.Contains(joined, want) {
t.Errorf("test args missing %q in %q", want, joined)
}
}
}
func TestXcodegenArgs(t *testing.T) {
args := xcodegenArgs("/c/project.yml")
want := []string{"xcodegen", "--spec", "/c/project.yml"}
if !equalArgs(args, want) {
t.Fatalf("xcodegen args = %v, want %v", args, want)
}
}
func TestTestTargetNameFromJSON(t *testing.T) {
// A device xctestrun-as-json: one test-target dict plus the metadata entry.
data := []byte(`{