예제 #1
0
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
예제 #2
0
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