コード例 #1
0
def test_cross_rbase_build_sh(tmpdir):
    with open(os.path.join(tmpdir, "build.sh"), "w") as f:
        f.write("#!/bin/bash\nR CMD INSTALL --build .")
    run_test_migration(
        m=version_migrator_rbase,
        inp=rbase_recipe,
        output=rbase_recipe_correct,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "2.0.1"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "2.0.1",
        },
        tmpdir=tmpdir,
    )
    expected = [
        "#!/bin/bash\n",
        "\n",
        "export DISABLE_AUTOBREW=1\n",
        "\n",
        "# shellcheck disable=SC2086\n",
        "${R} CMD INSTALL --build . ${R_ARGS}\n",
    ]
    with open(os.path.join(tmpdir, "build.sh")) as f:
        lines = f.readlines()
        assert lines == expected
コード例 #2
0
def test_cmake(tmpdir):
    with open(os.path.join(tmpdir, "build.sh"), "w") as f:
        f.write("#!/bin/bash\ncmake ..\nctest")
    run_test_migration(
        m=version_migrator_cmake,
        inp=config_recipe,
        output=config_recipe_correct_cmake,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "8.0"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "8.0",
        },
        tmpdir=tmpdir,
    )
    expected = [
        "#!/bin/bash\n",
        "cmake ${CMAKE_ARGS} ..\n",
        'if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then\n',
        "ctest\n",
        "fi\n",
    ]
    with open(os.path.join(tmpdir, "build.sh")) as f:
        lines = f.readlines()
        assert lines == expected
コード例 #3
0
def test_version_duplicate_lines_cleanup_skip(slug, clean_slug, tmpdir):
    with open(
            os.path.join(YAML_PATH,
                         "version_duplicate_lines_cleanup_skip.yaml"), ) as fp:
        in_yaml = fp.read()

    with open(
            os.path.join(
                YAML_PATH,
                "version_duplicate_lines_cleanup_skip_correct.yaml"), ) as fp:
        out_yaml = fp.read()

    run_test_migration(
        m=VERSION_DLC,
        inp=in_yaml.replace("@@SLUG@@", slug),
        output=out_yaml.replace("@@SLUG@@", clean_slug),
        kwargs={"new_version": "0.9"},
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "0.9",
        },
        tmpdir=tmpdir,
    )
コード例 #4
0
def test_make_check(tmpdir):
    with open(os.path.join(tmpdir, "build.sh"), "w") as f:
        f.write("#!/bin/bash\nmake check")
    run_test_migration(
        m=version_migrator_autoconf,
        inp=config_recipe,
        output=config_recipe_correct_make_check,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "8.0"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "8.0",
        },
        tmpdir=tmpdir,
    )
    expected = [
        "#!/bin/bash\n",
        "# Get an updated config.sub and config.guess\n",
        "cp $BUILD_PREFIX/share/gnuconfig/config.* ./support\n",
        'if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then\n',
        "make check\n",
        "fi\n",
    ]
    with open(os.path.join(tmpdir, "build.sh")) as f:
        lines = f.readlines()
        assert lines == expected
コード例 #5
0
def test_matplotlib_base(existing_yums, tmpdir):
    with open(os.path.join(YAML_PATH, "mplb.yaml")) as fp:
        in_yaml = fp.read()

    with open(os.path.join(YAML_PATH, "mplb_correct.yaml")) as fp:
        out_yaml = fp.read()

    yum_pth = os.path.join(tmpdir, "yum_requirements.txt")

    if len(existing_yums) > 0:
        with open(yum_pth, "w") as fp:
            for yum in existing_yums:
                fp.write("%s\n" % yum)

    run_test_migration(
        m=MPLB,
        inp=in_yaml,
        output=out_yaml,
        kwargs={},
        prb="I noticed that this recipe depends on `matplotlib` instead of ",
        mr_out={
            "migrator_name": "MatplotlibBase",
            "migrator_version": MPLB.migrator_version,
            "name": "matplotlib-to-matplotlib-base",
        },
        tmpdir=tmpdir,
    )

    with open(yum_pth) as fp:
        yums = fp.readlines()

    yums = {y.strip() for y in yums}
    assert "xorg-x11-server-Xorg" in yums
    for y in existing_yums:
        assert y in yums
コード例 #6
0
def test_version_extra_jinja2_keys_cleanup(tmpdir):
    with open(os.path.join(YAML_PATH, 'version_extra_jinja2_keys.yaml'),
              'r') as fp:
        in_yaml = fp.read()

    with open(
            os.path.join(YAML_PATH, 'version_extra_jinja2_keys_correct.yaml'),
            'r',
    ) as fp:
        out_yaml = fp.read()

    os.makedirs(os.path.join(tmpdir, 'recipe'), exist_ok=True)
    run_test_migration(
        m=VERSION_CF,
        inp=in_yaml,
        output=out_yaml,
        kwargs={"new_version": "0.20.0"},
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "0.20.0",
        },
        tmpdir=os.path.join(tmpdir, 'recipe'),
    )
