@@ -20,6 +20,9 @@ class GitTests: XCTestCase, XCTestCaseProvider {
20
20
return [
21
21
( " testHasVersion " , testHasVersion) ,
22
22
( " testHasNoVersion " , testHasNoVersion) ,
23
+ ( " testCloneShouldNotCrashWihoutTags " , testCloneShouldNotCrashWihoutTags) ,
24
+ ( " testCloneShouldCrashWihoutTags " , testCloneShouldCrashWihoutTags) ,
25
+
23
26
]
24
27
}
25
28
@@ -36,6 +39,14 @@ class GitTests: XCTestCase, XCTestCaseProvider {
36
39
XCTAssertFalse ( gitRepo. hasVersion)
37
40
}
38
41
}
42
+
43
+ func testCloneShouldNotCrashWihoutTags( ) {
44
+ tryCloningRepoWithTag ( " 0.1.0 " , shouldCrash: false )
45
+ }
46
+
47
+ func testCloneShouldCrashWihoutTags( ) {
48
+ tryCloningRepoWithTag ( nil , shouldCrash: true )
49
+ }
39
50
}
40
51
41
52
//MARK: - Helpers
@@ -59,3 +70,18 @@ private func makeGitRepo(dstdir: String, tag: String?, file: StaticString = __FI
59
70
}
60
71
return nil
61
72
}
73
+
74
+ private func tryCloningRepoWithTag( tag: String ? , shouldCrash: Bool ) {
75
+ var done = !shouldCrash
76
+ mktmpdir { path in
77
+ makeGitRepo ( path, tag: tag) !
78
+ do {
79
+ _ = try Sandbox . RawClone ( path: path)
80
+ } catch Error . GitVersionTagRequired {
81
+ done = shouldCrash
82
+ } catch {
83
+ XCTFail ( )
84
+ }
85
+ XCTAssertTrue ( done)
86
+ }
87
+ }
0 commit comments