File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ public class Git {
5858
5959 public class var majorVersionNumber : Int ? {
6060 let prefix = " git version "
61- var version = Git . version
61+ var version = self . version
6262 if version. hasPrefix ( prefix) {
6363 let prefixRange = version. startIndex... version. startIndex. advanced ( by: prefix. characters. count)
6464 version. removeSubrange ( prefixRange)
Original file line number Diff line number Diff line change @@ -40,4 +40,5 @@ XCTMain([
4040 testCase ( WalkTests . allTests) ,
4141 testCase ( ModuleMapsTestCase . allTests) ,
4242 testCase ( DescribeTests . allTests) ,
43+ testCase ( GitTests . allTests) ,
4344] )
Original file line number Diff line number Diff line change 1+ /*
2+ This source file is part of the Swift.org open source project
3+
4+ Copyright 2015 - 2016 Apple Inc. and the Swift project authors
5+ Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+ See http://swift.org/LICENSE.txt for license information
8+ See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+ */
10+
11+ @testable import Utility
12+ import XCTest
13+
14+ class GitMoc : Git {
15+ static var mocVersion : String = " git version 2.5.4 (Apple Git-61) "
16+ override class var version : String ! {
17+ return mocVersion
18+ }
19+ }
20+
21+ class GitTests : XCTestCase {
22+
23+ func testGitVersion( ) {
24+ XCTAssertEqual ( GitMoc . majorVersionNumber, 2 )
25+
26+ GitMoc . mocVersion = " 2.5.4 "
27+ XCTAssertEqual ( GitMoc . majorVersionNumber, 2 )
28+
29+ GitMoc . mocVersion = " git version 1.5.4 "
30+ XCTAssertEqual ( GitMoc . majorVersionNumber, 1 )
31+
32+ GitMoc . mocVersion = " 1.25.4 "
33+ XCTAssertEqual ( GitMoc . majorVersionNumber, 1 )
34+ }
35+ }
36+
37+ extension GitTests {
38+ static var allTests : [ ( String , GitTests -> ( ) throws -> Void ) ] {
39+ return [
40+ ( " testGitVersion " , testGitVersion) ,
41+ ]
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments