10
10
11
11
import XCTest
12
12
13
- import TestSupport
14
13
import Basic
14
+ import Utility
15
+
16
+ import TestSupport
15
17
16
18
import class PackageDescription. Package
17
- import class Utility. Git
18
19
import struct PackageDescription. Version
19
20
import struct PackageModel. Manifest
20
21
@@ -34,6 +35,30 @@ class GitTests: XCTestCase {
34
35
}
35
36
}
36
37
38
+ func testVersionSpecificTags( ) {
39
+ let current = Versioning . currentVersion
40
+ mktmpdir { path in
41
+ let gitRepo = makeGitRepo ( path, tags: [ " 0.1.0 " , " 0.2.0@swift- \( current. major) " , " 0.3.0@swift- \( current. major) . \( current. minor) " , " 0.4.0@swift- \( current. major) . \( current. minor) . \( current. patch) " ] ) !
42
+ XCTAssertTrue ( gitRepo. hasVersion)
43
+ XCTAssertEqual ( gitRepo. versions, [ Version ( 0 , 4 , 0 ) ] )
44
+ }
45
+ mktmpdir { path in
46
+ let gitRepo = makeGitRepo ( path, tags: [ " 0.1.0 " , " 0.2.0@swift- \( current. major) " , " 0.3.0@swift- \( current. major) . \( current. minor) " ] ) !
47
+ XCTAssertTrue ( gitRepo. hasVersion)
48
+ XCTAssertEqual ( gitRepo. versions, [ Version ( 0 , 3 , 0 ) ] )
49
+ }
50
+ mktmpdir { path in
51
+ let gitRepo = makeGitRepo ( path, tags: [ " 0.1.0 " , " 0.2.0@swift- \( current. major) " ] ) !
52
+ XCTAssertTrue ( gitRepo. hasVersion)
53
+ XCTAssertEqual ( gitRepo. versions, [ Version ( 0 , 2 , 0 ) ] )
54
+ }
55
+ mktmpdir { path in
56
+ let gitRepo = makeGitRepo ( path, tags: [ " 0.1.0 " , " v0.2.0@swift- \( current. major) " ] ) !
57
+ XCTAssertTrue ( gitRepo. hasVersion)
58
+ XCTAssertEqual ( gitRepo. versions, [ Version ( 0 , 2 , 0 ) ] )
59
+ }
60
+ }
61
+
37
62
func testHasNoVersion( ) {
38
63
mktmpdir { path in
39
64
let gitRepo = makeGitRepo ( path, tag: nil ) !
@@ -51,6 +76,7 @@ class GitTests: XCTestCase {
51
76
52
77
static var allTests = [
53
78
( " testHasVersion " , testHasVersion) ,
79
+ ( " testVersionSpecificTags " , testVersionSpecificTags) ,
54
80
( " testHasNoVersion " , testHasNoVersion) ,
55
81
( " testCloneShouldNotCrashWihoutTags " , testCloneShouldNotCrashWihoutTags) ,
56
82
( " testCloneShouldCrashWihoutTags " , testCloneShouldCrashWihoutTags) ,
@@ -60,7 +86,11 @@ class GitTests: XCTestCase {
60
86
//MARK: - Helpers
61
87
62
88
func makeGitRepo( _ dstdir: AbsolutePath , tag: String ? = nil , file: StaticString = #file, line: UInt = #line) -> Git . Repo ? {
63
- initGitRepo ( dstdir, tag: tag)
89
+ return makeGitRepo ( dstdir, tags: tag. flatMap { [ $0] } ?? [ ] , file: file, line: line)
90
+ }
91
+
92
+ func makeGitRepo( _ dstdir: AbsolutePath , tags: [ String ] , file: StaticString = #file, line: UInt = #line) -> Git . Repo ? {
93
+ initGitRepo ( dstdir, tags: tags)
64
94
return Git . Repo ( path: dstdir)
65
95
}
66
96
0 commit comments