1
- using System . IO ;
1
+ using System . Diagnostics ;
2
+ using System . IO ;
2
3
using GitVersion ;
3
4
using GitVersionCore . Tests ;
4
5
using NUnit . Framework ;
@@ -9,43 +10,58 @@ public class DynamicRepositoryTests : TestBase
9
10
string workDirectory ;
10
11
11
12
12
- [ SetUp ]
13
+ [ OneTimeSetUp ]
13
14
public void CreateTemporaryRepository ( )
14
15
{
15
16
// 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 ) ;
17
26
}
18
27
19
28
20
- //[TearDown]
21
- //public void Cleanup()
22
- //{
23
- // Directory.Delete(workDirectory, true);
24
- //}
29
+ [ OneTimeTearDown ]
30
+ public void Cleanup ( )
31
+ {
25
32
33
+ }
34
+
35
+ // Note: use same name twice to see if changing commits works on same (cached) repository
26
36
[ 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" ) ]
29
45
public void FindsVersionInDynamicRepo ( string name , string url , string targetBranch , string commitId , string expectedFullSemVer )
30
46
{
31
47
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
40
50
41
51
Directory . CreateDirectory ( dynamicDirectory ) ;
42
52
Directory . CreateDirectory ( workingDirectory ) ;
43
53
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
+
44
60
var executeCore = new ExecuteCore ( new TestFileSystem ( ) ) ;
45
61
46
62
var versionVariables = executeCore . ExecuteGitVersion ( url , dynamicDirectory , null , targetBranch ,
47
63
false , workingDirectory , commitId ) ;
48
64
49
65
Assert . AreEqual ( expectedFullSemVer , versionVariables . FullSemVer ) ;
50
66
}
51
- }
67
+ }
0 commit comments