MCPcopy Index your code
hub / github.com/jetify-com/devbox / runSingleDevboxTestscript

Function runSingleDevboxTestscript

testscripts/testrunner/examplesrunner.go:100–140  ·  view source on GitHub ↗
(t *testing.T, dir, projectDir string)

Source from the content-addressed store, hash-verified

98}
99
100func runSingleDevboxTestscript(t *testing.T, dir, projectDir string) {
101 testscriptDir, err := generateTestscript(t, dir, projectDir)
102 if err != nil {
103 t.Error(err)
104 }
105
106 params := getTestscriptParams(testscriptDir)
107
108 // save a reference to the original params.Setup so that we can wrap it below
109 setup := params.Setup
110 params.Setup = func(envs *testscript.Env) error {
111 // We set a custom XDG_STATE_HOME to an intentionally short path.
112 // Reason: devbox plugins like postgres store unix socket files in their state dir.
113 envs.Setenv(envir.XDGStateHome, xdgStateHomeDir)
114
115 // setup the devbox testscript environment
116 if err := setup(envs); err != nil {
117 return errors.WithStack(err)
118 }
119
120 // copy all the files and folders of the devbox-project being tested to the workdir
121 slog.Debug("copying projectDir: %s to env.WorkDir: %s\n", projectDir, envs.WorkDir)
122 // implementation detail: the period at the end of the projectDir/.
123 // is important to ensure this works for both mac and linux.
124 // Ref.https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00
125
126 cmd := exec.Command("rm", "-rf", projectDir+"/.devbox")
127 err = cmd.Run()
128 if err != nil {
129 slog.Error("failed %s before doing cp", "cmd", cmd, "err", err)
130 return errors.WithStack(err)
131 }
132
133 cmd = exec.Command("cp", "-r", projectDir+"/.", envs.WorkDir)
134 slog.Debug("running cmd", "cmd", cmd)
135 err = cmd.Run()
136 return errors.WithStack(err)
137 }
138
139 testscript.Run(t, params)
140}
141
142// generateTestscript will create a temp-directory and place the generic
143// testscript file (.test.txt) for all devbox-projects in the dir.

Callers 1

RunDevboxTestscriptsFunction · 0.85

Calls 5

generateTestscriptFunction · 0.85
getTestscriptParamsFunction · 0.85
CommandMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected