File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 9
9
"os"
10
10
"path/filepath"
11
11
"testing"
12
+ "time"
12
13
13
14
"code.gitea.io/gitea/modules/setting"
14
15
@@ -72,6 +73,18 @@ func createTestEngine(fixturesDir string) error {
72
73
return InitFixtures (& testfixtures.SQLite {}, fixturesDir )
73
74
}
74
75
76
+ func removeAllWithRetry (dir string ) error {
77
+ var err error
78
+ for i := 0 ; i < 20 ; i ++ {
79
+ err = os .RemoveAll (dir )
80
+ if err == nil {
81
+ break
82
+ }
83
+ time .Sleep (100 * time .Millisecond )
84
+ }
85
+ return err
86
+ }
87
+
75
88
// PrepareTestDatabase load test fixtures into test database
76
89
func PrepareTestDatabase () error {
77
90
return LoadFixtures ()
@@ -81,7 +94,7 @@ func PrepareTestDatabase() error {
81
94
// by tests that use the above MainTest(..) function.
82
95
func PrepareTestEnv (t testing.TB ) {
83
96
assert .NoError (t , PrepareTestDatabase ())
84
- assert .NoError (t , os . RemoveAll (setting .RepoRootPath ))
97
+ assert .NoError (t , removeAllWithRetry (setting .RepoRootPath ))
85
98
metaPath := filepath .Join (giteaRoot , "integrations" , "gitea-repositories-meta" )
86
99
assert .NoError (t , com .CopyDir (metaPath , setting .RepoRootPath ))
87
100
}
You can’t perform that action at this time.
0 commit comments