Exemplo n.º 1
0
def test_build_without_channel_fails(testing_workdir):
    # remove the conda forge channel from the arguments and make sure that we fail.  If we don't,
    #    we probably have channels in condarc, and this is not a good test.
    args = ['--no-anaconda-upload', '--no-activate',
            os.path.join(metadata_dir, "_recipe_requiring_external_channel")]
    with pytest.raises(DependencyNeedsBuildingError):
        main_build.execute(args)
Exemplo n.º 2
0
def test_build_add_channel():
    """This recipe requires the blinker package, which is only on conda-forge.
    This verifies that the -c argument works."""

    args = ['--no-anaconda-upload', '-c', 'conda_build_test', '--no-activate', '--no-anaconda-upload',
            os.path.join(metadata_dir, "_recipe_requiring_external_channel")]
    main_build.execute(args)
Exemplo n.º 3
0
def test_skeleton_pypi(testing_workdir, testing_config):
    args = ['pypi', 'peppercorn']
    main_skeleton.execute(args)
    assert os.path.isdir('peppercorn')

    # ensure that recipe generated is buildable
    main_build.execute(('peppercorn',))
Exemplo n.º 4
0
def test_skeleton_pypi(testing_workdir, test_config):
    args = ['pypi', 'click']
    main_skeleton.execute(args)
    assert os.path.isdir('click')

    # ensure that recipe generated is buildable
    args = ['click', '--no-anaconda-upload', '--croot', test_config.croot, '--no-activate',]
    main_build.execute(args)
Exemplo n.º 5
0
def test_build_without_channel_fails(testing_workdir):
    # remove the conda forge channel from the arguments and make sure that we fail.  If we don't,
    #    we probably have channels in condarc, and this is not a good test.
    args = [
        '--no-anaconda-upload', '--no-activate',
        os.path.join(metadata_dir, "_recipe_requiring_external_channel")
    ]
    main_build.execute(args)
Exemplo n.º 6
0
def test_skeleton_pypi(testing_workdir, testing_config):
    args = ['pypi', 'click']
    main_skeleton.execute(args)
    assert os.path.isdir('click')

    # ensure that recipe generated is buildable
    args = ['click', '--no-anaconda-upload', '--croot', testing_config.croot, '--no-activate']
    main_build.execute(args)
Exemplo n.º 7
0
def test_package_test(testing_workdir, testing_metadata):
    """Test calling conda build -t <package file> - rather than <recipe dir>"""
    api.output_yaml(testing_metadata, 'recipe/meta.yaml')
    output = api.build(testing_workdir,
                       config=testing_metadata.config,
                       notest=True)[0]
    args = ['-t', output]
    main_build.execute(args)
Exemplo n.º 8
0
def test_build_long_test_prefix_default_enabled(mocker, testing_workdir):
    recipe_path = os.path.join(metadata_dir, '_test_long_test_prefix')
    args = [recipe_path, '--no-anaconda-upload']
    main_build.execute(args)

    args.append('--no-long-test-prefix')
    with pytest.raises(SystemExit):
        main_build.execute(args)
Exemplo n.º 9
0
def test_build_long_test_prefix_default_enabled(mocker, testing_workdir, testing_metadata):
    recipe_path = os.path.join(metadata_dir, '_test_long_test_prefix')
    args = [recipe_path, '--no-anaconda-upload']
    main_build.execute(args)

    args.append('--no-long-test-prefix')
    with pytest.raises(SystemExit):
        main_build.execute(args)
Exemplo n.º 10
0
def test_skeleton_pypi(testing_workdir):
    args = ["pypi", "click"]
    main_skeleton.execute(args)
    assert os.path.isdir("click")

    # ensure that recipe generated is buildable
    args = ["click", "--no-anaconda-upload"]
    main_build.execute(args)
Exemplo n.º 11
0
def test_build_add_channel():
    """This recipe requires the conda_build_test_requirement package, which is
    only on the conda_build_test channel. This verifies that the -c argument
    works."""

    args = ['-c', 'conda_build_test', '--no-activate', '--no-anaconda-upload',
            os.path.join(metadata_dir, "_recipe_requiring_external_channel")]
    main_build.execute(args)