コード例 #7
0
def test_update_deps_version_pyquil(caplog, tmpdir, update_kind, out_yml):
    caplog.set_level(
        logging.DEBUG,
        logger="conda_forge_tick.migrators.version",
    )

    new_ver = "3.1.0"

    kwargs = {
        "new_version": new_ver,
        "conda-forge.yml": {
            "bot": {
                "inspection": update_kind
            }
        },
    }

    os.makedirs(os.path.join(tmpdir, "recipe"))
    with open(os.path.join(tmpdir, "recipe", "meta.yaml"), "w") as fp:
        fp.write(in_yml_pyquil)

    run_test_migration(
        m=VERSION,
        inp=in_yml_pyquil,
        output=out_yml,
        kwargs=kwargs,
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": new_ver,
        },
        tmpdir=os.path.join(tmpdir, "recipe"),
        make_body=True,
    )
コード例 #8
0
def test_cross_rbase(tmpdir):
    run_test_migration(
        m=version_migrator_rbase,
        inp=rbase_recipe,
        output=rbase_recipe_correct,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "2.0.1"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "2.0.1",
        },
        tmpdir=tmpdir,
    )
コード例 #9
0
def test_build2host_bhskip(tmpdir):
    run_test_migration(
        m=version_migrator_b2h,
        inp=python_recipe_b2h_bhskip,
        output=python_recipe_b2h_bhskip_correct,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "1.19.1"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "1.19.1",
        },
        tmpdir=tmpdir,
    )
コード例 #10
0
def test_nocondainspect(tmpdir):
    run_test_migration(
        m=version_migrator_nci,
        inp=python_recipe_nci,
        output=python_recipe_nci_correct,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "1.19.1"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "1.19.1",
        },
        tmpdir=tmpdir,
    )
コード例 #11
0
def test_migrate_opentelemetry(tmp_dir_with_conf):
    run_test_migration(
        m=version_migrator_whl,
        inp=opentelemetry_instrumentation,
        output=opentelemetry_instrumentation_expected,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "0.23b2"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "0.23b2",
        },
        tmpdir=tmp_dir_with_conf,
    )
コード例 #12
0
def test_cross_python_no_build(tmpdir):
    run_test_migration(
        m=version_migrator_python,
        inp=python_no_build_recipe,
        output=python_no_build_recipe_correct,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "2020.6.20"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "2020.6.20",
        },
        tmpdir=tmpdir,
    )
コード例 #13
0
def test_version_license_correct_r(tmpdir):
    run_test_migration(
        m=VER_LM,
        inp=r_recipe,
        output=r_recipe_correct,
        kwargs={"new_version": "0.9.2"},
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "0.9.2",
        },
        tmpdir=tmpdir,
    )
コード例 #14
0
def test_version_cfyaml_cleanup(cases, tmpdir):
    yaml = YAML()

    with open(os.path.join(YAML_PATH, 'version_cfyaml_cleanup_simple.yaml'),
              'r') as fp:
        in_yaml = fp.read()

    with open(
            os.path.join(YAML_PATH,
                         'version_cfyaml_cleanup_simple_correct.yaml'),
            'r',
    ) as fp:
        out_yaml = fp.read()

    cf_yml = {}
    for case in cases:
        cf_yml[case] = '10'
    cf_yml['foo'] = 'bar'

    os.makedirs(os.path.join(tmpdir, 'recipe'), exist_ok=True)
    cf_yml_pth = os.path.join(tmpdir, 'conda-forge.yml')
    with open(cf_yml_pth, 'w') as fp:
        yaml.dump(cf_yml, fp)

    run_test_migration(
        m=VERSION_CF,
        inp=in_yaml,
        output=out_yaml,
        kwargs={"new_version": "0.9"},
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "0.9",
        },
        tmpdir=os.path.join(tmpdir, 'recipe'),
    )

    with open(cf_yml_pth, 'r') as fp:
        new_cf_yml = yaml.load(fp)

    assert 'min_r_ver' not in new_cf_yml
    assert 'min_py_ver' not in new_cf_yml
    assert 'max_r_ver' not in new_cf_yml
    assert 'max_py_ver' not in new_cf_yml
    assert 'compiler_stack' not in new_cf_yml
    assert cf_yml['foo'] == 'bar'
