Пример #1
0
def test_make(configure_with_cmake_source_dir, capfd):
    tmp_dir = _tmpdir('test_make')
    with push_dir(str(tmp_dir)):

        src_dir = tmp_dir.ensure('SRC', dir=1)
        src_dir.join('CMakeLists.txt').write(textwrap.dedent(
            """
            cmake_minimum_required(VERSION 3.5.0)
            project(foobar NONE)
            file(WRITE "${CMAKE_BINARY_DIR}/foo.txt" "# foo")
            install(FILES "${CMAKE_BINARY_DIR}/foo.txt" DESTINATION ".")
            install(CODE "message(STATUS \\"Project has been installed\\")")
            message(STATUS "CMAKE_SOURCE_DIR:${CMAKE_SOURCE_DIR}")
            message(STATUS "CMAKE_BINARY_DIR:${CMAKE_BINARY_DIR}")
            """
        ))
        src_dir.ensure(CMAKE_BUILD_DIR, dir=1)

        with push_dir(str(src_dir)
                      if not configure_with_cmake_source_dir
                      else str(tmp_dir.ensure('BUILD', dir=1))):
            cmkr = CMaker()
            config_kwargs = {}
            if configure_with_cmake_source_dir:
                config_kwargs['cmake_source_dir'] = str(src_dir)
            env = cmkr.configure(**config_kwargs)
            cmkr.make(env=env)

        messages = ["Project has been installed"]

        if configure_with_cmake_source_dir:
            messages += [
                "/SRC",
                "/BUILD/{}".format(to_unix_path(CMAKE_BUILD_DIR)),
                "/BUILD/{}/./foo.txt".format(to_unix_path(CMAKE_INSTALL_DIR))
            ]
        else:
            messages += [
                "/SRC",
                "/SRC/{}".format(to_unix_path(CMAKE_BUILD_DIR)),
                "/SRC/{}/./foo.txt".format(to_unix_path(CMAKE_INSTALL_DIR)),
            ]

        out, _ = capfd.readouterr()
        for message in messages:
            assert message in out
def test_make(configure_with_cmake_source_dir, capfd):
    tmp_dir = _tmpdir('test_make')
    with push_dir(str(tmp_dir)):

        src_dir = tmp_dir.ensure('SRC', dir=1)
        src_dir.join('CMakeLists.txt').write(textwrap.dedent(
            """
            cmake_minimum_required(VERSION 3.5.0)
            project(foobar NONE)
            file(WRITE "${CMAKE_BINARY_DIR}/foo.txt" "# foo")
            install(FILES "${CMAKE_BINARY_DIR}/foo.txt" DESTINATION ".")
            install(CODE "message(STATUS \\"Project has been installed\\")")
            message(STATUS "CMAKE_SOURCE_DIR:${CMAKE_SOURCE_DIR}")
            message(STATUS "CMAKE_BINARY_DIR:${CMAKE_BINARY_DIR}")
            """
        ))
        src_dir.ensure(CMAKE_BUILD_DIR, dir=1)

        with push_dir(str(src_dir)
                      if not configure_with_cmake_source_dir
                      else str(tmp_dir.ensure('BUILD', dir=1))):
            cmkr = CMaker()
            config_kwargs = {}
            if configure_with_cmake_source_dir:
                config_kwargs['cmake_source_dir'] = str(src_dir)
            env = cmkr.configure(**config_kwargs)
            cmkr.make(env=env)

        messages = ["Project has been installed"]

        if configure_with_cmake_source_dir:
            messages += [
                "/SRC",
                "/BUILD/{}".format(to_unix_path(CMAKE_BUILD_DIR)),
                "/BUILD/{}/./foo.txt".format(to_unix_path(CMAKE_INSTALL_DIR))
            ]
        else:
            messages += [
                "/SRC",
                "/SRC/{}".format(to_unix_path(CMAKE_BUILD_DIR)),
                "/SRC/{}/./foo.txt".format(to_unix_path(CMAKE_INSTALL_DIR)),
            ]

        out, _ = capfd.readouterr()
        for message in messages:
            assert message in out
Пример #3
0
def test_to_unix_path(input_path, expected_path):
    assert to_unix_path(input_path) == expected_path
