1- using System . IO ;
1+ using System . Diagnostics ;
2+ using System . IO ;
23using GitVersion ;
34using GitVersionCore . Tests ;
45using NUnit . Framework ;
@@ -9,43 +10,58 @@ public class DynamicRepositoryTests : TestBase
910 string workDirectory ;
1011
1112
12- [ SetUp ]
13+ [ OneTimeSetUp ]
1314 public void CreateTemporaryRepository ( )
1415 {
1516 // Note: we can't use guid because paths will be too long
16- workDirectory = Path . Combine ( Path . GetTempPath ( ) , "DynRepoTests" ) ;
17+ workDirectory = Path . Combine ( Path . GetTempPath ( ) , "GV" ) ;
18+
19+ // Clean directory upfront, some build agents are having troubles
20+ if ( Directory . Exists ( workDirectory ) )
21+ {
22+ Directory . Delete ( workDirectory , true ) ;
23+ }
24+
25+ Directory . CreateDirectory ( workDirectory ) ;
1726 }
1827
1928
20- //[TearDown]
21- //public void Cleanup()
22- //{
23- // Directory.Delete(workDirectory, true);
24- //}
29+ [ OneTimeTearDown ]
30+ public void Cleanup ( )
31+ {
2532
33+ }
34+
35+ // Note: use same name twice to see if changing commits works on same (cached) repository
2636 [ Ignore ( "These tests are slow and fail on the second run in Test Explorer and need to be re-written" ) ]
27- [ TestCase ( "GV_master_1" , "https://github.com/GitTools/GitVersion" , "master" , "4783d325521463cd6cf1b61074352da84451f25d" , "4.0.0+1126" ) ]
28- [ TestCase ( "GV_master_2" , "https://github.com/GitTools/GitVersion" , "master" , "3bdcd899530b4e9b37d13639f317da04a749e728" , "4.0.0+1132" ) ]
37+ [ NonParallelizable ]
38+ [ TestCase ( "GV_master" , "https://github.com/GitTools/GitVersion" , "master" , "4783d325521463cd6cf1b61074352da84451f25d" , "4.0.0+1086" ) ]
39+ [ TestCase ( "GV_master" , "https://github.com/GitTools/GitVersion" , "master" , "3bdcd899530b4e9b37d13639f317da04a749e728" , "4.0.0+1092" ) ]
40+ [ TestCase ( "Ctl_develop" , "https://github.com/Catel/Catel" , "develop" , "0e2b6c125a730d2fa5e24394ef64abe62c98e9e9" , "5.12.0-alpha.188" ) ]
41+ [ TestCase ( "Ctl_develop" , "https://github.com/Catel/Catel" , "develop" , "71e71359f37581784e18c94e7a45eee72cbeeb30" , "5.12.0-alpha.192" ) ]
42+ [ TestCase ( "Ctl_master" , "https://github.com/Catel/Catel" , "master" , "f5de8964c35180a5f8607f5954007d5828aa849f" , "5.10.0" ) ]
43+ [ TestCase ( "CtlA_develop" , "https://github.com/Catel/Catel.Analyzers" , "develop" , "be0aa94642d6ff1df6209e2180a7fe0de9aab384" , "0.1.0-alpha.21" ) ]
44+ [ TestCase ( "CtlA_develop" , "https://github.com/Catel/Catel.Analyzers" , "develop" , "0e2b6c125a730d2fa5e24394ef64abe62c98e9e9" , "0.1.0-alpha.23" ) ]
2945 public void FindsVersionInDynamicRepo ( string name , string url , string targetBranch , string commitId , string expectedFullSemVer )
3046 {
3147 var root = Path . Combine ( workDirectory , name ) ;
32- var dynamicDirectory = Path . Combine ( root , "dynamic" ) ;
33- var workingDirectory = Path . Combine ( root , "working" ) ;
34-
35- // Clear upfront
36- if ( Directory . Exists ( root ) )
37- {
38- Directory . Delete ( root , true ) ;
39- }
48+ var dynamicDirectory = Path . Combine ( root , "D" ) ; // dynamic, keeping directory as short as possible
49+ var workingDirectory = Path . Combine ( root , "W" ) ; // working, keeping directory as short as possible
4050
4151 Directory . CreateDirectory ( dynamicDirectory ) ;
4252 Directory . CreateDirectory ( workingDirectory ) ;
4353
54+ Logger . AddLoggersTemporarily (
55+ x => Debug . WriteLine ( $ "[DEBUG] { x } ") ,
56+ x => Debug . WriteLine ( $ "[INFO] { x } ") ,
57+ x => Debug . WriteLine ( $ "[WARNING] { x } ") ,
58+ x => Debug . WriteLine ( $ "[ERROR] { x } ") ) ;
59+
4460 var executeCore = new ExecuteCore ( new TestFileSystem ( ) ) ;
4561
4662 var versionVariables = executeCore . ExecuteGitVersion ( url , dynamicDirectory , null , targetBranch ,
4763 false , workingDirectory , commitId ) ;
4864
4965 Assert . AreEqual ( expectedFullSemVer , versionVariables . FullSemVer ) ;
5066 }
51- }
67+ }
0 commit comments