コード例 #1
0
def test_package_keep_rules():
    if not have_dpkg():
        pytest.skip("unsupported configuration")
    rc = ScopedFile('cmake/.mirbuildrc', RC_PKG)
    scon = ScopedFile('debian/control', CONTROL, BPY.path)
    sins = ScopedFile('debian/libtest-dev.install', INSTALL_etc, BPY.path)
    sgit = ScopedFile('.git/foo', 'nothing', BPY.path)
    debdir = posixpath.split(BPY.path)[0]
    tw = TreeWatcher(debdir)
    bpy = BPY(BPY_pkg, 'package', '--debian-pkg-keep-rules')
    assert bpy.exitcode == 0
    (ed, ef, md, mf) = tw.diff(relative=True)
    assert not (md or mf or ed)
    deb = 'libtest-dev_2.0.18-1-git.f76b429-1_' + BPY.buildarch() + '.deb'
    src = 'test_2.0.18-1-git.f76b429-1.tar.gz'
    assert ef == set([
        'project/build.py', 'project/debian/rules', deb,
        'test_2.0.18-1-git.f76b429-1_' + BPY.buildarch() + '.changes',
        'test_2.0.18-1-git.f76b429-1.dsc', 'test_2.0.18-1-git.f76b429-1.tar.gz'
    ])
    (dirs, files) = BPY.debcontents(
        posixpath.join(debdir, deb),
        filter=lambda x: not re.match('./usr/share/doc', x))
    print dirs, files
    assert set(files) == set(
        ['./usr/lib/libtest.a', './usr/etc/bla', './usr/include/test/test.h'])
    (dirs, files) = BPY.srccontents(posixpath.join(debdir, src),
                                    filter=lambda x: re.search('/\.git/', x))
    print dirs, files
    if tar_ignore_supported():
        assert set(files) == set() and set(dirs) == set()
    del bpy  # force cleanup
    tw.clean()
コード例 #2
0
def test_usage_rcfile():
    rc1 = ScopedFile(
        'cmake/path/to/.mirbuildrc', """
[build]
configuration=debug
include_path={0}/include:{1}/include
library_path={1}/lib

[dependencies]
foo={0}

[test:boost]
log_level=all
""".format(LIB_a, LIB_b))
    bpy = BPY(BPY_dep)
    bpy.parse_help()
    assert bpy.err == ''
    assert bpy.has_usage
    assert bpy.exitcode == 0
    assert set(bpy.options.keys()) == set([
        'General', 'Boost Test', 'CMake Coverage', 'General Dependency',
        'C Library Dependency'
    ])
    assert set(bpy.options['C Library Dependency'].keys()) == set(
        ['with-foo', 'with-oh-my'])
    assert set(bpy.configs) >= set(['release', 'debug [*]'])
    assert bpy.options['General']['configuration']['default'] == None
    assert bpy.options['C Library Dependency']['with-foo']['default'] == LIB_a
    assert set(re.split(',\s*', bpy.options['General']['include-path']['default'])) \
               == set([posixpath.join(LIB_a, 'include'), posixpath.join(LIB_b, 'include')])
    assert set(re.split(',\s*', bpy.options['General']['library-path']['default'])) \
               == set([posixpath.join(LIB_b, 'lib')])
    assert bpy.options['Boost Test']['boost-test-log-level'][
        'default'] == 'all'
コード例 #3
0
def test_test_dep():
    rc = ScopedFile('cmake/.mirbuildrc', RC2)
    bpy = BPY(BPY_dep, 'test')
    assert bpy.exitcode == 0
    (to, summary) = bpy.test_output
    assert set(to.keys()) == set(['a_test', 'b_test', 'e_test'])
    assert summary == [3, 3, 'ALL TESTS PASSED']
    assert set(to['b_test']) == set(['a(12)=54', 'b(23)=4734'])
コード例 #4
0
def test_test_arg_fail():
    rc = ScopedFile('cmake/.mirbuildrc', RC)
    bpy = BPY(BPY_ver_arg, 'test')
    assert bpy.exitcode > 0
    (to, summary) = bpy.test_output
    assert set(to.keys()) == set(['a_test', 'b_test', 'e_test'])
    assert summary == [2, 3, '1 TEST FAILED']
    assert set(to['a_test'][1:]) >= set(
        ['fail', '--log_level=nothing', '--log_sink=stderr'])
コード例 #5
0
 def do_package(self):
     x = []
     for module, datadirs in self.__package_data_folders.items():
         mpath = os.path.join(*module.split('.'))
         pyfilename = os.path.join(mpath, '_data.py')
         locations = dict(
             (d, '/usr/share/{0}/{1}'.format(mpath, d)) for d in datadirs)
         contents = 'locations = {0!r}\n'.format(locations)
         x.append(ScopedFile(pyfilename, contents))
     mirbuild.python.PythonProject.do_package(self)
