Skip to content

Commit daebe09

Browse files
committed
Add integration test for testing SwiftPM's code coverage support
<rdar://problem/45575408> Add integration test for testing SwiftPM's code coverage support
1 parent 6cfcfc9 commit daebe09

File tree

8 files changed

+82
-0
lines changed

8 files changed

+82
-0
lines changed

test-codecov-package/foo/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// swift-tools-version:4.2
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "foo",
7+
products: [
8+
.library(
9+
name: "foo",
10+
targets: ["foo"]),
11+
],
12+
targets: [
13+
.target(
14+
name: "foo",
15+
dependencies: []),
16+
.testTarget(
17+
name: "fooTests",
18+
dependencies: ["foo"]),
19+
]
20+
)

test-codecov-package/foo/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# foo
2+
3+
A description of this package.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public struct foo {
2+
public var text = "Hello, World!"
3+
4+
public init() { }
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import XCTest
2+
3+
import fooTests
4+
5+
var tests = [XCTestCaseEntry]()
6+
tests += fooTests.allTests()
7+
XCTMain(tests)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import XCTest
2+
3+
#if !os(macOS)
4+
public func allTests() -> [XCTestCaseEntry] {
5+
return [
6+
testCase(fooTests.allTests),
7+
]
8+
}
9+
#endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import XCTest
2+
import foo
3+
4+
final class fooTests: XCTestCase {
5+
func testExample() {
6+
// This is an example of a functional test case.
7+
// Use XCTAssert and related functions to verify your tests produce the correct
8+
// results.
9+
XCTAssertEqual(foo().text, "Hello, World!")
10+
}
11+
12+
static var allTests = [
13+
("testExample", testExample),
14+
]
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Sanity check for SwiftPM's code coverage support.
2+
//
3+
// Make a sandbox dir.
4+
// RUN: rm -rf %t.dir
5+
// RUN: mkdir -p %t.dir
6+
// RUN: cp -r %S/foo %t.dir/
7+
// RUN: %{swift-test} --package-path %t.dir/foo --enable-code-coverage -v 2>&1 | tee %t.build-log
8+
//
9+
// Check the build log.
10+
//
11+
// RUN: %{FileCheck} --check-prefix CHECK-BUILD-LOG --input-file %t.build-log %s
12+
//
13+
// CHECK-BUILD-LOG: 'fooTests' passed
14+
//
15+
// Check the exported codecov file.
16+
//
17+
// RUN: %{FileCheck} --check-prefix CHECK-CODECOV-JSON --input-file %t.dir/foo/.build/debug/codecov/foo.json %s
18+
//
19+
// CHECK-CODECOV-JSON: llvm.coverage.json.export

0 commit comments

Comments
 (0)