@@ -10,46 +10,18 @@ public class DynamicRepositoryTests : TestBase
10
10
{
11
11
private string ? workDirectory ;
12
12
13
- private static void ClearReadOnly ( DirectoryInfo parentDirectory )
14
- {
15
- parentDirectory . Attributes = FileAttributes . Normal ;
16
- foreach ( var fi in parentDirectory . GetFiles ( ) )
17
- {
18
- fi . Attributes = FileAttributes . Normal ;
19
- }
20
- foreach ( var di in parentDirectory . GetDirectories ( ) )
21
- {
22
- ClearReadOnly ( di ) ;
23
- }
24
- }
13
+ [ SetUp ]
14
+ public void SetUp ( ) => this . workDirectory = PathHelper . Combine ( Path . GetTempPath ( ) , "GV" ) ;
25
15
26
- [ OneTimeSetUp ]
27
- public void CreateTemporaryRepository ( )
28
- {
29
- // Note: we can't use guid because paths will be too long
30
- this . workDirectory = PathHelper . Combine ( Path . GetTempPath ( ) , "GV" ) ;
31
-
32
- // Clean directory upfront, some build agents are having troubles
33
- if ( Directory . Exists ( this . workDirectory ) )
34
- {
35
- var di = new DirectoryInfo ( this . workDirectory ) ;
36
- ClearReadOnly ( di ) ;
37
-
38
- Directory . Delete ( this . workDirectory , true ) ;
39
- }
40
-
41
- Directory . CreateDirectory ( this . workDirectory ) ;
42
- }
43
-
44
- [ OneTimeTearDown ]
45
- public void Cleanup ( )
16
+ [ TearDown ]
17
+ public void TearDown ( )
46
18
{
47
19
}
48
20
49
21
// Note: use same name twice to see if changing commits works on same (cached) repository
50
22
[ NonParallelizable ]
51
- [ TestCase ( "GV_main" , "https://github.com/GitTools/GitVersion" , MainBranch , "efddf2f92c539a9c27f1904d952dcab8fb955f0e" , "5.8.2-56" ) ]
52
23
[ TestCase ( "GV_main" , "https://github.com/GitTools/GitVersion" , MainBranch , "2dc142a4a4df77db61a00d9fb7510b18b3c2c85a" , "5.8.2-47" ) ]
24
+ [ TestCase ( "GV_main" , "https://github.com/GitTools/GitVersion" , MainBranch , "efddf2f92c539a9c27f1904d952dcab8fb955f0e" , "5.8.2-56" ) ]
53
25
public void FindsVersionInDynamicRepo ( string name , string url , string targetBranch , string commitId , string expectedFullSemVer )
54
26
{
55
27
var root = PathHelper . Combine ( this . workDirectory , name ) ;
@@ -64,21 +36,22 @@ public void FindsVersionInDynamicRepo(string name, string url, string targetBran
64
36
TargetBranch = targetBranch ,
65
37
CommitId = commitId
66
38
} ,
67
- Settings = { NoFetch = false } ,
39
+ Settings = { NoFetch = false , NoCache = true } ,
68
40
WorkingDirectory = workingDirectory
69
41
} ;
70
42
var options = Options . Create ( gitVersionOptions ) ;
71
43
72
- Directory . CreateDirectory ( dynamicDirectory ) ;
73
- Directory . CreateDirectory ( workingDirectory ) ;
74
-
75
44
var sp = ConfigureServices ( services => services . AddSingleton ( options ) ) ;
76
45
77
46
sp . DiscoverRepository ( ) ;
78
47
79
48
var gitPreparer = sp . GetRequiredService < IGitPreparer > ( ) ;
80
49
gitPreparer . Prepare ( ) ;
81
50
51
+ var fileSystem = sp . GetRequiredService < IFileSystem > ( ) ;
52
+ fileSystem . CreateDirectory ( dynamicDirectory ) ;
53
+ fileSystem . CreateDirectory ( workingDirectory ) ;
54
+
82
55
var gitVersionCalculator = sp . GetRequiredService < IGitVersionCalculateTool > ( ) ;
83
56
84
57
var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
0 commit comments