Skip to content

Commit 938a200

Browse files
authored
[lagobot] clear .devbox dirs (#833)
## Summary **Problem:** If we have a `.devbox` directory in an example project, then running the testscript seems to fail. Something about copying that `.devbox` directory is breaking some logic. We should clear the `.devbox` directory before we execute the testscript. **Approach:** In this PR, I clear the `.devbox` directory in the example project __before__ copying the contents over into the testscript's workdir. This has the downside that if we have a `devbox shell` active for that project, then its `.devbox` directory will get cleared out under it. This is sub-optimal but also not a common scenario. I tried deleting the `.devbox` directory __after__ copying it into the testscript's workdir, but that failed. I think but couldn't confirm that it was due to some permissions issue. ## How was it tested? for `examples/development/csharp/hello-world`: 1. ran `devbox run run_test` to generate the `.devbox` dir 2. ran `DEVBOX_DEBUG=0 DEVBOX_EXAMPLE_TESTS=1 go test -v -run TestExamples/development_csharp -count 1 ./testscripts` - also, manually had to filter for `csharp` in the code because the filtering happens _after_ we copy all the projects into the testscript workdirs. I'll send another PR to fix this.
1 parent a883e15 commit 938a200

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

testscripts/testrunner/examplesrunner.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,17 @@ func runSingleExampleTestscript(t *testing.T, examplesDir, projectDir string) {
9696
// implementation detail: the period at the end of the projectDir/.
9797
// is important to ensure this works for both mac and linux.
9898
// Ref.https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00
99-
err = exec.Command("cp", "-r", projectDir+"/.", env.WorkDir).Run()
99+
100+
cmd := exec.Command("rm", "-rf", projectDir+"/.devbox")
101+
err = cmd.Run()
100102
if err != nil {
103+
debug.Log("failed %s before doing cp", cmd)
101104
return errors.WithStack(err)
102105
}
103106

107+
cmd = exec.Command("cp", "-r", projectDir+"/.", env.WorkDir)
108+
debug.Log("Running cmd: %s\n", cmd)
109+
err = cmd.Run()
104110
return errors.WithStack(err)
105111
}
106112

0 commit comments

Comments
 (0)