Merge pull request #159 from WesleyJeanette/patch-1
Allow gexec.Build to be called concurrently
Onsi Fakhouri authored 7 years ago
GitHub committed 7 years ago
8 | 8 | "path" |
9 | 9 | "path/filepath" |
10 | 10 | "runtime" |
11 | "sync" | |
11 | 12 | ) |
12 | 13 | |
13 | var tmpDir string | |
14 | var ( | |
15 | mu sync.Mutex | |
16 | tmpDir string | |
17 | ) | |
14 | 18 | |
15 | 19 | /* |
16 | 20 | Build uses go build to compile the package at packagePath. The resulting binary is saved off in a temporary directory. |
59 | 63 | gexec. In Ginkgo this is typically done in an AfterSuite callback. |
60 | 64 | */ |
61 | 65 | func CleanupBuildArtifacts() { |
66 | mu.Lock() | |
67 | defer mu.Unlock() | |
62 | 68 | if tmpDir != "" { |
63 | 69 | os.RemoveAll(tmpDir) |
64 | 70 | tmpDir = "" |
67 | 73 | |
68 | 74 | func temporaryDirectory() (string, error) { |
69 | 75 | var err error |
76 | mu.Lock() | |
77 | defer mu.Unlock() | |
70 | 78 | if tmpDir == "" { |
71 | 79 | tmpDir, err = ioutil.TempDir("", "gexec_artifacts") |
72 | 80 | if err != nil { |