|
5 | 5 | _ "embed" |
6 | 6 | "fmt" |
7 | 7 | "os" |
| 8 | + "path" |
8 | 9 | "path/filepath" |
9 | 10 |
|
10 | 11 | "github.com/docker/docker/api/types/container" |
@@ -35,13 +36,20 @@ func Run(ctx context.Context, testFiles []string, config pgconn.Config, fsys afe |
35 | 36 | } |
36 | 37 | binds := make([]string, len(testFiles)) |
37 | 38 | cmd := []string{"pg_prove", "--ext", ".pg", "--ext", ".sql", "-r"} |
| 39 | + var workingDir string |
38 | 40 | for i, fp := range testFiles { |
39 | 41 | if !filepath.IsAbs(fp) { |
40 | 42 | fp = filepath.Join(utils.CurrentDirAbs, fp) |
41 | 43 | } |
42 | 44 | dockerPath := utils.ToDockerPath(fp) |
43 | 45 | cmd = append(cmd, dockerPath) |
44 | 46 | binds[i] = fmt.Sprintf("%s:%s:ro", fp, dockerPath) |
| 47 | + if workingDir == "" { |
| 48 | + workingDir = dockerPath |
| 49 | + if path.Ext(dockerPath) != "" { |
| 50 | + workingDir = path.Dir(dockerPath) |
| 51 | + } |
| 52 | + } |
45 | 53 | } |
46 | 54 | if viper.GetBool("DEBUG") { |
47 | 55 | cmd = append(cmd, "--verbose") |
@@ -89,7 +97,8 @@ func Run(ctx context.Context, testFiles []string, config pgconn.Config, fsys afe |
89 | 97 | "PGPASSWORD=" + config.Password, |
90 | 98 | "PGDATABASE=" + config.Database, |
91 | 99 | }, |
92 | | - Cmd: cmd, |
| 100 | + Cmd: cmd, |
| 101 | + WorkingDir: workingDir, |
93 | 102 | }, |
94 | 103 | hostConfig, |
95 | 104 | network.NetworkingConfig{}, |
|
0 commit comments