コード例 #15
0
def test_correct_config_sub(tmpdir):
    with open(os.path.join(tmpdir, "build.sh"), "w") as f:
        f.write("#!/bin/bash\n./configure")
    run_test_migration(
        m=version_migrator_autoconf,
        inp=config_recipe,
        output=config_recipe_correct,
        prb="Dependencies have been updated if changed",
        kwargs={"new_version": "8.0"},
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "8.0",
        },
        tmpdir=tmpdir,
    )
    with open(os.path.join(tmpdir, "build.sh")) as f:
        assert len(f.readlines()) == 4
コード例 #16
0
def test_update_deps_version(caplog, tmpdir, update_kind, out_yml):
    caplog.set_level(
        logging.DEBUG,
        logger="conda_forge_tick.migrators.version",
    )

    with open(
            os.path.join(os.path.dirname(__file__), "test_yaml",
                         "depfinder.json"), ) as f:
        attrs = load(f)

    in_yaml = (attrs["raw_meta_yaml"].replace("2.3.0", "2.2.0").replace(
        "2694acbc8f7", ""))
    new_ver = "2.3.0"

    kwargs = {
        "new_version": new_ver,
        "conda-forge.yml": {
            "bot": {
                "inspection": update_kind
            }
        },
    }

    os.makedirs(os.path.join(tmpdir, "recipe"))
    with open(os.path.join(tmpdir, "recipe", "meta.yaml"), "w") as fp:
        fp.write(in_yaml)

    run_test_migration(
        m=VERSION,
        inp=in_yaml,
        output=out_yml,
        kwargs=kwargs,
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": new_ver,
        },
        tmpdir=os.path.join(tmpdir, "recipe"),
        make_body=True,
    )
def test_version_mpi_pin_run_as_build_cleanup(vals, tmpdir):
    yaml = YAML()

    with open(os.path.join(YAML_PATH, "version_mprab_cleanup_simple.yaml")) as fp:
        in_yaml = fp.read()

    with open(
        os.path.join(YAML_PATH, "version_mprab_cleanup_simple_correct.yaml"),
    ) as fp:
        out_yaml = fp.read()

    os.makedirs(os.path.join(tmpdir, "recipe"), exist_ok=True)
    cbc_pth = os.path.join(tmpdir, "recipe", "conda_build_config.yaml")
    cbc = {"pin_run_as_build": vals}
    with open(cbc_pth, "w") as fp:
        yaml.dump(cbc, fp)

    run_test_migration(
        m=VERSION_CF,
        inp=in_yaml,
        output=out_yaml,
        kwargs={"new_version": "0.9"},
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "0.9",
        },
        tmpdir=os.path.join(tmpdir, "recipe"),
    )

    if len(vals) == 0 or "blah" not in cbc["pin_run_as_build"]:
        assert not os.path.exists(cbc_pth)
    else:
        with open(cbc_pth) as fp:
            new_cbc = yaml.load(fp)

        if "blah" in vals:
            assert "blah" in new_cbc["pin_run_as_build"]

        for mpi in MPIS:
            assert mpi not in new_cbc["pin_run_as_build"]
コード例 #18
0
def test_version_pipcheck_outputs(tmpdir):
    with open(os.path.join(YAML_PATH, "version_pipcheck_outputs.yaml")) as fp:
        in_yaml = fp.read()

    with open(os.path.join(YAML_PATH,
                           "version_pipcheck_outputs_correct.yaml"), ) as fp:
        out_yaml = fp.read()

    run_test_migration(
        m=VERSION_PC,
        inp=in_yaml,
        output=out_yaml,
        kwargs={"new_version": "1.1.0"},
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "1.1.0",
        },
        tmpdir=tmpdir,
    )
コード例 #19
0
ファイル: test_use_pip.py プロジェクト: Prodyte/cf-scripts
PC = PipMigrator()
VERSION_PC = Version(set(), dict(), dict(), piggy_back_migrations=[PC])

YAML_PATH = os.path.join(os.path.dirname(__file__), "test_yaml")


@pytest.mark.parametrize("case", ["simple", "selector"])
def test_version_pipcheck(case, tmpdir):
    with open(os.path.join(YAML_PATH, "version_usepip_%s.yaml" % case), "r") as fp:
        in_yaml = fp.read()

    with open(
        os.path.join(YAML_PATH, "version_usepip_%s_correct.yaml" % case), "r",
    ) as fp:
        out_yaml = fp.read()

    run_test_migration(
        m=VERSION_PC,
        inp=in_yaml,
        output=out_yaml,
        kwargs={"new_version": "0.9"},
        prb="Dependencies have been updated if changed",
        mr_out={
            "migrator_name": "Version",
            "migrator_version": Version.migrator_version,
            "version": "0.9",
        },
        tmpdir=tmpdir,
    )