Skip to content

Commit 200fb10

Browse files
Merge pull request #3451 from armintaenzertng/fix_rdf_tests
Edit `check_rdf_scan` so that SPDX rdf tests don't automatically pass #3448
2 parents 2c46c57 + b3511a8 commit 200fb10

File tree

9 files changed

+160
-19
lines changed

9 files changed

+160
-19
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The following organizations or individuals have contributed to ScanCode:
88
- Alex Blekhman @a-tinsmith
99
- Alexander Gschrei @agschrei
1010
- Armijn Hemmel @armijnhemel
11+
- Armin Tänzer @armintaenzertng
1112
- Arnaud Jeansen @ajeans
1213
- Arnav Mandal @arnav-mandal1234
1314
- Aryan Kenchappagol @aryanxk02

tests/formattedcode/data/spdx/license_known/expected.rdf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"ns1:checksum": {
6060
"ns1:Checksum": {
6161
"ns1:checksumValue": "2b8b815229aa8a61e483fb4ba0588b8b6c491890",
62-
"ns1:algorithm": "SHA1"
62+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
6363
}
6464
},
6565
"ns1:fileName": "./scan/apache-2.0.LICENSE",
@@ -80,14 +80,34 @@
8080
"ns1:checksum": {
8181
"ns1:Checksum": {
8282
"ns1:checksumValue": "172444e7c137eb5cd3cae530aca0879c90f7fada",
83-
"ns1:algorithm": "SHA1"
83+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
8484
}
8585
},
8686
"ns1:fileName": "./scan/cc0-1.0.LICENSE",
8787
"@rdf:about": "http://www.spdx.org/files#SPDXRef-3"
8888
}
8989
}
9090
],
91+
"ns1:relationship": [
92+
{
93+
"ns1:Relationship": {
94+
"ns1:relationshipType": {
95+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
96+
},
97+
"ns1:spdxElementId": "SPDXRef-001",
98+
"ns1:relatedSpdxElement": "SPDXRef-2"
99+
}
100+
},
101+
{
102+
"ns1:Relationship": {
103+
"ns1:relationshipType": {
104+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
105+
},
106+
"ns1:spdxElementId": "SPDXRef-001",
107+
"ns1:relatedSpdxElement": "SPDXRef-3"
108+
}
109+
}
110+
],
91111
"@rdf:about": "http://www.spdx.org/tools#SPDXRef-DOCUMENT",
92112
"ns1:specVersion": "SPDX-2.2"
93113
},

tests/formattedcode/data/spdx/license_known/expected_with_text.rdf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"ns1:checksum": {
6060
"ns1:Checksum": {
6161
"ns1:checksumValue": "2b8b815229aa8a61e483fb4ba0588b8b6c491890",
62-
"ns1:algorithm": "SHA1"
62+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
6363
}
6464
},
6565
"ns1:fileName": "./scan/apache-2.0.LICENSE",
@@ -80,14 +80,34 @@
8080
"ns1:checksum": {
8181
"ns1:Checksum": {
8282
"ns1:checksumValue": "172444e7c137eb5cd3cae530aca0879c90f7fada",
83-
"ns1:algorithm": "SHA1"
83+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
8484
}
8585
},
8686
"ns1:fileName": "./scan/cc0-1.0.LICENSE",
8787
"@rdf:about": "http://www.spdx.org/files#SPDXRef-3"
8888
}
8989
}
9090
],
91+
"ns1:relationship": [
92+
{
93+
"ns1:Relationship": {
94+
"ns1:relationshipType": {
95+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
96+
},
97+
"ns1:spdxElementId": "SPDXRef-001",
98+
"ns1:relatedSpdxElement": "SPDXRef-2"
99+
}
100+
},
101+
{
102+
"ns1:Relationship": {
103+
"ns1:relationshipType": {
104+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
105+
},
106+
"ns1:spdxElementId": "SPDXRef-001",
107+
"ns1:relatedSpdxElement": "SPDXRef-3"
108+
}
109+
}
110+
],
91111
"@rdf:about": "http://www.spdx.org/tools#SPDXRef-DOCUMENT",
92112
"ns1:specVersion": "SPDX-2.2"
93113
},