コード例 #6
0
def test_usage_with_package():
    srn = ScopedFile('debian/control', 'nothing', BPY.path)
    bpy = BPY(BPY_std)
    bpy.parse_help()
    assert bpy.err == ''
    assert bpy.has_usage
    assert bpy.exitcode == 0
    assert set(bpy.options.keys()) == set(
        ['General', 'Boost Test', 'CMake Coverage', 'Debian Packaging'])
    assert set(bpy.commands) == set(['build', 'clean', 'configure', 'coverage', 'has', 'install', \
                                    'uninstall', 'meta', 'package', 'distclean', 'realclean', 'test'])
コード例 #7
0
def test_build():
    rc = ScopedFile('cmake/.mirbuildrc', RC)
    tw = TreeWatcher(BPY.path)
    bpy = BPY(BPY_dep, 'build')
    assert bpy.exitcode == 0
    (ed, ef, md, mf) = tw.diff(relative=True)
    assert not (md or mf)
    assert set(['lib/libtest.a', 'configure.json', 'config.cmake']) <= ef
    assert set(['test/a/bin/test', 'test/b/bin/test',
                'test/e/bin/test']).isdisjoint(ef)
    bpy.run('realclean')
    assert bpy.exitcode == 0
    (ed, ef, md, mf) = tw.diff(relative=True)
    assert not (md or mf or ed)
    assert ef == set(['build.py'])
コード例 #8
0
def test_meta_control():
    scon = ScopedFile('debian/control', CONTROL, BPY.path)
    bpy = BPY(BPY_dep, 'meta')
    assert bpy.err == ''
    assert bpy.exitcode == 0
    meta = json.loads(bpy.out)
    assert meta == {
        'project':
        'test',
        'dependencies': ['foo', 'oh-my'],
        'version':
        '2.0.18',
        'packaging': {
            'debian': {
                'source': 'test',
                'package': ['libtest-dev']
            }
        },
        'commands':
        'build clean configure coverage distclean has install meta package realclean test uninstall'
        .split()
    }
コード例 #9
0
def test_test():
    rc = ScopedFile('cmake/.mirbuildrc', RC)
    tw = TreeWatcher(BPY.path)
    bpy = BPY(BPY_ver, 'test')
    assert bpy.exitcode == 0
    (ed, ef, md, mf) = tw.diff(relative=True)
    assert not (md or mf)
    assert set(['lib/libtest.a', 'configure.json', 'config.cmake', \
                'test/a/bin/test', 'test/b/bin/test', 'test/e/bin/test']) <= ef
    (to, summary) = bpy.test_output
    assert set(to.keys()) == set(['a_test', 'b_test', 'e_test'])
    assert summary == [3, 3, 'ALL TESTS PASSED']
    assert posixpath.isabs(to['a_test'][0])
    assert set(to['a_test'][1:]) >= set(
        ['--log_level=nothing', '--log_sink=stderr'])
    ver = {}
    for l in to['e_test']:
        (k, v) = re.sub('^TEST_', '', l).split('=')
        ver[k] = v
    assert ver['PROJECT_STR'] == 'test'
    assert ver['PACKAGE_STR'] == 'test'
    assert ver['AUTHOR_STR'] == 'Marcus Holland-Moritz <*****@*****.**>'
    assert ver['RELEASE_ISODATE_STR'] == '2011-07-24T17:58:15+00:00'
    assert ver['RELEASE_YEAR_STR'] == '2011'
    assert ver['RELEASE_DATE_STR'] == '2011-07-24'
    assert ver['RELEASE_TIME_STR'] == '17:58:15'
    assert ver['FULL_REVISION_STR'] == '2.0.18-1-git.f76b429-1'
    assert ver['REVISION_STR'] == '2.0.18'
    assert int(ver['RELEASE_YEAR']) == 2011
    assert int(ver['RELEASE_EPOCH_TIME']) == 1311530295
    assert int(ver['MAJOR_REVISION']) == 2
    assert int(ver['MINOR_REVISION']) == 0
    assert int(ver['PATCHLEVEL']) == 18
    bpy.run('realclean')
    assert bpy.exitcode == 0
    (ed, ef, md, mf) = tw.diff(relative=True)
    assert not (md or mf or ed)
    assert ef == set(['build.py'])
コード例 #10
0
 def __init__(self, content, *args):
     self.sf = ScopedFile(self.name, content, self.path)
     self.run(*args)
