Skip to content

Commit 3ed88f7

Browse files
committed
Update tests for new swiftpm templates
- Update exec and run tests to expect sources in `./Sources` instead of `./Sources/$TARGET` - Add -tool variant of init tests rdar://105701394
1 parent 69db165 commit 3ed88f7

3 files changed

+49
-4
lines changed

swift-package-init-exec.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
RUN: rm -rf %t.dir
77
RUN: mkdir -p %t.dir/Project
88
RUN: %{swift-package} --package-path %t.dir/Project init --type executable
9-
RUN: rm -rf %t.dir/Project/Sources/Project/*
10-
RUN: echo "print(\"Hello, World!\")" >%t.dir/Project/Sources/Project/main.swift
9+
RUN: rm -rf %t.dir/Project/Sources/*
10+
RUN: echo "print(\"Hello, World!\")" >%t.dir/Project/Sources/main.swift
1111
RUN: %{swift-build} --package-path %t.dir/Project 2>&1 | tee %t.build-log
1212
```
1313

swift-package-init-tool.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Test `swift package init` (tool)
2+
3+
## Create a new package with a tool target.
4+
5+
```
6+
RUN: rm -rf %t.dir
7+
RUN: mkdir -p %t.dir/Project
8+
RUN: %{swift-package} --package-path %t.dir/Project init --type tool
9+
RUN: rm -rf %t.dir/Project/Sources/*
10+
RUN: %{swift-build} --package-path %t.dir/Project 2>&1 | tee %t.build-log
11+
```
12+
13+
## Check the build log.
14+
15+
```
16+
RUN: %{FileCheck} --check-prefix CHECK-BUILD-LOG --input-file %t.build-log %s
17+
```
18+
19+
```
20+
CHECK-BUILD-LOG: Compiling {{.*}}Project{{.*}}
21+
CHECK-BUILD-LOG: Linking {{.*}}Project
22+
```
23+
24+
## Verify that the tool was built and works.
25+
26+
```
27+
RUN: test -x %t.dir/Project/.build/debug/Project
28+
RUN: %t.dir/Project/.build/debug/Project > %t.out
29+
RUN: %{FileCheck} --check-prefix CHECK-TOOL-OUTPUT --input-file %t.out %s
30+
```
31+
32+
```
33+
CHECK-TOOL-OUTPUT: Hello, World!
34+
```
35+
36+
## Check there were no compile errors or warnings.
37+
38+
```
39+
RUN: %{FileCheck} --check-prefix CHECK-NO-WARNINGS-OR-ERRORS --input-file %t.build-log %s
40+
```
41+
42+
```
43+
CHECK-NO-WARNINGS-OR-ERRORS-NOT: warning
44+
CHECK-NO-WARNINGS-OR-ERRORS-NOT: error
45+
```

swift-run.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
RUN: rm -rf %t.dir
77
RUN: mkdir -p %t.dir/secho
88
RUN: %{swift-package} --package-path %t.dir/secho init --type executable
9-
RUN: rm -rf %t.dir/secho/Sources/secho/*
10-
RUN: echo "import Foundation; print(CommandLine.arguments.dropFirst().joined(separator: \" \"))" >%t.dir/secho/Sources/secho/main.swift
9+
RUN: rm -rf %t.dir/secho/Sources/*
10+
RUN: echo "import Foundation; print(CommandLine.arguments.dropFirst().joined(separator: \" \"))" >%t.dir/secho/Sources/main.swift
1111
RUN: %{swift-run} --package-path %t.dir/secho secho 1 "two" 2>&1 | tee %t.run-log
1212
```
1313

0 commit comments

Comments
 (0)