tests/formattedcode/data/spdx/license_ref/expected.rdf

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
],
4747
"ns1:checksum": {
4848
"ns1:Checksum": {
49-
"ns1:algorithm": "SHA1",
50-
"ns1:checksumValue": "f9c28fa2714ad0c2e36d3e5561afb0031fa76831"
49+
"ns1:checksumValue": "f9c28fa2714ad0c2e36d3e5561afb0031fa76831",
50+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
5151
}
5252
},
5353
"ns1:fileName": "./scan/NOTICE",
@@ -109,6 +109,15 @@
109109
"ns1:name": "scan"
110110
}
111111
},
112+
"ns1:relationship": {
113+
"ns1:Relationship": {
114+
"ns1:relationshipType": {
115+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
116+
},
117+
"ns1:spdxElementId": "SPDXRef-001",
118+
"ns1:relatedSpdxElement": "SPDXRef-2"
119+
}
120+
},
112121
"ns1:hasExtractedLicensingInfo": [
113122
{
114123
"ns1:ExtractedLicensingInfo": {

tests/formattedcode/data/spdx/license_ref/expected_with_text.rdf

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
],
4747
"ns1:checksum": {
4848
"ns1:Checksum": {
49-
"ns1:algorithm": "SHA1",
50-
"ns1:checksumValue": "f9c28fa2714ad0c2e36d3e5561afb0031fa76831"
49+
"ns1:checksumValue": "f9c28fa2714ad0c2e36d3e5561afb0031fa76831",
50+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
5151
}
5252
},
5353
"ns1:fileName": "./scan/NOTICE",
@@ -109,6 +109,15 @@
109109
"ns1:name": "scan"
110110
}
111111
},
112+
"ns1:relationship": {
113+
"ns1:Relationship": {
114+
"ns1:relationshipType": {
115+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
116+
},
117+
"ns1:spdxElementId": "SPDXRef-001",
118+
"ns1:relatedSpdxElement": "SPDXRef-2"
119+
}
120+
},
112121
"ns1:hasExtractedLicensingInfo": [
113122
{
114123
"ns1:ExtractedLicensingInfo": {

tests/formattedcode/data/spdx/or_later/expected.rdf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"ns1:checksum": {
1919
"ns1:Checksum": {
2020
"ns1:checksumValue": "0c5bf934430394112921e7a1a8128176606d32ca",
21-
"ns1:algorithm": "SHA1"
21+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
2222
}
2323
},
2424
"ns1:fileName": "./test.java",
@@ -51,6 +51,15 @@
5151
"ns1:name": "or_later"
5252
}
5353
},
54+
"ns1:relationship": {
55+
"ns1:Relationship": {
56+
"ns1:relationshipType": {
57+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
58+
},
59+
"ns1:spdxElementId": "SPDXRef-001",
60+
"ns1:relatedSpdxElement": "SPDXRef-1"
61+
}
62+
},
5463
"@rdf:about": "http://www.spdx.org/tools#SPDXRef-DOCUMENT",
5564
"ns1:specVersion": "SPDX-2.2"
5665
},

tests/formattedcode/data/spdx/tree/expected.rdf

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"ns1:checksum": {
6565
"ns1:Checksum": {
6666
"ns1:checksumValue": "3922760d8492eb8f853c10a627f5a73f9eaec6ff",
67-
"ns1:algorithm": "SHA1"
67+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
6868
}
6969
},
7070
"ns1:fileName": "./scan/copy1.c",
@@ -83,7 +83,7 @@
8383
"ns1:checksum": {
8484
"ns1:Checksum": {
8585
"ns1:checksumValue": "3922760d8492eb8f853c10a627f5a73f9eaec6ff",
86-
"ns1:algorithm": "SHA1"
86+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
8787
}
8888
},
8989
"ns1:fileName": "./scan/copy2.c",
@@ -101,8 +101,8 @@
101101
},
102102
"ns1:checksum": {
103103
"ns1:Checksum": {
104-
"ns1:algorithm": "SHA1",
105-
"ns1:checksumValue": "c91811eb5fdc7ab440355f9f8d1580e1518b0c2f"
104+
"ns1:checksumValue": "c91811eb5fdc7ab440355f9f8d1580e1518b0c2f",
105+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
106106
}
107107
},
108108
"ns1:fileName": "./scan/copy3.c",
@@ -121,7 +121,7 @@
121121
"ns1:checksum": {
122122
"ns1:Checksum": {
123123
"ns1:checksumValue": "3922760d8492eb8f853c10a627f5a73f9eaec6ff",
124-
"ns1:algorithm": "SHA1"
124+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
125125
}
126126
},
127127
"ns1:fileName": "./scan/subdir/copy1.c",
@@ -140,7 +140,7 @@
140140
"ns1:checksum": {
141141
"ns1:Checksum": {
142142
"ns1:checksumValue": "3922760d8492eb8f853c10a627f5a73f9eaec6ff",
143-
"ns1:algorithm": "SHA1"
143+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
144144
}
145145
},
146146
"ns1:fileName": "./scan/subdir/copy2.c",
@@ -159,7 +159,7 @@
159159
"ns1:checksum": {
160160
"ns1:Checksum": {
161161
"ns1:checksumValue": "389af7e629a9853056e42b262d5e30bf4579a74f",
162-
"ns1:algorithm": "SHA1"
162+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
163163
}
164164
},
165165
"ns1:fileName": "./scan/subdir/copy3.c",
@@ -178,7 +178,7 @@
178178
"ns1:checksum": {
179179
"ns1:Checksum": {
180180
"ns1:checksumValue": "58748872d25374160692f1ed7075d0fe80a544b1",
181-
"ns1:algorithm": "SHA1"
181+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
182182
}
183183
},
184184
"ns1:fileName": "./scan/subdir/copy4.c",
@@ -187,6 +187,71 @@
187187
}
188188
}
189189
],
190+
"ns1:relationship": [
191+
{
192+
"ns1:Relationship": {
193+
"ns1:relationshipType": {
194+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
195+
},
196+
"ns1:spdxElementId": "SPDXRef-001",
197+
"ns1:relatedSpdxElement": "SPDXRef-2"
198+
}
199+
},
200+
{
201+
"ns1:Relationship": {
202+
"ns1:relationshipType": {
203+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
204+
},
205+
"ns1:spdxElementId": "SPDXRef-001",
206+
"ns1:relatedSpdxElement": "SPDXRef-3"
207+
}
208+
},
209+
{
210+
"ns1:Relationship": {
211+
"ns1:relationshipType": {
212+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
213+
},
214+
"ns1:spdxElementId": "SPDXRef-001",
215+
"ns1:relatedSpdxElement": "SPDXRef-4"
216+
}
217+
},
218+
{
219+
"ns1:Relationship": {
220+
"ns1:relationshipType": {
221+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
222+
},
223+
"ns1:spdxElementId": "SPDXRef-001",
224+
"ns1:relatedSpdxElement": "SPDXRef-6"
225+
}
226+
},
227+
{
228+
"ns1:Relationship": {
229+
"ns1:relationshipType": {
230+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
231+
},
232+
"ns1:spdxElementId": "SPDXRef-001",
233+
"ns1:relatedSpdxElement": "SPDXRef-7"
234+
}
235+
},
236+
{
237+
"ns1:Relationship": {
238+
"ns1:relationshipType": {
239+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
240+
},
241+
"ns1:spdxElementId": "SPDXRef-001",
242+
"ns1:relatedSpdxElement": "SPDXRef-8"
243+
}
244+
},
245+
{
246+
"ns1:Relationship": {
247+
"ns1:relationshipType": {
248+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
249+
},
250+
"ns1:spdxElementId": "SPDXRef-001",
251+
"ns1:relatedSpdxElement": "SPDXRef-9"
252+
}
253+
}
254+
],
190255
"@rdf:about": "http://www.spdx.org/tools#SPDXRef-DOCUMENT",
191256
"ns1:specVersion": "SPDX-2.2"
192257
},

tests/formattedcode/data/spdx/unicode/expected.rdf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"ns1:checksum": {
2424
"ns1:Checksum": {
2525
"ns1:checksumValue": "3903b654c47ea95203567230d72093ad1c5c4b90",
26-
"ns1:algorithm": "SHA1"
26+
"ns1:algorithm": "http://spdx.org/rdf/terms#checksumAlgorithm_sha1"
2727
}
2828
},
2929
"ns1:licenseInfoInFile": {
@@ -69,6 +69,15 @@
6969
"ns1:name": "unicode"
7070
}
7171
},
72+
"ns1:relationship": {
73+
"ns1:Relationship": {
74+
"ns1:relationshipType": {
75+
"@rdf:resource": "http://spdx.org/rdf/terms#relationshipType_contains"
76+
},
77+
"ns1:spdxElementId": "SPDXRef-001",
78+
"ns1:relatedSpdxElement": "SPDXRef-1"
79+
}
80+
},
7281
"@rdf:about": "http://www.spdx.org/tools#SPDXRef-DOCUMENT",
7382
"ns1:specVersion": "SPDX-2.2"
7483
},

tests/formattedcode/test_output_spdx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def check_rdf_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES):
127127
else:
128128
with io.open(expected_file, encoding='utf-8') as i:
129129
expected = json.load(i)
130-
expected = load_and_clean_rdf(result_file)
131130

132131
assert json.dumps(result, indent=2) == json.dumps(expected, indent=2)
133132

0 commit comments

Comments
 (0)