Exemplo n.º 12
0
def test_build_skip_existing_croot(testing_workdir, capfd):
    # build the recipe first
    empty_sections = os.path.join(metadata_dir, "empty_sections")
    args = ['--no-anaconda-upload', '--croot', testing_workdir, empty_sections]
    main_build.execute(args)
    args.insert(0, '--skip-existing')
    main_build.execute(args)
    output, error = capfd.readouterr()
    assert "are already built" in output
Exemplo n.º 13
0
def test_purge_all(testing_metadata):
    """
    purge-all clears out build folders as well as build packages in the osx-64 folders and such
    """
    outputs = api.build(testing_metadata)
    args = ['purge-all', '--croot', testing_metadata.config.croot]
    main_build.execute(args)
    assert not get_build_folders(testing_metadata.config.croot)
    assert not any(os.path.isfile(fn) for fn in outputs)
Exemplo n.º 14
0
def test_build_output_build_path(testing_workdir, test_config, capfd):
    args = ['--output', os.path.join(metadata_dir, "python_run")]
    main_build.execute(args)
    test_path = os.path.join(sys.prefix, "conda-bld", test_config.subdir,
                                  "conda-build-test-python-run-1.0-py{}{}_0.tar.bz2".format(
                                      sys.version_info.major, sys.version_info.minor))
    output, error = capfd.readouterr()
    assert error == ""
    assert output.rstrip() == test_path, error
Exemplo n.º 15
0
def test_build_skip_existing_croot(testing_workdir, capfd):
    # build the recipe first
    empty_sections = os.path.join(metadata_dir, "empty_sections")
    args = ['--no-anaconda-upload', '--croot', testing_workdir, empty_sections]
    main_build.execute(args)
    args.insert(0, '--skip-existing')
    main_build.execute(args)
    output, error = capfd.readouterr()
    assert "are already built" in output
Exemplo n.º 16
0
def test_slash_in_recipe_arg_keeps_build_id(testing_workdir, test_config):
    recipe_path = os.path.join(metadata_dir, "has_prefix_files" + os.path.sep)
    fn = api.get_output_file_path(recipe_path, config=test_config)
    args = [os.path.join(metadata_dir, "has_prefix_files"), '--croot', test_config.croot]
    main_build.execute(args)
    data = package_has_file(fn, 'binary-has-prefix')
    assert data
    if hasattr(data, 'decode'):
        data = data.decode('UTF-8')
    assert 'has_prefix_files_1' in data
Exemplo n.º 17
0
def test_activate_scripts_not_included(testing_workdir):
    recipe = os.path.join(metadata_dir, '_activate_scripts_not_included')
    args = ['--no-anaconda-upload', '--croot', testing_workdir, recipe]
    main_build.execute(args)
    out = api.get_output_file_paths(recipe, croot=testing_workdir)[0]
    for f in ('bin/activate', 'bin/deactivate', 'bin/conda',
              'Scripts/activate.bat', 'Scripts/deactivate.bat', 'Scripts/conda.bat',
              'Scripts/activate.exe', 'Scripts/deactivate.exe', 'Scripts/conda.exe',
              'Scripts/activate', 'Scripts/deactivate', 'Scripts/conda'):
        assert not package_has_file(out, f)
Exemplo n.º 18
0
def test_activate_scripts_not_included(testing_workdir):
    recipe = os.path.join(metadata_dir, '_activate_scripts_not_included')
    args = ['--no-anaconda-upload', '--croot', testing_workdir, recipe]
    main_build.execute(args)
    out = api.get_output_file_paths(recipe, croot=testing_workdir)[0]
    for f in ('bin/activate', 'bin/deactivate', 'bin/conda',
              'Scripts/activate.bat', 'Scripts/deactivate.bat', 'Scripts/conda.bat',
              'Scripts/activate.exe', 'Scripts/deactivate.exe', 'Scripts/conda.exe',
              'Scripts/activate', 'Scripts/deactivate', 'Scripts/conda'):
        assert not package_has_file(out, f)
Exemplo n.º 19
0
def test_build_output_build_path(testing_workdir, test_config, test_metadata, capfd):
    api.output_yaml(test_metadata, 'meta.yaml')
    args = ['--output', testing_workdir]
    main_build.execute(args)
    test_path = os.path.join(sys.prefix, "conda-bld", test_config.subdir,
                                  "test_build_output_build_path-1.0-py{}{}_1.tar.bz2".format(
                                      sys.version_info.major, sys.version_info.minor))
    output, error = capfd.readouterr()
    assert error == ""
    assert output.rstrip() == test_path, error
