Repository navigation
Expand file tree
/
Copy pathcheck-local-swift-dependencies.bats
More file actions
executable file
·95 lines (75 loc) · 2.46 KB
/
Copy pathcheck-local-swift-dependencies.bats
File metadata and controls
executable file
·95 lines (75 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bats
load 'helpers/test_helper.bash'
@test "check-local-swift-dependencies passes when no .package(path:) is present" {
repo="$(make_temp_repo)"
copy_script_into_repo "$repo" "check-local-swift-dependencies.sh"
cat >"$repo/Package.swift" <<'SWIFT'
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "Demo",
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0")
],
targets: []
)
SWIFT
commit_all "$repo"
run bash -c "cd '$repo' && bash scripts/check-local-swift-dependencies.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"Found 0 local Swift package dependency references"* ]]
}
@test "check-local-swift-dependencies fails when .package(path:) exists" {
repo="$(make_temp_repo)"
copy_script_into_repo "$repo" "check-local-swift-dependencies.sh"
cat >"$repo/Package.swift" <<'SWIFT'
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "Demo",
dependencies: [
.package(path: "../LocalPackage")
],
targets: []
)
SWIFT
commit_all "$repo"
run bash -c "cd '$repo' && bash scripts/check-local-swift-dependencies.sh"
[ "$status" -eq 1 ]
[[ "$output" == *"contains local Swift package reference"* ]]
}
@test "check-local-swift-dependencies checks untracked Package.swift" {
repo="$(make_temp_repo)"
copy_script_into_repo "$repo" "check-local-swift-dependencies.sh"
cat >"$repo/Package.swift" <<'SWIFT'
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "Demo",
dependencies: [
.package(path: "../LocalPackage")
],
targets: []
)
SWIFT
cat >"$repo/README.md" <<'TXT'
fixture
TXT
git -C "$repo" add README.md
git -C "$repo" commit -q -m "tracked file only"
run bash -c "cd '$repo' && bash scripts/check-local-swift-dependencies.sh"
[ "$status" -eq 1 ]
[[ "$output" == *"contains local Swift package reference"* ]]
}
@test "check-local-swift-dependencies passes when no Package.swift is tracked" {
repo="$(make_temp_repo)"
copy_script_into_repo "$repo" "check-local-swift-dependencies.sh"
cat >"$repo/README.md" <<'TXT'
fixture
TXT
git -C "$repo" add README.md
git -C "$repo" commit -q -m "no package swift"
run bash -c "cd '$repo' && bash scripts/check-local-swift-dependencies.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"Found 0 local Swift package dependency references"* ]]
}