Repository navigation
Expand file tree
/
Copy pathtest_swift.py
More file actions
171 lines (154 loc) · 6.16 KB
/
Copy pathtest_swift.py
File metadata and controls
171 lines (154 loc) · 6.16 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import os.path
from packagedcode import swift
from packages_test_utils import PackageTester
from scancode.cli_test_utils import check_json_scan
from scancode.cli_test_utils import run_scan_click
from scancode_config import REGEN_TEST_FIXTURES
class TestSwiftHandler(PackageTester):
test_data_dir = os.path.join(os.path.dirname(__file__), "data/swift")
def test_swift_manifest_json_dump_is_datafile(self):
test_file = self.get_test_loc(
"packages/mapboxmaps_manifest_and_resolved/Package.swift.json"
)
assert swift.SwiftManifestJsonHandler.is_datafile(test_file)
def test_swift_package_resolved_is_datafile(self):
test_file = self.get_test_loc(
"packages/mapboxmaps_manifest_and_resolved/Package.resolved"
)
assert swift.SwiftPackageResolvedHandler.is_datafile(test_file)
def test_swift_show_dependencies_deplock_is_datafile(self):
test_file = self.get_test_loc(
"packages/vercelui/swift-show-dependencies.deplock"
)
assert swift.SwiftShowDependenciesDepLockHandler.is_datafile(test_file)
def test_parse_for_mapboxmaps_manifest(self):
test_file = self.get_test_loc(
"packages/mapboxmaps_manifest_and_resolved/Package.swift.json"
)
expected_loc = self.get_test_loc("swift-maboxmaps-manifest-parse-expected.json")
packages = swift.SwiftManifestJsonHandler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)
def test_parse_for_mapboxmaps_resolved(self):
test_file = self.get_test_loc(
"packages/mapboxmaps_manifest_and_resolved/Package.resolved"
)
expected_loc = self.get_test_loc("swift-maboxmaps-resolved-parse-expected.json")
packages = swift.SwiftPackageResolvedHandler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)
def test_parse_for_show_dependencies_deplock(self):
test_file = self.get_test_loc(
"packages/vercelui/swift-show-dependencies.deplock"
)
expected_loc = self.get_test_loc(
"swift-vercelui-show-dependencies-parse-expected.json"
)
packages = swift.SwiftShowDependenciesDepLockHandler.parse(test_file)
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)
class TestSwiftEndtoEnd(PackageTester):
test_data_dir = os.path.join(os.path.dirname(__file__), "data/swift")
def test_package_scan_swift_end_to_end_full_mapboxmaps_manifest_only(self):
test_dir = self.get_test_loc("packages/mapboxmaps_manifest")
result_file = self.get_temp_file("json")
expected_file = self.get_test_loc(
"swift-mapboxmaps-manifest-package-expected.json"
)
run_scan_click(
[
"--package",
"--strip-root",
"--processes",
"-1",
test_dir,
"--json",
result_file,
]
)
check_json_scan(
expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES
)
def test_package_scan_swift_end_to_end_full_mapboxmaps_manifest_and_resolved(self):
test_dir = self.get_test_loc("packages/mapboxmaps_manifest_and_resolved")
result_file = self.get_temp_file("json")
expected_file = self.get_test_loc(
"swift-mapboxmaps-manifest-and-resolved-package-expected.json"
)
run_scan_click(
[
"--package",
"--strip-root",
"--processes",
"-1",
test_dir,
"--json",
result_file,
]
)
check_json_scan(
expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES
)
def test_package_scan_swift_end_to_end_full_mapboxmaps_resolved_only(self):
test_dir = self.get_test_loc("packages/fastlane_resolved_v1")
result_file = self.get_temp_file("json")
expected_file = self.get_test_loc(
"swift-fastlane-resolved-v1-package-expected.json"
)
run_scan_click(
[
"--package",
"--strip-root",
"--processes",
"-1",
test_dir,
"--json",
result_file,
]
)
check_json_scan(
expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES
)
def test_package_scan_swift_end_to_end_full_vercelui(self):
test_dir = self.get_test_loc("packages/vercelui")
result_file = self.get_temp_file("json")
expected_file = self.get_test_loc("swift-vercelui-expected.json")
run_scan_click(
[
"--package",
"--strip-root",
"--processes",
"-1",
test_dir,
"--json",
result_file,
]
)
check_json_scan(
expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES
)
def test_package_scan_swift_end_to_end_full_vercelui_show_dependencies_only(self):
test_dir = self.get_test_loc("packages/vercelui_show_dependencies")
result_file = self.get_temp_file("json")
expected_file = self.get_test_loc(
"swift-vercelui-show-dependencies-expected.json"
)
run_scan_click(
[
"--package",
"--strip-root",
"--processes",
"-1",
test_dir,
"--json",
result_file,
]
)
check_json_scan(
expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES
)