def test_variants(): """ Multiple variants should return multiple metadata """ r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" requirements: build: - mypkg {{ mypkg }} """, from_string=True) r.write_recipes() recipe = r.recipe_dirs['one'] # Write a temporary conda_build_config.yaml that we'll point the config # object to: tmp = tempfile.NamedTemporaryFile(delete=False).name with open(tmp, 'w') as fout: fout.write( dedent( """ mypkg: - 1.0 - 2.0 """)) config = utils.load_conda_build_config() config.exclusive_config_file = tmp assert len(utils.load_all_meta(recipe, config)) == 2
def test_load_meta_skipping(): """ Ensure that a skipped recipe returns no metadata """ r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" build: skip: true """, from_string=True) r.write_recipes() recipe = r.recipe_dirs['one'] assert utils.load_all_meta(recipe) == []
def _run(contents, expect_pass=True): """ Build the recipe and run the lint function on the rendered recipe """ r = Recipes(contents, from_string=True) r.write_recipes() assert len(r.recipe_dirs) == 1 name = list(r.recipe_dirs.keys())[0] recipe = Recipe.from_file(r.basedir, r.recipe_dirs[name]) metas = [] for platform in ["linux", "osx"]: config = utils.load_conda_build_config(platform=platform, trim_skip=False) metas.extend(utils.load_all_meta(r.recipe_dirs[name], config=config, finalize=False)) if expect_pass: assert func(recipe, metas) is None, "lint did not pass" else: assert func(recipe, metas) is not None, "lint did not fail"
def _run(contents, expect_pass=True): """ Build the recipe and run the lint function on the rendered recipe """ r = Recipes(contents, from_string=True) r.write_recipes() assert len(r.recipe_dirs) == 1 name = list(r.recipe_dirs.keys())[0] recipe = Recipe.from_file(r.basedir, r.recipe_dirs[name]) metas = [] for platform in ["linux", "osx"]: config = utils.load_conda_build_config(platform=platform, trim_skip=False) metas.extend( utils.load_all_meta(r.recipe_dirs[name], config=config, finalize=False)) if expect_pass: assert func(recipe, metas) is None, "lint did not pass" else: assert func(recipe, metas) is not None, "lint did not fail"
def test_skip_unsatisfiable_pin_compatible(config_fixture): """ Test unsatisfiable variants which are skipped get filtered out. """ r = Recipes(""" one: meta.yaml: | package: name: one version: 0.2 two: meta.yaml: | package: name: two version: 0.1 build: skip: True # [one == '0.1'] requirements: host: - one - one >=0.2 run: - {{ pin_compatible('one') }} conda_build_config.yaml: | one: - 0.1 - 0.2 """, from_string=True) r.write_recipes() build_result = build.build_recipes( r.basedir, config_fixture, [r.recipe_dirs["one"]], testonly=False, force=False, mulled_test=False, ) assert build_result assert len(utils.load_all_meta(r.recipe_dirs["two"])) == 1