Skip to content

Commit d2b4fc7

Browse files
committed
Update tests expectations
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 021ad24 commit d2b4fc7

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

tests/packagedcode/test_rpm_installed.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,29 @@ def test_parse_rpm_xmlish_can_parse_rhel(self):
131131
def test_scan_system_package_end_to_end_installed_rpms_fedora_bdb(self):
132132
test_dir = self.extract_test_tar('rpm_installed/end-to-end/bdb-fedora-rootfs.tar.xz')
133133
test_dir = os.path.join(test_dir, 'rootfs')
134-
# To regen this test:
135-
# 1. Uncomment the following line
136-
# expected_file = self.get_test_loc('rpm_installed/end-to-end/bdb-fedora-rootfs.tar.xz-expected.json', must_exist=False)
137-
# 2. Comment the following lines
138-
expected_file = self.extract_test_tar('rpm_installed/end-to-end/bdb-fedora-rootfs.tar.xz-expected.json.tar.xz')
139-
expected_file= os.path.join(expected_file, 'bdb-fedora-rootfs.tar.xz-expected.json')
140-
# 3. Then extract `bdb-fedora-rootfs.tar.xz-expected.json.tar.xz` and stage the changes, then regen to see changes
141-
# 4. Then run `tar -cJf bdb-fedora-rootfs.tar.xz-expected.json.tar.xz bdb-fedora-rootfs.tar.xz-expected.json`
142-
# 5. Remove the extracted folder and also revert changes in this file, run test without regen to verify
134+
135+
# To regen this test expected tarball:
136+
# - regen the test with SCANCODE_REGEN_TEST_FIXTURES=yes
137+
# - in a shell Then run `tar -cJf bdb-fedora-rootfs.tar.xz-expected.json.tar.xz bdb-fedora-rootfs.tar.xz-expected.json`
138+
# - Remove the extracted json
139+
140+
# To regen this test and see changes:
141+
# - Extract `bdb-fedora-rootfs.tar.xz-expected.json.tar.xz` and stage the changes, then regen to see changes
142+
# - regen the test with SCANCODE_REGEN_TEST_FIXTURES=yes
143+
# - in a shell Then run `tar -cJf bdb-fedora-rootfs.tar.xz-expected.json.tar.xz bdb-fedora-rootfs.tar.xz-expected.json`
144+
# - Remove the extracted json
145+
146+
regen = REGEN_TEST_FIXTURES
147+
expected = 'bdb-fedora-rootfs.tar.xz-expected.json'
148+
149+
expected_file_tarball = f'rpm_installed/end-to-end/{expected}.tar.xz'
150+
if regen:
151+
# regen is special because we compress the JSON
152+
expected_file = self.get_test_loc(f'rpm_installed/end-to-end/{expected}', must_exist=False)
153+
else:
154+
expected_file = self.extract_test_tar(expected_file_tarball)
155+
expected_file = os.path.join(expected_file, expected)
156+
143157
result_file = self.get_temp_file('results.json')
144158
run_scan_click(['--system-package', test_dir, '--json-pp', result_file])
145-
check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES)
159+
check_json_scan(expected_file, result_file, regen=regen)

0 commit comments

Comments
 (0)