Skip to content

Commit 5249967

Browse files
committed
refactor: test with a full --package scan
Signed-off-by: Om Santosh Suneri <[email protected]>
1 parent b09b68b commit 5249967

File tree

2 files changed

+161
-114
lines changed

2 files changed

+161
-114
lines changed
Lines changed: 155 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,158 @@
1-
[
2-
{
3-
"type": "cargo",
4-
"namespace": null,
5-
"name": "constant_time_eq",
6-
"version": "0.4.2",
7-
"qualifiers": {},
8-
"subpath": null,
9-
"primary_language": "Rust",
10-
"description": "Compares two equal-sized byte strings in constant time.",
11-
"release_date": null,
12-
"parties": [
13-
{
14-
"type": "person",
15-
"role": "author",
16-
"name": "Cesar Eduardo Barros",
17-
"email": "[email protected]",
18-
"url": null
19-
}
20-
],
21-
"keywords": [
22-
"constant_time",
23-
"cryptography",
24-
"no-std"
25-
],
26-
"homepage_url": null,
27-
"download_url": null,
28-
"size": null,
29-
"sha1": null,
30-
"md5": null,
31-
"sha256": null,
32-
"sha512": null,
33-
"bug_tracking_url": null,
34-
"code_view_url": null,
35-
"vcs_url": "https://github.com/cesarb/constant_time_eq",
36-
"copyright": null,
37-
"holder": null,
38-
"declared_license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
39-
"declared_license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
40-
"license_detections": [
41-
{
42-
"license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
43-
"license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
44-
"matches": [
45-
{
46-
"license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
47-
"license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
48-
"from_file": null,
49-
"start_line": 1,
50-
"end_line": 1,
51-
"matcher": "1-spdx-id",
52-
"score": 100.0,
53-
"matched_length": 10,
54-
"match_coverage": 100.0,
55-
"rule_relevance": 100,
56-
"rule_identifier": "spdx-license-identifier-cc0_1_0_or_mit_0_or_apache_2_0-f44a2ec174eb034bd3c662f728664281e507b20d",
57-
"rule_url": null,
58-
"matched_text": "CC0-1.0 OR MIT-0 OR Apache-2.0"
59-
}
1+
{
2+
"headers": [
3+
{
4+
"tool_name": "scancode-toolkit",
5+
"tool_version": "32.4.1",
6+
"options": {
7+
"input": [
8+
"/tests/packagedcode/data/cargo/cargo_toml/single-file-scan/Cargo.toml"
609
],
61-
"identifier": "cc0_1_0_or_mit_0_or_apache_2_0-3f14dd48-7cd8-cf28-d4e1-3b0174a587ee"
62-
}
63-
],
64-
"other_license_expression": null,
65-
"other_license_expression_spdx": null,
66-
"other_license_detections": [],
67-
"extracted_license_statement": "CC0-1.0 OR MIT-0 OR Apache-2.0",
68-
"notice_text": null,
69-
"source_packages": [],
70-
"file_references": [],
71-
"is_private": false,
72-
"is_virtual": false,
73-
"extra_data": {
74-
"documentation_url": "https://docs.rs/constant_time_eq",
75-
"rust_version": "1.85.0",
76-
"rust_edition": "2024"
77-
},
78-
"dependencies": [
79-
{
80-
"purl": "pkg:cargo/criterion",
81-
"extracted_requirement": "0.5.1",
82-
"scope": "dev-dependencies",
83-
"is_runtime": false,
84-
"is_optional": false,
85-
"is_pinned": false,
86-
"is_direct": true,
87-
"resolved_package": {},
88-
"extra_data": {
89-
"version": "0.5.1",
90-
"features": [
91-
"cargo_bench_support",
92-
"html_reports"
93-
]
94-
}
10+
"--json-pp": "/tmp/cargo-full-scan.json",
11+
"--package": true
9512
},
96-
{
97-
"purl": "pkg:cargo/count_instructions",
98-
"extracted_requirement": "0.2.0",
99-
"scope": "dev-dependencies",
100-
"is_runtime": false,
101-
"is_optional": false,
102-
"is_pinned": false,
103-
"is_direct": true,
104-
"resolved_package": {},
105-
"extra_data": {}
13+
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
14+
"start_timestamp": "2025-10-28T175155.400609",
15+
"end_timestamp": "2025-10-28T175201.660855",
16+
"output_format_version": "4.1.0",
17+
"duration": 6.26029896736145,
18+
"message": null,
19+
"errors": [],
20+
"warnings": [],
21+
"extra_data": {
22+
"system_environment": {
23+
"operating_system": "linux",
24+
"cpu_architecture": "64",
25+
"platform": "Linux-6.10.14-linuxkit-x86_64-with-glibc2.36",
26+
"platform_version": "#1 SMP Tue Oct 14 07:32:13 UTC 2025",
27+
"python_version": "3.12.12 (main, Oct 21 2025, 02:11:48) [GCC 12.2.0]"
28+
},
29+
"spdx_license_list_version": "3.27",
30+
"files_count": 1
10631
}
107-
],
108-
"repository_homepage_url": "https://crates.io/crates/constant_time_eq",
109-
"repository_download_url": "https://crates.io/api/v1/crates/constant_time_eq/0.4.2/download",
110-
"api_data_url": "https://crates.io/api/v1/crates/constant_time_eq",
111-
"datasource_id": "cargo_toml",
112-
"purl": "pkg:cargo/[email protected]"
113-
}
114-
]
32+
}
33+
],
34+
"packages": [],
35+
"dependencies": [],
36+
"files": [
37+
{
38+
"path": "Cargo.toml",
39+
"type": "file",
40+
"package_data": [
41+
{
42+
"type": "cargo",
43+
"namespace": null,
44+
"name": "constant_time_eq",
45+
"version": "0.4.2",
46+
"qualifiers": {},
47+
"subpath": null,
48+
"primary_language": "Rust",
49+
"description": "Compares two equal-sized byte strings in constant time.",
50+
"release_date": null,
51+
"parties": [
52+
{
53+
"type": "person",
54+
"role": "author",
55+
"name": "Cesar Eduardo Barros",
56+
"email": "[email protected]",
57+
"url": null
58+
}
59+
],
60+
"keywords": [
61+
"constant_time",
62+
"cryptography",
63+
"no-std"
64+
],
65+
"homepage_url": null,
66+
"download_url": null,
67+
"size": null,
68+
"sha1": null,
69+
"md5": null,
70+
"sha256": null,
71+
"sha512": null,
72+
"bug_tracking_url": null,
73+
"code_view_url": null,
74+
"vcs_url": "https://github.com/cesarb/constant_time_eq",
75+
"copyright": null,
76+
"holder": null,
77+
"declared_license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
78+
"declared_license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
79+
"license_detections": [
80+
{
81+
"license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
82+
"license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
83+
"matches": [
84+
{
85+
"license_expression": "cc0-1.0 OR mit-0 OR apache-2.0",
86+
"license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0",
87+
"from_file": "Cargo.toml",
88+
"start_line": 1,
89+
"end_line": 1,
90+
"matcher": "1-spdx-id",
91+
"score": 100.0,
92+
"matched_length": 10,
93+
"match_coverage": 100.0,
94+
"rule_relevance": 100,
95+
"rule_identifier": "spdx-license-identifier-cc0_1_0_or_mit_0_or_apache_2_0-f44a2ec174eb034bd3c662f728664281e507b20d",
96+
"rule_url": null,
97+
"matched_text": "CC0-1.0 OR MIT-0 OR Apache-2.0"
98+
}
99+
],
100+
"identifier": "cc0_1_0_or_mit_0_or_apache_2_0-3f14dd48-7cd8-cf28-d4e1-3b0174a587ee"
101+
}
102+
],
103+
"other_license_expression": null,
104+
"other_license_expression_spdx": null,
105+
"other_license_detections": [],
106+
"extracted_license_statement": "CC0-1.0 OR MIT-0 OR Apache-2.0",
107+
"notice_text": null,
108+
"source_packages": [],
109+
"file_references": [],
110+
"is_private": false,
111+
"is_virtual": false,
112+
"extra_data": {
113+
"documentation_url": "https://docs.rs/constant_time_eq",
114+
"rust_version": "1.85.0",
115+
"rust_edition": "2024"
116+
},
117+
"dependencies": [
118+
{
119+
"purl": "pkg:cargo/criterion",
120+
"extracted_requirement": "0.5.1",
121+
"scope": "dev-dependencies",
122+
"is_runtime": false,
123+
"is_optional": false,
124+
"is_pinned": false,
125+
"is_direct": true,
126+
"resolved_package": {},
127+
"extra_data": {
128+
"version": "0.5.1",
129+
"features": [
130+
"cargo_bench_support",
131+
"html_reports"
132+
]
133+
}
134+
},
135+
{
136+
"purl": "pkg:cargo/count_instructions",
137+
"extracted_requirement": "0.2.0",
138+
"scope": "dev-dependencies",
139+
"is_runtime": false,
140+
"is_optional": false,
141+
"is_pinned": false,
142+
"is_direct": true,
143+
"resolved_package": {},
144+
"extra_data": {}
145+
}
146+
],
147+
"repository_homepage_url": "https://crates.io/crates/constant_time_eq",
148+
"repository_download_url": "https://crates.io/api/v1/crates/constant_time_eq/0.4.2/download",
149+
"api_data_url": "https://crates.io/api/v1/crates/constant_time_eq",
150+
"datasource_id": "cargo_toml",
151+
"purl": "pkg:cargo/[email protected]"
152+
}
153+
],
154+
"for_packages": [],
155+
"scan_errors": []
156+
}
157+
]
158+
}

tests/packagedcode/test_cargo.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ def test_parse_cargo_toml_workspace_with_dependencies_child(self):
8585

8686
def test_parse_cargo_toml_single_file_no_crash(self):
8787
test_file = self.get_test_loc('cargo/cargo_toml/single-file-scan/Cargo.toml')
88-
expected_loc = self.get_test_loc('cargo/cargo_toml/single-file-scan/Cargo.toml.expected')
89-
packages_data = cargo.CargoTomlHandler.parse(test_file)
90-
self.check_packages_data(packages_data, expected_loc, regen=REGEN_TEST_FIXTURES)
88+
expected_file = self.get_test_loc('cargo/cargo_toml/single-file-scan/Cargo.toml.expected')
89+
result_file = self.get_temp_file('results.json')
90+
run_scan_click(['--package', test_file, '--json', result_file])
91+
check_json_scan(
92+
expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES
93+
)
9194

9295
def test_parse_cargo_toml_tauri_workspace_in_version(self):
9396
test_file = self.get_test_loc('cargo/cargo_toml/tauri-examples/Cargo.toml')

0 commit comments

Comments
 (0)