示例#1
0
def test_rpm_command(ogr_distgit_and_remote):
    call_real_packit(
        parameters=["--debug", "local-build"], cwd=ogr_distgit_and_remote[0]
    )
    rpm_paths = ogr_distgit_and_remote[0].glob("noarch/*.rpm")

    assert all([rpm_path.exists() for rpm_path in rpm_paths])
示例#2
0
def test_rpm_command_for_path(ogr_distgit_and_remote):
    call_real_packit(parameters=[
        "--debug", "build", "locally",
        str(ogr_distgit_and_remote[0])
    ])
    rpm_paths = Path.cwd().glob("noarch/*.rpm")
    assert all(rpm_path.exists() for rpm_path in rpm_paths)
示例#3
0
def test_local_build_with_remote_bad(ogr_distgit_and_remote):
    with pytest.raises(CalledProcessError) as ex:
        call_real_packit(
            parameters=["--debug", "--remote", "burcak", "local-build"],
            cwd=ogr_distgit_and_remote[0],
            return_output=True,
        )
    assert b"Remote named 'burcak' didn't exist" in ex.value.output
示例#4
0
def test_srpm_command_for_path(upstream_or_distgit_path, tmp_path):
    with cwd(tmp_path):
        call_real_packit(
            parameters=["--debug", "srpm",
                        str(upstream_or_distgit_path)])
        srpm_path = list(Path.cwd().glob("*.src.rpm"))[0]
        assert srpm_path.exists()
        build_srpm(srpm_path)
示例#5
0
def test_local_build_with_remote_good(ogr_distgit_and_remote):
    call_real_packit(
        parameters=["--debug", "--remote", "origin", "local-build"],
        cwd=ogr_distgit_and_remote[0],
    )
    rpm_paths = ogr_distgit_and_remote[0].glob("noarch/*.rpm")

    assert all(rpm_path.exists() for rpm_path in rpm_paths)
示例#6
0
def test_srpm_custom_path(cwd_upstream_or_distgit):
    custom_path = "sooooorc.rpm"
    call_real_packit(
        parameters=["--debug", "srpm", "--output", custom_path],
        cwd=cwd_upstream_or_distgit,
    )
    srpm_path = cwd_upstream_or_distgit.joinpath(custom_path)
    assert srpm_path.is_file()
    build_srpm(srpm_path)
示例#7
0
def test_srpm_command_for_path_with_multiple_sources(
    upstream_and_remote_with_multiple_sources, ):
    workdir, _ = upstream_and_remote_with_multiple_sources
    with cwd(workdir):
        call_real_packit(parameters=["--debug", "srpm", str(workdir)])
        srpm_path = list(Path.cwd().glob("*.src.rpm"))[0]
        assert srpm_path.exists()
        assert (Path.cwd() / "python-ogr.spec").exists()
        build_srpm(srpm_path)
示例#8
0
def test_srpm_twice(cwd_upstream_or_distgit):
    call_real_packit(parameters=["--debug", "srpm"], cwd=cwd_upstream_or_distgit)
    call_real_packit(parameters=["--debug", "srpm"], cwd=cwd_upstream_or_distgit)

    # since we build from the 0.1.0, we would get the same SRPM because of '--new 0.1.0'
    srpm_files = list(cwd_upstream_or_distgit.glob("*.src.rpm"))

    assert srpm_files[0].exists()

    build_srpm(srpm_files[0])
示例#9
0
def test_prepare_sources_command(cwd_upstream_or_distgit):
    call_real_packit(
        parameters=["--debug", "prepare-sources"],
        cwd=cwd_upstream_or_distgit,
    )
    result_dir = cwd_upstream_or_distgit.joinpath("prepare_sources_result")
    assert result_dir.exists()

    tarball_path = list(result_dir.glob("*.tar.gz"))[0]
    assert tarball_path.exists()
    specfile_path = list(result_dir.glob("*.spec"))[0]
    assert specfile_path.exists()
示例#10
0
def test_prepare_sources_command_for_path(upstream_or_distgit_path, tmp_path):
    with cwd(tmp_path):
        call_real_packit(parameters=[
            "--debug",
            "prepare-sources",
            "--result-dir",
            Path.cwd(),
            str(upstream_or_distgit_path),
        ])

        tarball_path = list(Path.cwd().glob("*.tar.gz"))[0]
        assert tarball_path.exists()
        specfile_path = list(Path.cwd().glob("*.spec"))[0]
        assert specfile_path.exists()
