Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8858: test(cli): run cmd/multica tests outside the host's task marker (#10225)
Jiayuan Zhang8c8ca7d851df
diff --git a/server/cmd/multica/cmd_auth_test.go b/server/cmd/multica/cmd_auth_test.goindex 3772425849..bd1be12f72 100644--- a/server/cmd/multica/cmd_auth_test.go+++ b/server/cmd/multica/cmd_auth_test.go@@ -24,6 +24,10 @@ func TestMain(m *testing.M) {"MULTICA_WORKSPACE_ID","MULTICA_SERVER_URL","MULTICA_TASK_CONFIG_ROOT",+ "MULTICA_TASK_WORKSPACES_ROOT",+ "MULTICA_AGENT_NAME",+ devEnvHomeEnv,+ devEnvNameEnv,} {os.Unsetenv(key)}@@ -41,11 +45,32 @@ func TestMain(m *testing.M) {os.Exit(1)}+ // The daemon-task marker lookup walks up from the working directory. Run+ // from a checkout inside an agent task workdir, the package directory sits+ // below that task's real marker, and every API, config and daemon path+ // refuses. Tests that need a marker create one and t.Chdir into it.+ testLaunchDir, err = os.Getwd()+ if err == nil {+ err = os.Chdir(scratchHome)+ }+ if err != nil {+ _ = os.RemoveAll(scratchHome)+ fmt.Fprintf(os.Stderr, "move cmd/multica tests into scratch home: %v\n", err)+ os.Exit(1)+ }+code := m.Run()+ // Windows cannot remove the current working directory.+ _ = os.Chdir(os.TempDir())_ = os.RemoveAll(scratchHome)os.Exit(code)}+// testLaunchDir is the working directory the test binary started in, before+// TestMain moved it into the scratch home. A helper process whose parent set+// exec.Cmd.Dir reads its fixtures from there.+var testLaunchDir string+var redirectTestHome = testutil.RedirectUserHome// testCmd returns a minimal cobra.Command with the --profile persistent flagdiff --git a/server/cmd/multica/cmd_issue_attachment_test.go b/server/cmd/multica/cmd_issue_attachment_test.goindex abe958f854..827cc6908e 100644--- a/server/cmd/multica/cmd_issue_attachment_test.go+++ b/server/cmd/multica/cmd_issue_attachment_test.go@@ -29,6 +29,9 @@ func TestIssueAttachmentArgvProcess(t *testing.T) {if separator < 0 {t.Fatal("missing CLI argv")}+ // The argv names fixture files relative to the directory the parent ran+ // this process in.+ t.Chdir(testLaunchDir)// TestMain clears task credentials before tests run. Set only synthetic// credentials here, after that isolation, and let TestMain clean up normally.t.Setenv("MULTICA_SERVER_URL", os.Getenv("MULTICA_TEST_ATTACHMENT_SERVER"))