Skip to content

Commit aa713f8

Browse files
authored
Merge pull request #171 from Pratikrocks/scancode_options
Add scancode options in deltacode results
2 parents e482026 + a717250 commit aa713f8

8 files changed

Lines changed: 257 additions & 4 deletions

File tree

expected.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"deltacode_notice": "Generated with DeltaCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nDeltaCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nDeltaCode is a free software codebase-comparison tool from nexB Inc. and others.\nVisit https://github.com/nexB/deltacode/ for support and download.",
3+
"new_scan_options": {
4+
"input": [
5+
"/home/arnav-mandal1234/Downloads/coala-0.10.0/coalib/"
6+
],
7+
"--fingerprint": true,
8+
"--info": true,
9+
"--json-pp": "o.json"
10+
},
11+
"old_scan_options": {
12+
"input": [
13+
"/home/arnav-mandal1234/Downloads/coala-0.10.0/coalib/"
14+
],
15+
"--fingerprint": true,
16+
"--info": true,
17+
"--json-pp": "o.json"
18+
},
19+
"deltacode_options": {
20+
"--new": "tests/data/deltacode/scancode_options_new.json",
21+
"--old": "tests/data/deltacode/scancode_options_old.json",
22+
"--all-delta-types": false
23+
},
24+
"deltacode_version": "1.0.1.dev112+gde3c583.d20210613",
25+
"deltacode_errors": [],
26+
"deltas_count": 1,
27+
"delta_stats": {
28+
"old_files_count": 1,
29+
"new_files_count": 1,
30+
"percent_added": 0.0,
31+
"percent_removed": 0.0,
32+
"percent_moved": 0.0,
33+
"percent_modified": 100.0,
34+
"percent_unmodified": 0.0
35+
},
36+
"deltas": [
37+
{
38+
"status": "modified",
39+
"factors": [],
40+
"score": 20,
41+
"new": {
42+
"path": "coalib/__init__.py",
43+
"type": "file",
44+
"name": "__init__.py",
45+
"size": 587,
46+
"sha1": "8fc64c86979if8cec0758cfe0fe92d85b219ac49",
47+
"fingerprint": "",
48+
"original_path": "coalib/__init__.py",
49+
"licenses": [],
50+
"copyrights": []
51+
},
52+
"old": {
53+
"path": "coalib/__init__.py",
54+
"type": "file",
55+
"name": "__init__.py",
56+
"size": 587,
57+
"sha1": "8fc64c86979bf8cec0758cfe0fe92d85b219ac49",
58+
"fingerprint": "",
59+
"original_path": "coalib/__init__.py",
60+
"licenses": [],
61+
"copyrights": []
62+
}
63+
}
64+
]
65+
}