示例#11
0
def test_srpm_command_no_tags(upstream_and_remote):
    upstream_cwd, _ = upstream_and_remote

    # remove the tags
    tags = subprocess.run(("git", "tag"),
                          cwd=upstream_cwd,
                          stdout=subprocess.PIPE)
    subprocess.run(["xargs", "git", "tag", "-d"],
                   cwd=upstream_cwd,
                   input=tags.stdout)

    call_real_packit(parameters=["--debug", "srpm"], cwd=upstream_cwd)
    srpm_path = list(upstream_cwd.glob("*.src.rpm"))[0]
    assert srpm_path.exists()
    build_srpm(srpm_path)
示例#12
0
def _test_srpm_symlinking(upstream_repo_path, path_prefix):
    packit_yaml_path = upstream_repo_path / ".packit.json"
    packit_yaml_dict = json.loads(packit_yaml_path.read_text())

    sources_tarball = "random_sources.tar.gz"
    desired_path = f"{path_prefix}/tmp/{sources_tarball}"
    packit_yaml_dict["actions"] = {
        "create-archive":
        [f"bash -c 'mkdir tmp; touch {desired_path}; echo {desired_path}'"]
    }
    packit_yaml_path.write_text(json.dumps(packit_yaml_dict))
    out = call_real_packit(parameters=["srpm"],
                           cwd=upstream_repo_path,
                           return_output=True)
    assert f"\n{desired_path}\n" in out.decode()

    srpm_path = list(upstream_repo_path.glob("*.src.rpm"))[0]
    assert srpm_path.exists()

    tarball = Path(upstream_repo_path / sources_tarball)
    # check if it's symlink
    assert tarball.is_symlink()
    # links to correct file
    assert (tarball.resolve() == (upstream_repo_path /
                                  f"tmp/{sources_tarball}").absolute())
示例#13
0
def test_srpm_twice_with_custom_name(cwd_upstream_or_distgit):
    custom_path = "sooooorc.rpm"
    call_real_packit(
        parameters=["--debug", "srpm", "--output", custom_path],
        cwd=cwd_upstream_or_distgit,
    )
    srpm_path1 = cwd_upstream_or_distgit.joinpath(custom_path)
    assert srpm_path1.is_file()
    build_srpm(srpm_path1)

    custom_path2 = "sooooorc2.rpm"
    call_real_packit(
        parameters=["--debug", "srpm", "--output", custom_path2],
        cwd=cwd_upstream_or_distgit,
    )
    srpm_path2 = cwd_upstream_or_distgit.joinpath(custom_path2)
    assert srpm_path2.is_file()
    build_srpm(srpm_path2)
示例#14
0
def test_action_output(upstream_and_remote):
    upstream_repo_path = upstream_and_remote[0]
    packit_yaml_path = upstream_repo_path / ".packit.json"
    packit_yaml_dict = json.loads(packit_yaml_path.read_text())
    # http://www.atlaspiv.cz/?page=detail&beer_id=4187
    the_line_we_want = "MadCat - Imperial Stout Rum Barrel Aged 20°"
    packit_yaml_dict["actions"] = {
        "post-upstream-clone": [f"bash -c 'echo {the_line_we_want}'"]
    }
    packit_yaml_path.write_text(json.dumps(packit_yaml_dict))
    out = call_real_packit(parameters=["srpm"],
                           cwd=upstream_repo_path,
                           return_output=True)
    assert f"\n{the_line_we_want}\n" in out.decode()
    srpm_path = list(upstream_repo_path.glob("*.src.rpm"))[0]
    assert srpm_path.exists()
    build_srpm(srpm_path)
示例#15
0
def test_srpm_weird_sources(upstream_and_remote_weird_sources):
    repo = upstream_and_remote_weird_sources[0]
    call_real_packit(parameters=["--debug", "srpm"], cwd=repo)
    srpm_path = list(repo.glob("*.src.rpm"))[0]
    assert srpm_path.exists()
    build_srpm(srpm_path)
示例#16
0
def test_srpm_spec_not_in_root(upstream_spec_not_in_root):
    call_real_packit(parameters=["--debug", "srpm"],
                     cwd=upstream_spec_not_in_root[0])
    srpm_path = list(upstream_spec_not_in_root[0].glob("*.src.rpm"))[0]
    assert srpm_path.exists()
    build_srpm(srpm_path)
示例#17
0
def test_srpm_command(cwd_upstream_or_distgit):
    call_real_packit(parameters=["--debug", "srpm"],
                     cwd=cwd_upstream_or_distgit)
    srpm_path = list(cwd_upstream_or_distgit.glob("*.src.rpm"))[0]
    assert srpm_path.exists()
    build_srpm(srpm_path)
示例#18
0
def test_srpm_command_for_path(upstream_or_distgit_path, tmp_path):
    with cwd(tmp_path):
        call_real_packit(parameters=[
            "--debug", "validate-config",
            str(upstream_or_distgit_path)
        ])