diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hydrilla/builder/build.py | 7 | ||||
-rw-r--r-- | src/test/test_hydrilla_builder.py | 12 |
2 files changed, 8 insertions, 11 deletions
diff --git a/src/hydrilla/builder/build.py b/src/hydrilla/builder/build.py index 3503f7a..0044614 100644 --- a/src/hydrilla/builder/build.py +++ b/src/hydrilla/builder/build.py @@ -339,14 +339,13 @@ class Build: def write_package_files(self, dstpath: Path): """Write package files under 'dstpath' for distribution.""" - file_dir_path = (dstpath / 'file').resolve() + file_dir_path = (dstpath / 'file' / 'sha256').resolve() file_dir_path.mkdir(parents=True, exist_ok=True) for file_ref in self.files_by_path.values(): if file_ref.include_in_distribution: - file_name = f'sha256-{file_ref.contents_hash}' - with open(file_dir_path / file_name, 'wb') as output: - output.write(file_ref.contents) + file_path = file_dir_path / file_ref.contents_hash + file_path.write_bytes(file_ref.contents) source_dir_path = (dstpath / 'source').resolve() source_dir_path.mkdir(parents=True, exist_ok=True) diff --git a/src/test/test_hydrilla_builder.py b/src/test/test_hydrilla_builder.py index 0b6244f..f079d34 100644 --- a/src/test/test_hydrilla_builder.py +++ b/src/test/test_hydrilla_builder.py @@ -298,14 +298,13 @@ def test_build(tmpdir, prepare_source_example): set([path.name for path in dstdir.iterdir()]) # Verify files under 'file/' - file_dir = dstdir / 'file' + file_dir = dstdir / 'file' / 'sha256' for fn in settings.dist_filenames: - dist_file_path = file_dir / f'sha256-{settings.sha256_hashes[fn]}' + dist_file_path = file_dir / settings.sha256_hashes[fn] assert dist_file_path.is_file() - with open(dist_file_path, 'rb') as file_handle: - assert file_handle.read() == settings.contents[fn] + assert dist_file_path.read_bytes() == settings.contents[fn] sha256_hashes_set = set([settings.sha256_hashes[fn] for fn in settings.dist_filenames]) @@ -313,8 +312,7 @@ def test_build(tmpdir, prepare_source_example): spdx_report_sha256 = None for path in file_dir.iterdir(): - assert path.name.startswith('sha256-') - if path.name[7:] in sha256_hashes_set: + if path.name in sha256_hashes_set: continue assert spdx_report_sha256 is None and settings.report_spdx_included @@ -323,7 +321,7 @@ def test_build(tmpdir, prepare_source_example): spdx_contents = file_handle.read() spdx_report_sha256 = sha256(spdx_contents.encode()).digest().hex() - assert spdx_report_sha256 == path.name[7:] + assert spdx_report_sha256 == path.name for fn in settings.src_filenames: if not any([n in fn.lower() for n in ('license', 'reuse')]): |