Skip to content

Commit 090c35e

Browse files
committed
Move Bazel tests to own file #1678
Signed-off-by: Jono Yang <[email protected]>
1 parent be88844 commit 090c35e

File tree

9 files changed

+60
-22
lines changed

9 files changed

+60
-22
lines changed

tests/packagedcode/data/build/bazel-expected.json renamed to tests/packagedcode/data/bazel/end2end-expected.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
],
1818
"files": [
1919
{
20-
"path": "bazel",
20+
"path": "end2end",
2121
"type": "directory",
2222
"packages": [],
2323
"scan_errors": []
2424
},
2525
{
26-
"path": "bazel/BUILD",
26+
"path": "end2end/BUILD",
2727
"type": "file",
2828
"packages": [
2929
{
3030
"type": "bazel",
3131
"namespace": null,
32-
"name": "bazel",
32+
"name": "end2end",
3333
"version": null,
3434
"qualifiers": {},
3535
"subpath": null,
@@ -52,11 +52,11 @@
5252
"license_expression": null,
5353
"declared_license": null,
5454
"notice_text": null,
55-
"root_path": "bazel",
55+
"root_path": "end2end",
5656
"dependencies": [],
5757
"contains_source_code": null,
5858
"source_packages": [],
59-
"purl": "pkg:bazel/bazel",
59+
"purl": "pkg:bazel/end2end",
6060
"repository_homepage_url": null,
6161
"repository_download_url": null,
6262
"api_data_url": null
@@ -65,37 +65,37 @@
6565
"scan_errors": []
6666
},
6767
{
68-
"path": "bazel/subdir",
68+
"path": "end2end/subdir",
6969
"type": "directory",
7070
"packages": [],
7171
"scan_errors": []
7272
},
7373
{
74-
"path": "bazel/subdir/dir",
74+
"path": "end2end/subdir/dir",
7575
"type": "directory",
7676
"packages": [],
7777
"scan_errors": []
7878
},
7979
{
80-
"path": "bazel/subdir/dir/file1",
80+
"path": "end2end/subdir/dir/file1",
8181
"type": "file",
8282
"packages": [],
8383
"scan_errors": []
8484
},
8585
{
86-
"path": "bazel/subdir/file1",
86+
"path": "end2end/subdir/file1",
8787
"type": "file",
8888
"packages": [],
8989
"scan_errors": []
9090
},
9191
{
92-
"path": "bazel/subdir2",
92+
"path": "end2end/subdir2",
9393
"type": "directory",
9494
"packages": [],
9595
"scan_errors": []
9696
},
9797
{
98-
"path": "bazel/subdir2/BUILD",
98+
"path": "end2end/subdir2/BUILD",
9999
"type": "file",
100100
"packages": [
101101
{
@@ -124,7 +124,7 @@
124124
"license_expression": null,
125125
"declared_license": null,
126126
"notice_text": null,
127-
"root_path": "bazel/subdir2",
127+
"root_path": "end2end/subdir2",
128128
"dependencies": [],
129129
"contains_source_code": null,
130130
"source_packages": [],
@@ -137,19 +137,19 @@
137137
"scan_errors": []
138138
},
139139
{
140-
"path": "bazel/subdir2/file2",
140+
"path": "end2end/subdir2/file2",
141141
"type": "file",
142142
"packages": [],
143143
"scan_errors": []
144144
},
145145
{
146-
"path": "bazel/subdir2/subdir3",
146+
"path": "end2end/subdir2/subdir3",
147147
"type": "directory",
148148
"packages": [],
149149
"scan_errors": []
150150
},
151151
{
152-
"path": "bazel/subdir2/subdir3/file2",
152+
"path": "end2end/subdir2/subdir3/file2",
153153
"type": "file",
154154
"packages": [],
155155
"scan_errors": []
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/packagedcode/data/build/bazel/subdir2/subdir3/file2 renamed to tests/packagedcode/data/bazel/end2end/subdir2/subdir3/file2

File renamed without changes.

tests/packagedcode/test_bazel.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# Copyright (c) 2019 nexB Inc. and others. All rights reserved.
3+
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
4+
# The ScanCode software is licensed under the Apache License version 2.0.
5+
# Data generated with ScanCode require an acknowledgment.
6+
# ScanCode is a trademark of nexB Inc.
7+
#
8+
# You may not use this software except in compliance with the License.
9+
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
10+
# Unless required by applicable law or agreed to in writing, software distributed
11+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
13+
# specific language governing permissions and limitations under the License.
14+
#
15+
# When you publish or redistribute any data created with ScanCode or any ScanCode
16+
# derivative work, you must accompany this data with the following acknowledgment:
17+
#
18+
# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
19+
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
20+
# ScanCode should be considered or used as legal advice. Consult an Attorney
21+
# for any legal advice.
22+
# ScanCode is a free software code scanning tool from nexB Inc. and others.
23+
# Visit https://github.com/nexB/scancode-toolkit/ for support and download.
24+
25+
from __future__ import absolute_import
26+
from __future__ import print_function
27+
from __future__ import unicode_literals
28+
29+
import os.path
30+
31+
from packagedcode import bazel
32+
from scancode.cli_test_utils import check_json_scan
33+
from scancode.cli_test_utils import run_scan_click
34+
from packages_test_utils import PackageTester
35+
36+
37+
class TestBazel(PackageTester):
38+
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
39+
40+
def test_end2end_scan_can_detect_bazel(self):
41+
test_file = self.get_test_loc('bazel/end2end')
42+
expected_file = self.get_test_loc('bazel/end2end-expected.json')
43+
result_file = self.get_temp_file('results.json')
44+
run_scan_click(['--package', test_file, '--json-pp', result_file])
45+
check_json_scan(expected_file, result_file, regen=False)

tests/packagedcode/test_build.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
class TestBuild(PackageTester):
3939
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
4040

41-
def test_end2end_scan_can_detect_bazel(self):
42-
test_file = self.get_test_loc('build/bazel')
43-
expected_file = self.get_test_loc('build/bazel-expected.json')
44-
result_file = self.get_temp_file('results.json')
45-
run_scan_click(['--package', test_file, '--json-pp', result_file])
46-
check_json_scan(expected_file, result_file, regen=False)
47-
4841
def test_build_get_package_resources(self):
4942
test_loc = self.get_test_loc('build/get_package_resources')
5043
codebase = Codebase(test_loc)

0 commit comments

Comments
 (0)