Browse Source

tests: fix race condition in TestPathRunOnDemand (#2663)

pull/2667/head
Alessandro Ros 2 years ago committed by GitHub
parent
commit
f82c6e3654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      internal/core/path_test.go

6
internal/core/path_test.go

@ -84,7 +84,7 @@ func main() {
func TestPathRunOnDemand(t *testing.T) { func TestPathRunOnDemand(t *testing.T) {
onDemandFile := filepath.Join(os.TempDir(), "ondemand") onDemandFile := filepath.Join(os.TempDir(), "ondemand")
onUnDemandFile := filepath.Join(os.TempDir(), "ondisconnect") onUnDemandFile := filepath.Join(os.TempDir(), "onundemand")
srcFile := filepath.Join(os.TempDir(), "ondemand.go") srcFile := filepath.Join(os.TempDir(), "ondemand.go")
err := os.WriteFile(srcFile, err := os.WriteFile(srcFile,
@ -182,14 +182,14 @@ func TestPathRunOnDemand(t *testing.T) {
}() }()
for { for {
_, err := os.Stat(onDemandFile) _, err := os.Stat(onUnDemandFile)
if err == nil { if err == nil {
break break
} }
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
} }
_, err := os.Stat(onUnDemandFile) _, err := os.Stat(onDemandFile)
require.NoError(t, err) require.NoError(t, err)
}) })
} }

Loading…
Cancel
Save