コード例 #11
0
def test_usage_rcfile_multi():
    rc1 = ScopedFile(
        'cmake/path/to/.mirbuildrc', """
[build]
include_path={0}/include:{1}/include

[dependencies]
oh-my={0}

[test:boost]
log_sink=stderr
""".format(LIB_a, LIB_b))
    rc2 = ScopedFile(
        'cmake/path/.mirbuildrc', """
[build]
configuration=release
library_path={0}/lib

[dependencies]
foo={0}
oh-my=/oh/no
""".format(LIB_b))
    rc3 = ScopedFile(
        'cmake/.mirbuildrc', """
[build]
configuration=debug

[test:boost]
log_level=nothing
log_sink=/some/where
""")

    bpy = BPY(BPY_dep)
    bpy.parse_help()

    assert bpy.err == ''
    assert bpy.has_usage
    assert bpy.exitcode == 0
    assert bpy.cache is None

    assert set(bpy.options.keys()) == set([
        'General', 'Boost Test', 'CMake Coverage', 'General Dependency',
        'C Library Dependency'
    ])
    assert set(bpy.options['C Library Dependency'].keys()) == set(
        ['with-foo', 'with-oh-my'])
    assert set(bpy.configs) >= set(['release [*]', 'debug'])
    assert bpy.options['General']['configuration']['default'] == None
    assert bpy.options['C Library Dependency']['with-foo']['default'] == LIB_b
    assert bpy.options['C Library Dependency']['with-oh-my'][
        'default'] == LIB_a
    assert set(re.split(',\s*', bpy.options['General']['include-path']['default'])) \
               == set([posixpath.join(LIB_a, 'include'), posixpath.join(LIB_b, 'include')])
    assert set(re.split(',\s*', bpy.options['General']['library-path']['default'])) \
               == set([posixpath.join(LIB_b, 'lib')])
    assert bpy.options['Boost Test']['boost-test-log-level'][
        'default'] == 'nothing'
    assert bpy.options['Boost Test']['boost-test-log-sink'][
        'default'] == 'stderr'

    bpy.run('configure')

    cache = bpy.cache
    cfg = bpy.config
    assert bpy.err == ''
    assert bpy.exitcode == 0
    assert cache is not None
    assert cache.has_key(sys.platform)
    cache = cache[sys.platform]
    assert cache['test_runners']['boost']['log_sink'] == 'stderr'
    assert cache['test_runners']['boost']['log_level'] == 'nothing'
    assert cache['dependencies']['foo']['path'] == LIB_b
    assert cache['dependencies']['oh-my']['path'] == LIB_a
    assert set(cache['general']['include_path']) \
               == set([posixpath.join(LIB_a, 'include'), posixpath.join(LIB_b, 'include')])
    assert set(cache['general']['library_path']) \
               == set([posixpath.join(LIB_b, 'lib')])
    assert cache['general']['configuration'] == 'release'
    assert cfg is not None
    assert cfg['var']['CMAKE_BUILD_TYPE'] == 'release'
    assert string.count(cfg['INCLUDE_DIRECTORIES'],
                        posixpath.join(LIB_a, 'include')) >= 1
    assert string.count(cfg['INCLUDE_DIRECTORIES'],
                        posixpath.join(LIB_b, 'include')) >= 1
    assert string.count(cfg['LINK_DIRECTORIES'], posixpath.join(LIB_a,
                                                                'lib')) >= 1
    assert string.count(cfg['LINK_DIRECTORIES'], posixpath.join(LIB_b,
                                                                'lib')) >= 1

    bpy.run('configure', '--boost-test-log-sink=filename.out', '-c', 'debug', '--with-foo=' + LIB_a, \
                         '--prefix=/opt/bpy', '--library-path=' + posixpath.join(LIB_a, 'lib'))

    cache = bpy.cache
    cfg = bpy.config
    assert bpy.err == ''
    assert bpy.exitcode == 0
    assert cache is not None
    assert cache.has_key(sys.platform)
    cache = cache[sys.platform]
    assert cache['test_runners']['boost']['log_sink'] == 'filename.out'
    assert cache['test_runners']['boost']['log_level'] == 'nothing'
    assert cache['dependencies']['foo']['path'] == LIB_a
    assert cache['dependencies']['oh-my']['path'] == LIB_a
    assert set(cache['general']['include_path']) \
               == set([posixpath.join(LIB_a, 'include'), posixpath.join(LIB_b, 'include')])
    assert set(cache['general']['library_path']) \
               == set([posixpath.join(LIB_a, 'lib'), posixpath.join(LIB_b, 'lib')])
    assert cache['general']['configuration'] == 'debug'
    assert cfg is not None
    assert cfg['var']['CMAKE_BUILD_TYPE'] == 'debug'
    assert cfg['var']['CMAKE_INSTALL_PREFIX'] == '/opt/bpy'
    assert string.count(cfg['INCLUDE_DIRECTORIES'],
                        posixpath.join(LIB_a, 'include')) >= 1
    assert string.count(cfg['LINK_DIRECTORIES'], posixpath.join(LIB_a,
                                                                'lib')) >= 1

    bpy.run()
    bpy.parse_help()

    assert bpy.err == ''
    assert bpy.has_usage
    assert bpy.exitcode == 0
    assert set(bpy.configs) >= set(['release', 'debug [*]'])
    assert bpy.options['C Library Dependency']['with-foo']['default'] == LIB_a
    assert bpy.options['C Library Dependency']['with-oh-my'][
        'default'] == LIB_a
    assert set(re.split(',\s*', bpy.options['General']['include-path']['default'])) \
               == set([posixpath.join(LIB_a, 'include'), posixpath.join(LIB_b, 'include')])
    assert set(re.split(',\s*', bpy.options['General']['library-path']['default'])) \
               == set([posixpath.join(LIB_a, 'lib'), posixpath.join(LIB_b, 'lib')])
    assert bpy.options['Boost Test']['boost-test-log-sink'][
        'default'] == 'filename.out'