@@ -93,15 +93,19 @@ func MainTest(m *testing.M, testOptsArg ...*TestOptions) {
9393 setting .SSH .Domain = "try.gitea.io"
9494 setting .Database .Type = "sqlite3"
9595 setting .Repository .DefaultBranch = "master" // many test code still assume that default branch is called "master"
96- repoRootPath , _ , err := temp .MkdirTemp ("repos" )
96+ repoRootPath , cleanup1 , err := temp .MkdirTemp ("repos" )
9797 if err != nil {
9898 fatalTestError ("TempDir: %v\n " , err )
9999 }
100+ defer cleanup1 ()
101+
100102 setting .RepoRootPath = repoRootPath
101- appDataPath , _ , err := temp .MkdirTemp ("appdata" )
103+ appDataPath , cleanup2 , err := temp .MkdirTemp ("appdata" )
102104 if err != nil {
103105 fatalTestError ("TempDir: %v\n " , err )
104106 }
107+ defer cleanup2 ()
108+
105109 setting .AppDataPath = appDataPath
106110 setting .AppWorkPath = giteaRoot
107111 setting .StaticRootPath = giteaRoot
@@ -154,13 +158,6 @@ func MainTest(m *testing.M, testOptsArg ...*TestOptions) {
154158 fatalTestError ("tear down failed: %v\n " , err )
155159 }
156160 }
157-
158- if err = util .RemoveAll (repoRootPath ); err != nil {
159- fatalTestError ("util.RemoveAll: %v\n " , err )
160- }
161- if err = util .RemoveAll (appDataPath ); err != nil {
162- fatalTestError ("util.RemoveAll: %v\n " , err )
163- }
164161 os .Exit (exitStatus )
165162}
166163
0 commit comments