Skip to content

Commit

Permalink
Measure code coverage (#35)
Browse files Browse the repository at this point in the history
Test on Linux
  • Loading branch information
Kuniwak authored Jun 1, 2018
1 parent 5459dc2 commit 9d85851
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
jobs:
build:
docker:
- image: library/swift:4.1
steps:
- checkout
- run:
name: Test
command: swift test
8 changes: 8 additions & 0 deletions MirrorDiffKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@
62D9B2441F89CF9C003EB20D /* Diffable+PrettyPrintable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2475EFB17462C4A09EBF5CDD /* Diffable+PrettyPrintable.swift */; };
DD7502881C68FEDE006590AF /* MirrorDiffKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6DA0F1BF000BD002C0205 /* MirrorDiffKit.framework */; };
DD7502921C690C7A006590AF /* MirrorDiffKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52D6D9F01BEFFFBE002C0205 /* MirrorDiffKit.framework */; };
EA2163DC13FE3647327F18A9 /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA216798C613BF7343B78F9B /* CGFloat.swift */; };
EA2165CDBCCC092295716C5C /* Issue30Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA21612FF0A7126E52BCEC00 /* Issue30Tests.swift */; };
EA2167097B3AED6125E54396 /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA216798C613BF7343B78F9B /* CGFloat.swift */; };
EA216CF30D62188E5155A7E8 /* Issue30Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA21612FF0A7126E52BCEC00 /* Issue30Tests.swift */; };
EA216F8778D14A6219C76D22 /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA216798C613BF7343B78F9B /* CGFloat.swift */; };
EA216F9D625A95D8C24BBC44 /* Issue30Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA21612FF0A7126E52BCEC00 /* Issue30Tests.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -266,6 +269,7 @@
DD75027A1C68FCFC006590AF /* MirrorDiffKit-macOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "MirrorDiffKit-macOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
DD75028D1C690C7A006590AF /* MirrorDiffKit-tvOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "MirrorDiffKit-tvOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
EA21612FF0A7126E52BCEC00 /* Issue30Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Issue30Tests.swift; sourceTree = "<group>"; };
EA216798C613BF7343B78F9B /* CGFloat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloat.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -374,6 +378,7 @@
2475E9B7A1DFD63AED417A2A /* MirrorDiffKitTests */ = {
isa = PBXGroup;
children = (
EA216798C613BF7343B78F9B /* CGFloat.swift */,
2475EB2612EBD9B39D1B4013 /* Diffable+PrettyPrintableTests.swift */,
2475E181CA7D757D18DEC5E2 /* DiffableSequenceTests.swift */,
2475E2E82C8E152A456073DA /* DiffableSetTests.swift */,
Expand Down Expand Up @@ -778,6 +783,7 @@
2475EF4F935D471711CF5B79 /* MirrorDiffKit.drainTests.swift in Sources */,
2475E0E8A362A5E697A888C0 /* Issue22Tests.swift in Sources */,
EA216CF30D62188E5155A7E8 /* Issue30Tests.swift in Sources */,
EA2167097B3AED6125E54396 /* CGFloat.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -913,6 +919,7 @@
2475E1846A255E42EB0FF14E /* MirrorDiffKit.drainTests.swift in Sources */,
2475E93DD7224451896564C3 /* Issue22Tests.swift in Sources */,
EA216F9D625A95D8C24BBC44 /* Issue30Tests.swift in Sources */,
EA2163DC13FE3647327F18A9 /* CGFloat.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -937,6 +944,7 @@
2475ECFCB3F5C388B2AD52DD /* MirrorDiffKit.drainTests.swift in Sources */,
2475E71D83906B540219C374 /* Issue22Tests.swift in Sources */,
EA2165CDBCCC092295716C5C /* Issue30Tests.swift in Sources */,
EA216F8778D14A6219C76D22 /* CGFloat.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
41 changes: 41 additions & 0 deletions Tests/MirrorDiffKitTests/CGFloat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Foundation

#if os(Linux)
typealias CGFloatCompatibleWithLinux = CGFloat

class CGFloat {
fileprivate let value: Double

init(_ value: Double) {
self.value = value
}
}

// SEE: https://github.com/apple/swift/blob/d3cb915abb9af1e8ccfbcfd4515e2b75fc75b5f1/stdlib/public/SDK/CoreGraphics/CGFloat.swift.gyb#L363-L368
extension CGFloat: CustomReflectable {
var customMirror: Mirror {
return Mirror(reflecting: self.value)
}
}


// SEE: https://github.com/apple/swift/blob/d3cb915abb9af1e8ccfbcfd4515e2b75fc75b5f1/stdlib/public/SDK/CoreGraphics/CGFloat.swift.gyb#L370-L376
extension CGFloat: CustomStringConvertible {
var description: String {
return "\(self.value)"
}
}


func createCGFloat(_ value: Double) -> CGFloat {
return CGFloat(value)
}
#else
import CoreGraphics

typealias CGFloatCompatibleWithLinux = CGFloat

func createCGFloat(_ value: Double) -> CGFloat {
return CGFloat(value)
}
#endif
6 changes: 3 additions & 3 deletions Tests/MirrorDiffKitTests/Issue30Tests.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import XCTest
import CoreGraphics
@testable import MirrorDiffKit


Expand All @@ -12,8 +11,9 @@ class Issue30Tests: XCTestCase {


func testCGFloat() {
let a = CGFloat(0.0)
let b = CGFloat(1.0)
// NOTE: Use a fake CGFloat on Linux.
let a = createCGFloat(0.0)
let b = createCGFloat(1.0)

let expected = [
"",
Expand Down
6 changes: 3 additions & 3 deletions Tests/MirrorDiffKitTests/TransformerTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import XCTest
import Foundation
import CoreGraphics
@testable import MirrorDiffKit


Expand Down Expand Up @@ -79,8 +78,9 @@ class TransformerTests: XCTestCase {
expected: true
),
#line: TestCase(
input: 3.14 as CGFloat,
target: .number(type: CGFloat.self, value: "3.14"),
// NOTE: Use fake CGFloat on Linux.
input: createCGFloat(3.14),
target: .number(type: CGFloatCompatibleWithLinux.self, value: "3.14"),
expected: true
),

Expand Down
3 changes: 0 additions & 3 deletions circle.yml

This file was deleted.

0 comments on commit 9d85851

Please sign in to comment.