@@ -22,17 +22,18 @@ import (
22
22
// virtenvs of devbox plugins in this directory. We need to use a custom
23
23
// path that is intentionally short, since some plugins store unix sockets in
24
24
// their virtenv and unix sockets require their paths to be short.
25
- const xdgStateHomeDir = "/tmp/devbox-example- testscripts"
25
+ const xdgStateHomeDir = "/tmp/devbox-testscripts"
26
26
27
- // RunExamplesTestscripts generates testscripts for each example devbox-project.
28
- func RunExamplesTestscripts (t * testing.T , examplesDir string ) {
27
+ // RunDevboxTestscripts generates and runs a testscript test for each Devbox project in dir.
28
+ // For each project, runs `devbox run run_test` (if script exists) and asserts it succeeds.
29
+ func RunDevboxTestscripts (t * testing.T , dir string ) {
29
30
// ensure the state home dir for devbox exists
30
31
err := os .MkdirAll (xdgStateHomeDir , 0700 )
31
32
if err != nil && ! errors .Is (err , fs .ErrNotExist ) {
32
33
t .Error (err )
33
34
}
34
35
35
- err = filepath .WalkDir (examplesDir , func (path string , entry os.DirEntry , err error ) error {
36
+ err = filepath .WalkDir (dir , func (path string , entry os.DirEntry , err error ) error {
36
37
if err != nil {
37
38
return err
38
39
}
@@ -75,16 +76,16 @@ func RunExamplesTestscripts(t *testing.T, examplesDir string) {
75
76
}
76
77
77
78
t .Logf ("running testscript for example: %s\n " , path )
78
- runSingleExampleTestscript (t , examplesDir , path )
79
+ runSingleDevboxTestscript (t , dir , path )
79
80
return nil
80
81
})
81
82
if err != nil {
82
83
t .Error (err )
83
84
}
84
85
}
85
86
86
- func runSingleExampleTestscript (t * testing.T , examplesDir , projectDir string ) {
87
- testscriptDir , err := generateTestscript (t , examplesDir , projectDir )
87
+ func runSingleDevboxTestscript (t * testing.T , dir , projectDir string ) {
88
+ testscriptDir , err := generateTestscript (t , dir , projectDir )
88
89
if err != nil {
89
90
t .Error (err )
90
91
}
@@ -127,10 +128,10 @@ func runSingleExampleTestscript(t *testing.T, examplesDir, projectDir string) {
127
128
}
128
129
129
130
// generateTestscript will create a temp-directory and place the generic
130
- // testscript file (.test.txt) for all examples devbox-projects in it .
131
+ // testscript file (.test.txt) for all devbox-projects in the dir .
131
132
// It returns the directory containing the testscript file.
132
- func generateTestscript (t * testing.T , examplesDir , projectDir string ) (string , error ) {
133
- testPath , err := filepath .Rel (examplesDir , projectDir )
133
+ func generateTestscript (t * testing.T , dir , projectDir string ) (string , error ) {
134
+ testPath , err := filepath .Rel (dir , projectDir )
134
135
if err != nil {
135
136
return "" , errors .WithStack (err )
136
137
}
0 commit comments