def test_rootbuilddir_copy_sources(build_dir, mock_source): root_path = build_dir / "root_builddir" root_path.mkdir() platforms = ["x86_64", "ppc64le"] root = RootBuildDir(root_path) root.platforms = platforms root._copy_sources(mock_source) dockerfile = os.path.join(mock_source.path, DOCKERFILE_FILENAME) with open(dockerfile, "r") as f: original_content = f.read() for platform in platforms: copied_dockerfile = root.path / platform / DOCKERFILE_FILENAME assert copied_dockerfile.exists() assert copied_dockerfile.read_text("utf-8") == original_content
def test_rootbuilddir_copy_sources_reflink(caplog, build_dir, mock_source, reflink_support): root_path = build_dir / "root_builddir" root_path.mkdir() platforms = ["x86_64"] root = RootBuildDir(root_path) root.platforms = platforms flexmock(reflink).should_receive('supported_at').and_return( reflink_support).once() flexmock(reflink).should_receive('reflink').and_return(True).times( int(reflink_support)) flexmock(shutil).should_receive('copy2').and_return(True).times( int(not reflink_support)) method_name = shutil.copy2.__name__ if reflink_support: method_name = 'reflink_copy' root._copy_sources(mock_source) log_msg = f"copy method used for copy sources: {method_name}" assert log_msg in caplog.text
def test_rootbuilddir_has_sources(build_dir): build_dir.joinpath("x86_64").mkdir() build_dir.joinpath("s390x").mkdir() root = RootBuildDir(build_dir) root.platforms = ["x86_64", "s390x"] assert root.has_sources
def test_rootbuilddir_has_sources_no_builddir_created(build_dir): root = RootBuildDir(build_dir) root.platforms = ["x86_64"] assert not root.has_sources