@@ -10,46 +10,18 @@ public class DynamicRepositoryTests : TestBase
1010{
1111 private string ? workDirectory ;
1212
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" ) ;
2515
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 ( )
4618 {
4719 }
4820
4921 // Note: use same name twice to see if changing commits works on same (cached) repository
5022 [ NonParallelizable ]
51- [ TestCase ( "GV_main" , "https://github.com/GitTools/GitVersion" , MainBranch , "efddf2f92c539a9c27f1904d952dcab8fb955f0e" , "5.8.2-56" ) ]
5223 [ 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" ) ]
5325 public void FindsVersionInDynamicRepo ( string name , string url , string targetBranch , string commitId , string expectedFullSemVer )
5426 {
5527 var root = PathHelper . Combine ( this . workDirectory , name ) ;
@@ -64,21 +36,22 @@ public void FindsVersionInDynamicRepo(string name, string url, string targetBran
6436 TargetBranch = targetBranch ,
6537 CommitId = commitId
6638 } ,
67- Settings = { NoFetch = false } ,
39+ Settings = { NoFetch = false , NoCache = true } ,
6840 WorkingDirectory = workingDirectory
6941 } ;
7042 var options = Options . Create ( gitVersionOptions ) ;
7143
72- Directory . CreateDirectory ( dynamicDirectory ) ;
73- Directory . CreateDirectory ( workingDirectory ) ;
74-
7544 var sp = ConfigureServices ( services => services . AddSingleton ( options ) ) ;
7645
7746 sp . DiscoverRepository ( ) ;
7847
7948 var gitPreparer = sp . GetRequiredService < IGitPreparer > ( ) ;
8049 gitPreparer . Prepare ( ) ;
8150
51+ var fileSystem = sp . GetRequiredService < IFileSystem > ( ) ;
52+ fileSystem . CreateDirectory ( dynamicDirectory ) ;
53+ fileSystem . CreateDirectory ( workingDirectory ) ;
54+
8255 var gitVersionCalculator = sp . GetRequiredService < IGitVersionCalculateTool > ( ) ;
8356
8457 var versionVariables = gitVersionCalculator . CalculateVersionVariables ( ) ;
0 commit comments