Skip to content

Commit 874bd0f

Browse files
authored
Merge pull request #148 from swiftlang/jgrynspan/basic-swift-testing-6.0.0
2 parents cda4c57 + 7c47031 commit 874bd0f

File tree

4 files changed

+75
-22
lines changed

4 files changed

+75
-22
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ Tests
2020

2121
Here is a partial list of tests in the repository:
2222

23-
| Test Name | Functionality |
24-
|--------------------------|------------------------------------------------------------------|
25-
| basic | Check output of `swift --version` |
26-
| example-package-dealer | Build the example package-dealer package |
27-
| repl | Various REPL sanity checks, notably importing Darwin and Glibc |
28-
| swift-build-self-host | Use swift build to build itself |
29-
| swift-compiler | Compile a basic swift file |
30-
| test-c-library-swiftpm | Build a package that links a 3rd party library |
31-
| test-foundation-package | Build a package that imports Foundation |
32-
| test-import-glibc | Compile a source file importing and using Glibc |
33-
| test-multi-compile | Compile multiple source files into an executable |
34-
| test-multi-compile-glibc | Compile multiple source files importing Glibc into an executable |
35-
| test-static-lib | Compile multiple source files into a static library |
36-
| test-xctest-package | Build a package that imports XCTest |
23+
| Test Name | Functionality |
24+
|----------------------------|------------------------------------------------------------------|
25+
| basic | Check output of `swift --version` |
26+
| example-package-dealer | Build the example package-dealer package |
27+
| repl | Various REPL sanity checks, notably importing Darwin and Glibc |
28+
| swift-build-self-host | Use swift build to build itself |
29+
| swift-compiler | Compile a basic swift file |
30+
| test-c-library-swiftpm | Build a package that links a 3rd party library |
31+
| test-foundation-package | Build a package that imports Foundation |
32+
| test-import-glibc | Compile a source file importing and using Glibc |
33+
| test-multi-compile | Compile multiple source files into an executable |
34+
| test-multi-compile-glibc | Compile multiple source files importing Glibc into an executable |
35+
| test-static-lib | Compile multiple source files into a static library |
36+
| test-xctest-package | Build a package that imports XCTest |
37+
| test-swift-testing-package | Build a package that imports Swift Testing |
3738

swift-package-init-lib.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
```
77
RUN: rm -rf %t.dir
88
RUN: mkdir -p %t.dir/Project
9-
RUN: %{swift-package} --package-path %t.dir/Project init --type library
9+
RUN: %{swift-package} --package-path %t.dir/Project init --type library --enable-xctest --enable-swift-testing
1010
RUN: %{swift-build} --package-path %t.dir/Project 2>&1 | tee %t.build-log
11-
RUN: %{swift-test} --package-path %t.dir/Project 2>&1 | tee %t.test-log
11+
RUN: %{swift-test} --package-path %t.dir/Project --enable-xctest --disable-swift-testing 2>&1 | tee %t.xctest-log
12+
RUN: %{swift-test} --package-path %t.dir/Project --disable-xctest --enable-swift-testing 2>&1 | tee %t.swift-testing-log
1213
```
1314

1415
## Check the build log.
@@ -21,23 +22,35 @@ RUN: %{FileCheck} --check-prefix CHECK-BUILD-LOG --input-file %t.build-log %s
2122
CHECK-BUILD-LOG: Compiling {{.*}}Project{{.*}}
2223
```
2324

24-
## Check the test log.
25+
## Check the XCTest log.
2526

2627
```
27-
RUN: %{FileCheck} --check-prefix CHECK-TEST-LOG --input-file %t.test-log %s
28+
RUN: %{FileCheck} --check-prefix CHECK-XCTEST-LOG --input-file %t.xctest-log %s
2829
```
2930

3031
```
31-
CHECK-TEST-LOG: Compiling {{.*}}ProjectTests{{.*}}
32-
CHECK-TEST-LOG: Test Suite 'All tests' passed
33-
CHECK-TEST-LOG-NEXT: Executed 1 test
32+
CHECK-XCTEST-LOG: Compiling {{.*}}ProjectTests{{.*}}
33+
CHECK-XCTEST-LOG: Test Suite 'All tests' passed
34+
CHECK-XCTEST-LOG-NEXT: Executed 1 test
35+
```
36+
37+
## Check the Swift Testing log.
38+
39+
```
40+
RUN: %{FileCheck} --check-prefix CHECK-SWIFT-TESTING-LOG --input-file %t.swift-testing-log %s
41+
```
42+
43+
```
44+
CHECK-SWIFT-TESTING-LOG: Test run started.
45+
CHECK-SWIFT-TESTING-LOG: Test run with 1 test passed after {{.*}} seconds.
3446
```
3547

3648
## Check there were no compile errors or warnings.
3749

3850
```
3951
RUN: %{FileCheck} --check-prefix CHECK-NO-WARNINGS-OR-ERRORS --input-file %t.build-log %s
40-
RUN: %{FileCheck} --check-prefix CHECK-NO-WARNINGS-OR-ERRORS --input-file %t.test-log %s
52+
RUN: %{FileCheck} --check-prefix CHECK-NO-WARNINGS-OR-ERRORS --input-file %t.xctest-log %s
53+
RUN: %{FileCheck} --check-prefix CHECK-NO-WARNINGS-OR-ERRORS --input-file %t.swift-testing-log %s
4154
```
4255

4356
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Testing
2+
3+
@Test func test_example() {
4+
print("HI")
5+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// swift-tools-version:6.0
2+
// Trivial test for importing Swift Testing.
3+
//
4+
// REQUIRES: platform=Linux
5+
//
6+
// Make a sandbox dir.
7+
// RUN: rm -rf %t.dir
8+
// RUN: mkdir -p %t.dir/tool
9+
// RUN: cp %s %t.dir/tool/Package.swift
10+
// RUN: cp %S/Tests.swift %t.dir/tool/Tests.swift
11+
// RUN: %{swift-build} --build-tests --package-path %t.dir/tool -v 2>&1 | tee %t.build-log
12+
//
13+
// Check the build log.
14+
//
15+
// RUN: %{FileCheck} --check-prefix CHECK-BUILD-LOG --input-file %t.build-log %s
16+
//
17+
// CHECK-BUILD-LOG: swiftc{{.*}} -module-name tool
18+
//
19+
// Verify that the tool exists and works.
20+
//
21+
// RUN: test -x %t.dir/tool/.build/debug/toolPackageTests.xctest
22+
// RUN: %t.dir/tool/.build/debug/toolPackageTests.xctest --testing-library swift-testing > %t.out
23+
// RUN: %{FileCheck} --check-prefix CHECK-TOOL-OUTPUT --input-file %t.out %s
24+
//
25+
// CHECK-TOOL-OUTPUT: HI
26+
27+
import PackageDescription
28+
29+
let package = Package(
30+
name: "tool",
31+
targets: [
32+
.testTarget(name: "tool", path: "./"),
33+
]
34+
)

0 commit comments

Comments
 (0)