src/deltacode/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def write_json(deltacode, outfile, all_delta_types=False):
4444
"""
4545
results = OrderedDict([
4646
('deltacode_notice', get_notice()),
47-
# ('new_scan_options', deltacode.new_scan_options),
48-
# ('old_scan_options', deltacode.old_scan_options),
47+
('new_scan_options', deltacode.new_scan_options),
48+
('old_scan_options', deltacode.old_scan_options),
4949
('deltacode_options', deltacode.options),
5050
('deltacode_version', __version__),
5151
('deltacode_errors', collect_errors(deltacode)),

tests/data/deltacode/coala-expected-result.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
{
22
"deltacode_notice": "Generated with DeltaCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nDeltaCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nDeltaCode is a free software codebase-comparison tool from nexB Inc. and others.\nVisit https://github.com/nexB/deltacode/ for support and download.",
3+
"new_scan_options": {
4+
"input": [
5+
"/home/arnav-mandal1234/Downloads/coala-0.10.0/coalib/"
6+
],
7+
"--fingerprint": true,
8+
"--info": true,
9+
"--json-pp": "o.json"
10+
},
11+
"old_scan_options": {
12+
"input": [
13+
"/home/arnav-mandal1234/Downloads/coala-0.7.0/coalib/"
14+
],
15+
"--fingerprint": true,
16+
"--info": true,
17+
"--json-pp": "o.json"
18+
},
319
"deltacode_options": {
420
"--new": "tests/data/deltacode/coala-0.10.0-new.json",
521
"--old": "tests/data/deltacode/coala-0.7.0-old.json",
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"deltacode_notice": "Generated with DeltaCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nDeltaCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nDeltaCode is a free software codebase-comparison tool from nexB Inc. and others.\nVisit https://github.com/nexB/deltacode/ for support and download.",
3+
"new_scan_options": {
4+
"input": [
5+
"/home/arnav-mandal1234/Downloads/coala-0.10.0/coalib/"
6+
],
7+
"--fingerprint": true,
8+
"--info": true,
9+
"--json-pp": "o.json"
10+
},
11+
"old_scan_options": {
12+
"input": [
13+
"/home/arnav-mandal1234/Downloads/coala-0.10.0/coalib/"
14+
],
15+
"--fingerprint": true,
16+
"--info": true,
17+
"--json-pp": "o.json"
18+
},
19+
"deltacode_options": {
20+
"--new": "tests/data/deltacode/scancode_options_new.json",
21+
"--old": "tests/data/deltacode/scancode_options_old.json",
22+
"--all-delta-types": false
23+
},
24+
"deltacode_version": "1.0.1.dev112+gde3c583.d20210613",
25+
"deltacode_errors": [],
26+
"deltas_count": 1,
27+
"delta_stats": {
28+
"old_files_count": 1,
29+
"new_files_count": 1,
30+
"percent_added": 0.0,
31+
"percent_removed": 0.0,
32+
"percent_moved": 0.0,
33+
"percent_modified": 100.0,
34+
"percent_unmodified": 0.0
35+
},
36+
"deltas": [
37+
{
38+
"status": "modified",
39+
"factors": [],
40+
"score": 20,
41+
"new": {
42+
"path": "coalib/__init__.py",
43+
"type": "file",
44+
"name": "__init__.py",
45+
"size": 587,
46+
"sha1": "8fc64c86979if8cec0758cfe0fe92d85b219ac49",
47+
"fingerprint": "",
48+
"original_path": "coalib/__init__.py",
49+
"licenses": [],
50+
"copyrights": []
51+
},
52+
"old": {
53+
"path": "coalib/__init__.py",
54+
"type": "file",
55+
"name": "__init__.py",
56+
"size": 587,
57+
"sha1": "8fc64c86979bf8cec0758cfe0fe92d85b219ac49",
58+
"fingerprint": "",
59+
"original_path": "coalib/__init__.py",
60+
"licenses": [],
61+
"copyrights": []
62+
}
63+
}
64+
]
65+
}
66+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"headers": [
3+
{
4+
"tool_name": "scancode-toolkit",
5+
"tool_version": "3.0.2.post1029.8efa043b4",
6+
"options": {
7+
"input": [
8+
"/home/arnav-mandal1234/Downloads/coala-0.10.0/coalib/"
9+
],
10+
"--fingerprint": true,
11+
"--info": true,
12+
"--json-pp": "o.json"
13+
},
14+
"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.",
15+
"start_timestamp": "2019-08-17T193247.327863",
16+
"end_timestamp": "2019-08-17T193249.994771",
17+
"message": null,
18+
"errors": [],
19+
"extra_data": {
20+
"files_count": 1
21+
}
22+
}
23+
],
24+
"files": [
25+
{
26+
"path": "coalib/__init__.py",
27+
"type": "file",
28+
"name": "__init__.py",
29+
"size": 587,
30+
"date": "2017-02-05",
31+
"sha1": "8fc64c86979if8cec0758cfe0fe92d85b219ac49",
32+
"files_count": 0,
33+
"dirs_count": 0,
34+
"size_count": 0,
35+
"scan_errors": []
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"headers": [
3+
{
4+
"tool_name": "scancode-toolkit",
5+
"tool_version": "3.0.2.post1029.8efa043b4",
6+
"options": {
7+
"input": [
8+
"/home/arnav-mandal1234/Downloads/coala-0.10.0/coalib/"
9+
],
10+
"--fingerprint": true,
11+
"--info": true,
12+
"--json-pp": "o.json"
13+
},
14+
"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.",
15+
"start_timestamp": "2019-08-17T193247.327863",
16+
"end_timestamp": "2019-08-17T193249.994771",
17+
"message": null,
18+
"errors": [],
19+
"extra_data": {
20+
"files_count": 1
21+
}
22+
}
23+
],
24+
"files": [
25+
{
26+
"path": "coalib/__init__.py",
27+
"type": "file",
28+
"name": "__init__.py",
29+
"size": 587,
30+
"date": "2017-02-05",
31+
"sha1": "8fc64c86979bf8cec0758cfe0fe92d85b219ac49",
32+
"files_count": 0,
33+
"dirs_count": 0,
34+
"size_count": 0,
35+
"scan_errors": []
36+
}
37+
]
38+
}

tests/data/deltacode/sugar-expected.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
{
22
"deltacode_notice": "Generated with DeltaCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nDeltaCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nDeltaCode is a free software codebase-comparison tool from nexB Inc. and others.\nVisit https://github.com/nexB/deltacode/ for support and download.",
3+
"new_scan_options": {
4+
"input": [
5+
"/home/arnav-mandal1234/Desktop/sugar-0.114/src/"
6+
],
7+
"--fingerprint": true,
8+
"--info": true,
9+
"--json-pp": "o.json"
10+
},
11+
"old_scan_options": {
12+
"input": [
13+
"/home/arnav-mandal1234/Desktop/sugar-0.108.0/src/"
14+
],
15+
"--fingerprint": true,
16+
"--info": true,
17+
"--json-pp": "o.json"
18+
},
19+
"deltacode_options": {
20+
"--new": "tests/data/deltacode/sugar-0.114-new.json",
21+
"--old": "tests/data/deltacode/sugar-0.108.0-old.json",
22+
"--all-delta-types": true
23+
},
24+
"deltacode_version": "1.0.1.dev112+gde3c583.d20210613",
325
"deltacode_errors": [],
426
"deltas_count": 136,
527
"delta_stats": {
@@ -3875,4 +3897,4 @@
38753897
}
38763898
}
38773899
]
3878-
}
3900+
}

tests/test_deltacode.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,4 +1462,12 @@ def test_non_similarity_matching_1(self):
14621462
result_file = self.get_temp_file('json')
14631463
args = ['--new', new_file, '--old', old_file, '--json-file', result_file, '--all-delta-types']
14641464
test_utils.run_scan_click(args)
1465-
test_utils.check_json_scan(self.get_test_loc('deltacode/sugar-coala-expected.json'), result_file, regen=False)
1465+
test_utils.check_json_scan(self.get_test_loc('deltacode/sugar-coala-expected.json'), result_file, regen=False)
1466+
1467+
def test_scancode_options(self):
1468+
old_file = self.get_test_loc('deltacode/scancode_options_old.json')
1469+
new_file = self.get_test_loc('deltacode/scancode_options_new.json')
1470+
result_file = self.get_temp_file('json')
1471+
args = ['--new', new_file, '--old', old_file, '--json-file', result_file, '--all-delta-types']
1472+
test_utils.run_scan_click(args)
1473+
test_utils.check_json_scan(self.get_test_loc('deltacode/scancode_options_expected.json'), result_file, regen=False)

0 commit comments

Comments
 (0)