Exemplo n.º 20
0
def test_build_output_build_path(testing_workdir, test_config, capfd):
    args = ['--output', os.path.join(metadata_dir, "python_run")]
    main_build.execute(args)
    test_path = os.path.join(
        sys.prefix, "conda-bld", test_config.subdir,
        "conda-build-test-python-run-1.0-py{}{}_0.tar.bz2".format(
            sys.version_info.major, sys.version_info.minor))
    output, error = capfd.readouterr()
    assert error == ""
    assert output.rstrip() == test_path, error
Exemplo n.º 21
0
def test_purge_all(test_metadata):
    """
    purge-all clears out build folders as well as build packages in the osx-64 folders and such
    """
    api.build(test_metadata)
    fn = api.get_output_file_path(test_metadata)
    args = ['purge-all', '--croot', test_metadata.config.croot]
    main_build.execute(args)
    assert not get_build_folders(test_metadata.config.croot)
    assert not os.path.isfile(fn)
Exemplo n.º 22
0
def test_build_output_build_path(testing_workdir, testing_metadata, testing_config, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    testing_config.verbose = False
    testing_config.debug = False
    args = ['--output', os.path.join(testing_workdir)]
    main_build.execute(args)
    test_path = os.path.join(sys.prefix, "conda-bld", testing_config.host_subdir,
                                  "test_build_output_build_path-1.0-1.tar.bz2")
    output, error = capfd.readouterr()
    assert test_path == output.rstrip(), error
    assert error == ""
Exemplo n.º 23
0
def test_build_no_build_id(testing_workdir, test_config):
    args = [os.path.join(metadata_dir, "has_prefix_files"), '--no-build-id',
            '--croot', test_config.croot, '--no-activate', '--no-anaconda-upload']
    main_build.execute(args)
    fn = api.get_output_file_path(os.path.join(metadata_dir, "has_prefix_files"),
                                  config=test_config)
    data = package_has_file(fn, 'binary-has-prefix')
    assert data
    if hasattr(data, 'decode'):
        data = data.decode('UTF-8')
    assert 'has_prefix_files_1' not in data
Exemplo n.º 24
0
def test_build_output_build_path(testing_workdir, testing_metadata, testing_config, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    testing_config.verbose = False
    testing_config.debug = False
    args = ['--output', os.path.join(testing_workdir)]
    main_build.execute(args)
    test_path = os.path.join(sys.prefix, "conda-bld", testing_config.host_subdir,
                                  "test_build_output_build_path-1.0-1.tar.bz2")
    output, error = capfd.readouterr()
    assert test_path == output.rstrip(), error
    assert error == ""
Exemplo n.º 25
0
def test_build_no_build_id(testing_workdir, test_config, capfd):
    args = [os.path.join(metadata_dir, "has_prefix_files"), '--no-build-id',
            '--croot', test_config.croot]
    main_build.execute(args)
    fn = api.get_output_file_path(os.path.join(metadata_dir, "has_prefix_files"),
                                  config=test_config)
    assert package_has_file(fn, 'info/has_prefix')
    data = package_has_file(fn, 'info/has_prefix')
    if hasattr(data, 'decode'):
        data = data.decode('UTF-8')
    assert 'has_prefix_files_1' not in data
Exemplo n.º 26
0
def test_purge_all(testing_workdir, testing_metadata):
    """
    purge-all clears out build folders as well as build packages in the osx-64 folders and such
    """
    api.output_yaml(testing_metadata, 'meta.yaml')
    with TemporaryDirectory() as tmpdir:
        testing_metadata.config.croot = tmpdir
        outputs = api.build(testing_workdir, config=testing_metadata.config)
        args = ['purge-all', '--croot', tmpdir]
        main_build.execute(args)
        assert not get_build_folders(testing_metadata.config.croot)
        assert not any(os.path.isfile(fn) for fn in outputs)
Exemplo n.º 27
0
def test_no_filename_hash(testing_workdir, testing_metadata, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    args = ['--output', testing_workdir, '--old-build-string']
    main_render.execute(args)
    output, error = capfd.readouterr()
    assert not re.search('h[0-9a-f]{%d}' % testing_metadata.config.hash_length, output)

    args = ['--no-anaconda-upload', '--no-activate', testing_workdir, '--old-build-string']
    main_build.execute(args)
    output, error = capfd.readouterr()
    assert not re.search('h[0-9a-f]{%d}' % testing_metadata.config.hash_length, output)
    assert not re.search('h[0-9a-f]{%d}' % testing_metadata.config.hash_length, error)
Exemplo n.º 28
0
def test_build_output_folder(testing_workdir, test_metadata, capfd):
    api.output_yaml(test_metadata, 'meta.yaml')
    with TemporaryDirectory() as tmp:
        out = os.path.join(tmp, 'out')
        args = [
            testing_workdir, '--no-build-id', '--croot', tmp, '--no-activate',
            '--no-anaconda-upload', '--output-folder', out
        ]
        main_build.execute(args)
        test_metadata.config.output_folder = out
        output, error = capfd.readouterr()
        assert "anaconda upload {}".format(out) in output
Exemplo n.º 29
0
def test_build_output_build_path(testing_workdir, test_config, test_metadata,
                                 capfd):
    api.output_yaml(test_metadata, 'meta.yaml')
    args = ['--output', testing_workdir]
    main_build.execute(args)
    test_path = os.path.join(
        sys.prefix, "conda-bld", test_config.subdir,
        "test_build_output_build_path-1.0-py{}{}_1.tar.bz2".format(
            sys.version_info.major, sys.version_info.minor))
    output, error = capfd.readouterr()
    assert error == ""
    assert output.rstrip() == test_path, error
Exemplo n.º 30
0
def test_build_skip_existing(testing_workdir, capfd, mocker):
    # build the recipe first
    empty_sections = os.path.join(metadata_dir, "empty_sections")
    args = ['--no-anaconda-upload', empty_sections]
    main_build.execute(args)
    args.insert(0, '--skip-existing')
    import conda_build.source
    provide = mocker.patch.object(conda_build.source, 'provide')
    main_build.execute(args)
    provide.assert_not_called()
    output, error = capfd.readouterr()
    assert ("are already built" in output or "are already built" in error)
Exemplo n.º 31
0
def test_purge(testing_workdir, test_metadata):
    """
    purge clears out build folders - things like some_pkg_12048309850135

    It does not clear out build packages from folders like osx-64 or linux-64.
    """
    api.build(test_metadata)
    fn = api.get_output_file_path(test_metadata)
    args = ['purge']
    main_build.execute(args)
    assert not get_build_folders(test_metadata.config.croot)
    assert os.path.isfile(fn)
Exemplo n.º 32
0
def test_purge(testing_workdir, test_metadata):
    """
    purge clears out build folders - things like some_pkg_12048309850135

    It does not clear out build packages from folders like osx-64 or linux-64.
    """
    api.build(test_metadata)
    fn = api.get_output_file_path(test_metadata)
    args = ['purge']
    main_build.execute(args)
    assert not get_build_folders(test_metadata.config.croot)
    assert os.path.isfile(fn)
Exemplo n.º 33
0
def test_build_skip_existing(testing_workdir, capfd, mocker):
    # build the recipe first
    empty_sections = os.path.join(metadata_dir, "empty_sections")
    args = ['--no-anaconda-upload', empty_sections]
    main_build.execute(args)
    args.insert(0, '--skip-existing')
    import conda_build.source
    provide = mocker.patch.object(conda_build.source, 'provide')
    main_build.execute(args)
    provide.assert_not_called()
    output, error = capfd.readouterr()
    assert ("are already built" in output or "are already built" in error)
Exemplo n.º 34
0
def test_no_filename_hash(testing_workdir, testing_metadata, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    args = ['--output', testing_workdir, '--old-build-string']
    main_render.execute(args)
    output, error = capfd.readouterr()
    assert not re.search('h[0-9a-f]{%d}' % testing_metadata.config.hash_length, output)

    args = ['--no-anaconda-upload', '--no-activate', testing_workdir, '--old-build-string']
    main_build.execute(args)
    output, error = capfd.readouterr()
    assert not re.search('test_no_filename_hash.*h[0-9a-f]{%d}' % testing_metadata.config.hash_length, output)
    assert not re.search('test_no_filename_hash.*h[0-9a-f]{%d}' % testing_metadata.config.hash_length, error)
Exemplo n.º 35
0
def test_purge_all(testing_workdir, testing_metadata):
    """
    purge-all clears out build folders as well as build packages in the osx-64 folders and such
    """
    api.output_yaml(testing_metadata, 'meta.yaml')
    with TemporaryDirectory() as tmpdir:
        testing_metadata.config.croot = tmpdir
        outputs = api.build(testing_workdir, config=testing_metadata.config)
        args = ['purge-all', '--croot', tmpdir]
        main_build.execute(args)
        assert not get_build_folders(testing_metadata.config.croot)
        assert not any(os.path.isfile(fn) for fn in outputs)
Exemplo n.º 36
0
def test_slash_in_recipe_arg_keeps_build_id(testing_workdir, test_config):
    recipe_path = os.path.join(metadata_dir, "has_prefix_files" + os.path.sep)
    fn = api.get_output_file_path(recipe_path, config=test_config)
    args = [
        os.path.join(metadata_dir, "has_prefix_files"), '--croot',
        test_config.croot
    ]
    main_build.execute(args)
    data = package_has_file(fn, 'binary-has-prefix')
    assert data
    if hasattr(data, 'decode'):
        data = data.decode('UTF-8')
    assert 'has_prefix_files_1' in data
Exemplo n.º 37
0
def test_build_source(testing_workdir):
    with TemporaryDirectory() as tmp:
        args = [
            os.path.join(metadata_dir, '_pyyaml_find_header'),
            '--source',
            '--no-build-id',
            '--croot',
            tmp,
            '--no-activate',
            '--no-anaconda-upload',
        ]
        main_build.execute(args)
        assert os.path.isfile(os.path.join(tmp, 'work', 'setup.py'))
Exemplo n.º 38
0
def test_build_multiple_recipes(testing_metadata, testing_workdir, testing_config):
    """Test that building two recipes in one CLI call separates the build environment for each"""
    os.makedirs('recipe1')
    os.makedirs('recipe2')
    api.output_yaml(testing_metadata, 'recipe1/meta.yaml')
    with open('recipe1/run_test.py', 'w') as f:
        f.write("import os; assert 'test_build_multiple_recipes' in os.getenv('PREFIX')")
    testing_metadata.meta['package']['name'] = 'package2'
    api.output_yaml(testing_metadata, 'recipe2/meta.yaml')
    with open('recipe2/run_test.py', 'w') as f:
        f.write("import os; assert 'package2' in os.getenv('PREFIX')")
    args = ['--no-anaconda-upload', 'recipe1', 'recipe2']
    main_build.execute(args)
Exemplo n.º 39
0
def test_build_multiple_recipes(testing_metadata, testing_workdir, testing_config):
    """Test that building two recipes in one CLI call separates the build environment for each"""
    os.makedirs('recipe1')
    os.makedirs('recipe2')
    api.output_yaml(testing_metadata, 'recipe1/meta.yaml')
    with open('recipe1/run_test.py', 'w') as f:
        f.write("import os; assert 'test_build_multiple_recipes' in os.getenv('PREFIX')")
    testing_metadata.meta['package']['name'] = 'package2'
    api.output_yaml(testing_metadata, 'recipe2/meta.yaml')
    with open('recipe2/run_test.py', 'w') as f:
        f.write("import os; assert 'package2' in os.getenv('PREFIX')")
    args = ['--no-anaconda-upload', 'recipe1', 'recipe2']
    main_build.execute(args)
Exemplo n.º 40
0
def test_purge(testing_workdir, testing_metadata):
    """
    purge clears out build folders - things like some_pkg_12048309850135

    It does not clear out build packages from folders like osx-64 or linux-64.
    """
    outputs = api.build(testing_metadata)
    args = ['purge']
    main_build.execute(args)
    dirs = get_build_folders(testing_metadata.config.croot)
    assert not dirs
    # make sure artifacts are kept - only temporary folders get nuked
    assert all(os.path.isfile(fn) for fn in outputs)
Exemplo n.º 41
0
def test_skeleton_pypi(testing_workdir, testing_config, capfd):
    args = ['pypi', 'click']
    main_skeleton.execute(args)
    assert os.path.isdir('click')

    # ensure that recipe generated is buildable
    args = ['click', '--no-anaconda-upload', '--croot', testing_config.croot, '--no-activate']
    main_build.execute(args)
    output, error = capfd.readouterr()
    if hasattr(output, 'decode'):
        output = output.decode()
    assert 'Nothing to test for' not in output
    assert 'Nothing to test for' not in error
Exemplo n.º 42
0
def test_purge_all(test_metadata):
    """
    purge-all clears out build folders as well as build packages in the osx-64 folders and such
    """
    # override config to be default, so that output path lines up with default
    #    config used by main_build
    test_metadata.config = api.Config()
    api.build(test_metadata)
    fn = api.get_output_file_path(test_metadata)
    args = ['purge-all']
    main_build.execute(args)
    assert not get_build_folders(test_metadata.config.croot)
    assert not os.path.isfile(fn)
Exemplo n.º 43
0
def test_purge_all(test_metadata):
    """
    purge-all clears out build folders as well as build packages in the osx-64 folders and such
    """
    # override config to be default, so that output path lines up with default
    #    config used by main_build
    test_metadata.config = api.Config()
    api.build(test_metadata)
    fn = api.get_output_file_path(test_metadata)
    args = ["purge-all"]
    main_build.execute(args)
    assert not get_build_folders(test_metadata.config.croot)
    assert not os.path.isfile(fn)
Exemplo n.º 44
0
def test_build_output_build_path(testing_workdir, testing_metadata, testing_config, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    testing_config.verbose = False
    testing_config.debug = False
    metadata = api.render(testing_workdir, config=testing_config)[0][0]
    args = ['--output', os.path.join(testing_workdir)]
    main_build.execute(args)
    _hash = metadata._hash_dependencies()
    test_path = os.path.join(sys.prefix, "conda-bld", testing_config.host_subdir,
                                  "test_build_output_build_path-1.0-py{}{}{}_1.tar.bz2".format(
                                      sys.version_info.major, sys.version_info.minor, _hash))
    output, error = capfd.readouterr()
    # assert error == ""
    assert output.rstrip() == test_path, error
Exemplo n.º 45
0
def test_build_no_build_id(testing_workdir, test_config, capfd):
    args = [
        os.path.join(metadata_dir, "has_prefix_files"), '--no-build-id',
        '--croot', test_config.croot
    ]
    main_build.execute(args)
    fn = api.get_output_file_path(os.path.join(metadata_dir,
                                               "has_prefix_files"),
                                  config=test_config)
    assert package_has_file(fn, 'info/has_prefix')
    data = package_has_file(fn, 'info/has_prefix')
    if hasattr(data, 'decode'):
        data = data.decode('UTF-8')
    assert 'has_prefix_files_1' not in data
Exemplo n.º 46
0
def test_purge(testing_workdir, testing_metadata):
    """
    purge clears out build folders - things like some_pkg_12048309850135

    It does not clear out build packages from folders like osx-64 or linux-64.
    """
    api.output_yaml(testing_metadata, 'meta.yaml')
    outputs = api.build(testing_workdir)
    args = ['purge']
    main_build.execute(args)
    dirs = get_build_folders(testing_metadata.config.croot)
    assert not dirs
    # make sure artifacts are kept - only temporary folders get nuked
    assert all(os.path.isfile(fn) for fn in outputs)
Exemplo n.º 47
0
def test_build_no_build_id(testing_workdir, test_config):
    args = [
        os.path.join(metadata_dir, "has_prefix_files"), '--no-build-id',
        '--croot', test_config.croot, '--no-activate', '--no-anaconda-upload'
    ]
    main_build.execute(args)
    fn = api.get_output_file_path(os.path.join(metadata_dir,
                                               "has_prefix_files"),
                                  config=test_config)
    data = package_has_file(fn, 'binary-has-prefix')
    assert data
    if hasattr(data, 'decode'):
        data = data.decode('UTF-8')
    assert 'has_prefix_files_1' not in data
Exemplo n.º 48
0
def test_build_output_build_path(testing_workdir, testing_metadata, testing_config, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    testing_config.verbose = False
    testing_config.debug = False
    metadata = api.render(testing_workdir, config=testing_config)[0][0]
    args = ['--output', os.path.join(testing_workdir)]
    main_build.execute(args)
    _hash = metadata._hash_dependencies()
    test_path = os.path.join(sys.prefix, "conda-bld", testing_config.host_subdir,
                                  "test_build_output_build_path-1.0-py{}{}{}_1.tar.bz2".format(
                                      sys.version_info.major, sys.version_info.minor, _hash))
    output, error = capfd.readouterr()
    # assert error == ""
    assert output.rstrip() == test_path, error
Exemplo n.º 49
0
def test_build_output_build_path_multiple_recipes(testing_workdir, testing_metadata,
                                                  testing_config, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    testing_config.verbose = False
    skip_recipe = os.path.join(metadata_dir, "build_skip")
    args = ['--output', testing_workdir, skip_recipe]

    main_build.execute(args)

    test_path = lambda pkg: os.path.join(sys.prefix, "conda-bld", testing_config.host_subdir, pkg)
    test_paths = [test_path("test_build_output_build_path_multiple_recipes-1.0-1.tar.bz2"), ]

    output, error = capfd.readouterr()
    # assert error == ""
    assert output.rstrip().splitlines() == test_paths, error
Exemplo n.º 50
0
def test_test_extra_dep(testing_metadata):
    testing_metadata.meta['test']['imports'] = ['imagesize']
    api.output_yaml(testing_metadata, 'meta.yaml')
    output = api.build(testing_metadata, notest=True, anaconda_upload=False)[0]

    # tests version constraints.  CLI would quote this - "click <6.7"
    args = [output, '-t', '--extra-deps', 'imagesize <1.0']
    # extra_deps will add it in
    main_build.execute(args)

    # missing click dep will fail tests
    with pytest.raises(SystemExit):
        args = [output, '-t']
        # extra_deps will add it in
        main_build.execute(args)
Exemplo n.º 51
0
def test_test_extra_dep(testing_metadata):
    testing_metadata.meta['test']['imports'] = ['imagesize']
    api.output_yaml(testing_metadata, 'meta.yaml')
    output = api.build(testing_metadata, notest=True, anaconda_upload=False)[0]

    # tests version constraints.  CLI would quote this - "click <6.7"
    args = [output, '-t', '--extra-deps', 'imagesize <1.0']
    # extra_deps will add it in
    main_build.execute(args)

    # missing click dep will fail tests
    with pytest.raises(SystemExit):
        args = [output, '-t']
        # extra_deps will add it in
        main_build.execute(args)
Exemplo n.º 52
0
def test_build_output_build_path_multiple_recipes(testing_workdir, testing_metadata,
                                                  testing_config, capfd):
    api.output_yaml(testing_metadata, 'meta.yaml')
    testing_config.verbose = False
    skip_recipe = os.path.join(metadata_dir, "build_skip")
    args = ['--output', testing_workdir, skip_recipe]

    main_build.execute(args)

    test_path = lambda pkg: os.path.join(sys.prefix, "conda-bld", testing_config.host_subdir, pkg)
    test_paths = [test_path("test_build_output_build_path_multiple_recipes-1.0-1.tar.bz2"), ]

    output, error = capfd.readouterr()
    # assert error == ""
    assert output.rstrip().splitlines() == test_paths, error
Exemplo n.º 53
0
def test_build_output_build_path_multiple_recipes(testing_workdir, test_config, capfd):
    skip_recipe = os.path.join(metadata_dir, "build_skip")
    args = ['--output', os.path.join(metadata_dir, "python_run"), skip_recipe]

    main_build.execute(args)

    test_path = lambda pkg: os.path.join(sys.prefix, "conda-bld", test_config.subdir, pkg)
    test_paths = [test_path(
        "conda-build-test-python-run-1.0-py{}{}_0.tar.bz2".format(
        sys.version_info.major, sys.version_info.minor)),
        "Skipped: {} defines build/skip for this "
        "configuration.".format(os.path.abspath(skip_recipe))]

    output, error = capfd.readouterr()
    assert error == ""
    assert output.rstrip().splitlines() == test_paths, error
Exemplo n.º 54
0
def test_relative_path_test_recipe():
    # this test builds a package into (cwd)/relative/path and then calls:
    # conda-build --test --croot ./relative/path/ /abs/path/to/recipe

    empty_sections = os.path.join(metadata_dir, "empty_with_build_script")
    croot_rel = os.path.join('.', 'relative', 'path')
    croot_abs = os.path.abspath(os.path.normpath(croot_rel))

    # build the package
    args = ['--no-anaconda-upload', '--no-test', '--croot', croot_abs, empty_sections]
    output_file_abs = main_build.execute(args)
    assert(len(output_file_abs) == 1)

    # run the test stage with relative croot
    args = ['--no-anaconda-upload', '--test', '--croot', croot_rel, empty_sections]
    main_build.execute(args)
Exemplo n.º 55
0
def test_skeleton_pypi(testing_workdir, testing_config, capfd):
    args = ['pypi', 'click']
    main_skeleton.execute(args)
    assert os.path.isdir('click')

    # ensure that recipe generated is buildable
    args = [
        'click', '--no-anaconda-upload', '--croot', testing_config.croot,
        '--no-activate'
    ]
    main_build.execute(args)
    output, error = capfd.readouterr()
    if hasattr(output, 'decode'):
        output = output.decode()
    assert 'Nothing to test for' not in output
    assert 'Nothing to test for' not in error
Exemplo n.º 56
0
def test_relative_path_test_recipe():
    # this test builds a package into (cwd)/relative/path and then calls:
    # conda-build --test --croot ./relative/path/ /abs/path/to/recipe

    empty_sections = os.path.join(metadata_dir, "empty_with_build_script")
    croot_rel = os.path.join('.', 'relative', 'path')
    croot_abs = os.path.abspath(os.path.normpath(croot_rel))

    # build the package
    args = ['--no-anaconda-upload', '--no-test', '--croot', croot_abs, empty_sections]
    output_file_abs = main_build.execute(args)
    assert(len(output_file_abs) == 1)

    # run the test stage with relative croot
    args = ['--no-anaconda-upload', '--test', '--croot', croot_rel, empty_sections]
    main_build.execute(args)
Exemplo n.º 57
0
def test_slash_in_recipe_arg_keeps_build_id(testing_workdir, testing_config):
    args = [os.path.join(metadata_dir, "has_prefix_files"), '--croot', testing_config.croot,
            '--no-anaconda-upload']
    outputs = main_build.execute(args)
    data = package_has_file(outputs[0], 'binary-has-prefix')
    assert data
    if hasattr(data, 'decode'):
        data = data.decode('UTF-8')
    assert 'conda-build-test-has-prefix-files_1' in data
Exemplo n.º 58
0
def test_build_output_folder(testing_workdir, test_metadata, capfd):
    api.output_yaml(test_metadata, 'meta.yaml')
    with TemporaryDirectory() as tmp:
        out = os.path.join(tmp, 'out')
        args = [testing_workdir, '--no-build-id',
                '--croot', tmp, '--no-activate', '--no-anaconda-upload',
                '--output-folder', out]
        output = main_build.execute(args)[0]
        assert os.path.isfile(os.path.join(out, test_metadata.config.subdir, os.path.basename(output)))
Exemplo n.º 59
0
def test_no_force_upload(mocker, testing_workdir, testing_metadata):
    with open(os.path.join(testing_workdir, '.condarc'), 'w') as f:
        f.write('anaconda_upload: True\n')
        f.write('conda_build:\n')
        f.write('    force_upload: False\n')
    del testing_metadata.meta['test']
    api.output_yaml(testing_metadata, 'meta.yaml')
    args = ['--no-force-upload', testing_workdir]
    call = mocker.patch.object(conda_build.build.subprocess, 'call')
    reset_context(testing_workdir)
    main_build.execute(args)
    pkg = api.get_output_file_path(testing_metadata)
    assert call.called_once_with(['anaconda', 'upload', pkg])
    args = [testing_workdir]
    with open(os.path.join(testing_workdir, '.condarc'), 'w') as f:
        f.write('anaconda_upload: True\n')
    main_build.execute(args)
    assert call.called_once_with(['anaconda', 'upload', '--force', pkg])
Exemplo n.º 60
0
def test_relative_path_test_artifact():
    # this test builds a package into (cwd)/relative/path and then calls:
    # conda-build --test ./relative/path/{platform}/{artifact}.tar.bz2

    empty_sections = os.path.join(metadata_dir, "empty_with_build_script")
    croot_rel = os.path.join('.', 'relative', 'path')
    croot_abs = os.path.abspath(os.path.normpath(croot_rel))

    # build the package
    args = ['--no-anaconda-upload', '--no-test', '--croot', croot_abs, empty_sections]
    output_file_abs = main_build.execute(args)
    assert(len(output_file_abs) == 1)

    output_file_rel = os.path.join(croot_rel, os.path.relpath(output_file_abs[0], croot_abs))

    # run the test stage with relative path
    args = ['--no-anaconda-upload', '--test', output_file_rel]
    main_build.execute(args)