Пример #4
0
def check_sdist(proj, base=''):
    sdists_tar = glob.glob('dist/*.tar.gz')
    sdists_zip = glob.glob('dist/*.zip')
    assert sdists_tar or sdists_zip

    expected_content = [
        to_unix_path(os.path.join(proj, 'setup.py')),
        to_unix_path(os.path.join(proj, base, 'hello/__init__.py')),
        to_unix_path(os.path.join(proj, base, 'hello/data/subdata/hello_data1_include_from_manifest.txt')),
        to_unix_path(os.path.join(proj, base, 'hello/data/subdata/hello_data2_include_from_manifest.txt')),
        to_unix_path(os.path.join(
            proj, base, 'hello/data/subdata/hello_data4_include_from_manifest_and_exclude_from_setup.txt')),
        to_unix_path(os.path.join(proj, base, 'hello/hello_include_from_manifest.txt')),
        to_unix_path(os.path.join(proj, base, 'hello2/__init__.py')),
        to_unix_path(os.path.join(proj, base, 'hello2/data2/subdata2/hello2_data1_include_from_manifest.txt')),
        to_unix_path(os.path.join(proj, base, 'hello2/data2/subdata2/hello2_data2_include_from_manifest.txt')),
        to_unix_path(os.path.join(
            proj, base, 'hello2/data2/subdata2/hello2_data4_include_from_manifest_and_exclude_from_setup.txt')),
        to_unix_path(os.path.join(proj, base, 'hello2/hello2_include_from_manifest.txt'))
    ]

    sdist_archive = 'dist/%s.zip' % proj
    if sdists_tar:
        sdist_archive = 'dist/%s.tar.gz' % proj

    check_sdist_content(sdist_archive, proj, expected_content)
Пример #5
0
def test_to_unix_path(input_path, expected_path):
    assert to_unix_path(input_path) == expected_path
Пример #6
0
def check_sdist(proj, base=''):
    sdists_tar = glob.glob('dist/*.tar.gz')
    sdists_zip = glob.glob('dist/*.zip')
    assert sdists_tar or sdists_zip

    expected_content = [
        to_unix_path(os.path.join(proj, 'setup.py')),
        to_unix_path(os.path.join(proj, base, 'hello/__init__.py')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello/data/subdata/hello_data1_include_from_manifest.txt')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello/data/subdata/hello_data2_include_from_manifest.txt')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello/data/subdata/hello_data4_include_from_manifest_and_exclude_from_setup.txt'
            )),
        to_unix_path(
            os.path.join(proj, base, 'hello/hello_include_from_manifest.txt')),
        to_unix_path(os.path.join(proj, base, 'hello2/__init__.py')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello2/data2/subdata2/hello2_data1_include_from_manifest.txt')
        ),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello2/data2/subdata2/hello2_data2_include_from_manifest.txt')
        ),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello2/data2/subdata2/hello2_data4_include_from_manifest_and_exclude_from_setup.txt'
            )),
        to_unix_path(
            os.path.join(proj, base,
                         'hello2/hello2_include_from_manifest.txt')),
        to_unix_path(os.path.join(proj, 'PKG-INFO'))
    ]

    member_list = None
    if sdists_tar:
        if base != '':
            expected_content.extend([to_unix_path(os.path.join(proj, base))])
        expected_content.extend([
            proj,
            to_unix_path(os.path.join(proj, base, 'hello')),
            to_unix_path(os.path.join(proj, base, 'hello/data')),
            to_unix_path(os.path.join(proj, base, 'hello/data/subdata')),
            to_unix_path(os.path.join(proj, base, 'hello2')),
            to_unix_path(os.path.join(proj, base, 'hello2/data2')),
            to_unix_path(os.path.join(proj, base, 'hello2/data2/subdata2'))
        ])
        member_list = tarfile.open('dist/%s.tar.gz' % proj).getnames()

    elif sdists_zip:
        member_list = ZipFile('dist/%s.zip' % proj).namelist()

    assert expected_content and member_list
    assert sorted(expected_content) == sorted(member_list)
Пример #7
0
def check_sdist(proj, base=''):
    sdists_tar = glob.glob('dist/*.tar.gz')
    sdists_zip = glob.glob('dist/*.zip')
    assert sdists_tar or sdists_zip

    expected_content = [
        to_unix_path(os.path.join(proj, 'setup.py')),
        to_unix_path(os.path.join(proj, base, 'hello/__init__.py')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello/data/subdata/hello_data1_include_from_manifest.txt')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello/data/subdata/hello_data2_include_from_manifest.txt')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello/data/subdata/hello_data4_include_from_manifest_and_exclude_from_setup.txt'
            )),
        to_unix_path(
            os.path.join(proj, base, 'hello/hello_include_from_manifest.txt')),
        to_unix_path(os.path.join(proj, base, 'hello2/__init__.py')),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello2/data2/subdata2/hello2_data1_include_from_manifest.txt')
        ),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello2/data2/subdata2/hello2_data2_include_from_manifest.txt')
        ),
        to_unix_path(
            os.path.join(
                proj, base,
                'hello2/data2/subdata2/hello2_data4_include_from_manifest_and_exclude_from_setup.txt'
            )),
        to_unix_path(
            os.path.join(proj, base,
                         'hello2/hello2_include_from_manifest.txt'))
    ]

    sdist_archive = 'dist/%s.zip' % proj
    if sdists_tar:
        sdist_archive = 'dist/%s.tar.gz' % proj

    check_sdist_content(sdist_archive, proj, expected_content)