Exemple #1
0
def test_is_installed():
    from rosdep2.platforms.source import SourceInstaller, SourceInstall
    resolved = SourceInstall()
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    installer = SourceInstaller()
    assert installer.is_installed(resolved)
def test_is_installed():
    from rosdep2.platforms.source import SourceInstaller, SourceInstall
    resolved = SourceInstall()
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    installer = SourceInstaller()
    assert installer.is_installed(resolved)
def test_SourceInstall():
    from rosdep2.platforms.source import InvalidRdmanifest, SourceInstall

    #tripwire
    SourceInstall()

    # test unpacking of dict
    manifest = {
        'md5sum': 'fake-md5',
        'exec-path': '/path',
        'install-script': 'echo hello',
        'check-presence-script': 'hello there',
        'uri': 'http://ros.org/',
        'alternate-uri': 'http://turtlebot.com/',
        'depends': ['foo', 'bar'],
        }
    resolved = SourceInstall.from_manifest(manifest, 'fake-url')
    assert resolved.manifest == manifest
    assert resolved.manifest_url == 'fake-url'
    assert resolved.install_command == 'echo hello'
    assert resolved.check_presence_command == 'hello there'
    assert resolved.exec_path == '/path'
    assert resolved.tarball == 'http://ros.org/'
    assert resolved.alternate_tarball == 'http://turtlebot.com/'
    assert resolved.tarball_md5sum == 'fake-md5'

    test_dir = get_test_dir()
    path = os.path.join(test_dir, 'rep112-example.rdmanifest')
    manifest = yaml.load(open(path))
    resolved = SourceInstall.from_manifest(manifest, path)
    _subtest_rep112_rdmanifest(resolved)

    #TODO: test depends

    # test with bad dicts
    manifest = {
        'md5sum': 'fake-md5',
        'exec-path': '/path',
        'install-script': 'echo hello',
        'check-presence-script': 'hello there',
        'alternate-uri': 'http://turtlebot.com/',
        'depends': ['foo', 'bar'],
        }
    # uri is required
    try:
        SourceInstall.from_manifest(manifest, 'foo')
        assert False, "should have raised"
    except InvalidRdmanifest as e:
        pass
    
    # test defaults
    manifest = dict(uri='http://ros.org/')
    resolved = SourceInstall.from_manifest(manifest, 'foo')
    assert resolved.exec_path == '.'
    assert resolved.install_command == ''
    assert resolved.check_presence_command == ''    
    assert resolved.alternate_tarball is None
    assert resolved.tarball_md5sum is None
def test_install_source():
    from rosdep2.platforms.source import install_source, SourceInstall
    resolved = SourceInstall()
    resolved.tarball = 'https://github.com/ros-infrastructure/rosdep/raw/master/test/source/foo.tar.gz'
    resolved.tarball_md5sum = 'fd34dc39f8f192b97fcc191fe0a6befc'
    resolved.install_command = """#!/bin/sh
exit 0
"""
    resolved.exec_path = ''
    install_source(resolved)
Exemple #5
0
def test_install_source():
    from rosdep2.platforms.source import install_source, SourceInstall
    resolved = SourceInstall()
    resolved.tarball = 'https://kforge.ros.org/rosrelease/rosdep/raw-file/tip/test/source/foo.tar.gz'
    resolved.tarball_md5sum = 'fd34dc39f8f192b97fcc191fe0a6befc'
    resolved.install_command = """#!/bin/sh
exit 0
"""
    resolved.exec_path = ''
    install_source(resolved)
def _install_rdmanifest(uri, prefix):
    if os.path.isfile(uri):
        with open(uri, 'r') as f:
            contents = f.read()
            manifest = load_rdmanifest(contents)
            source_install = SourceInstall.from_manifest(manifest, uri)
            _install_source(source_install)
    else:
        logger.info('Downloading rdmanifest')
        manifest, url = download_rdmanifest(uri, None)
        source_install = SourceInstall.from_manifest(manifest, url)
        _install_source(source_install, prefix)
Exemple #7
0
def test_source_detect():
    from rosdep2.platforms.source import source_detect, SourceInstall
    resolved = SourceInstall()
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    assert [] == source_detect([])
    assert [resolved] == source_detect([resolved])

    def yes(*args, **kwds):
        return 0

    def no(*args, **kwds):
        return 1

    resolved = [
        SourceInstall(),
        SourceInstall(),
        SourceInstall(),
        SourceInstall()
    ]
    for r in resolved:
        r.check_presence_command = ''

    retval = source_detect(resolved, exec_fn=yes)
    assert resolved == retval, retval
    assert [] == source_detect(resolved, exec_fn=no)
def test_source_detect():
    from rosdep2.platforms.source import source_detect, SourceInstall
    resolved = SourceInstall()
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    assert [] == source_detect([])
    assert [resolved] == source_detect([resolved])

    def yes(*args, **kwds): return 0
    def no(*args, **kwds): return 1

    resolved = [SourceInstall(), SourceInstall(), SourceInstall(), SourceInstall()]
    for r in resolved:
        r.check_presence_command = ''
    
    retval = source_detect(resolved, exec_fn=yes)
    assert resolved == retval, retval
    assert [] == source_detect(resolved, exec_fn=no)
Exemple #9
0
def test_SourceInstall():
    from rosdep2.platforms.source import InvalidRdmanifest, SourceInstall

    #tripwire
    SourceInstall()

    # test unpacking of dict
    manifest = {
        'md5sum': 'fake-md5',
        'exec-path': '/path',
        'install-script': 'echo hello',
        'check-presence-script': 'hello there',
        'uri': 'http://ros.org/',
        'alternate-uri': 'http://turtlebot.com/',
        'depends': ['foo', 'bar'],
    }
    resolved = SourceInstall.from_manifest(manifest, 'fake-url')
    assert resolved.manifest == manifest
    assert resolved.manifest_url == 'fake-url'
    assert resolved.install_command == 'echo hello'
    assert resolved.check_presence_command == 'hello there'
    assert resolved.exec_path == '/path'
    assert resolved.tarball == 'http://ros.org/'
    assert resolved.alternate_tarball == 'http://turtlebot.com/'
    assert resolved.tarball_md5sum == 'fake-md5'

    test_dir = get_test_dir()
    path = os.path.join(test_dir, 'rep112-example.rdmanifest')
    manifest = yaml.load(open(path))
    resolved = SourceInstall.from_manifest(manifest, path)
    _subtest_rep112_rdmanifest(resolved)

    #TODO: test depends

    # test with bad dicts
    manifest = {
        'md5sum': 'fake-md5',
        'exec-path': '/path',
        'install-script': 'echo hello',
        'check-presence-script': 'hello there',
        'alternate-uri': 'http://turtlebot.com/',
        'depends': ['foo', 'bar'],
    }
    # uri is required
    try:
        SourceInstall.from_manifest(manifest, 'foo')
        assert False, "should have raised"
    except InvalidRdmanifest as e:
        pass

    # test defaults
    manifest = dict(uri='http://ros.org/')
    resolved = SourceInstall.from_manifest(manifest, 'foo')
    assert resolved.exec_path == '.'
    assert resolved.install_command == ''
    assert resolved.check_presence_command == ''
    assert resolved.alternate_tarball is None
    assert resolved.tarball_md5sum is None
Exemple #10
0
def test_install_source():
    from rosdep2.platforms.source import install_source, SourceInstall
    resolved = SourceInstall()
    resolved.tarball = 'https://github.com/ros-infrastructure/rosdep/raw/master/test/source/foo.tar.gz'
    resolved.tarball_md5sum = 'fd34dc39f8f192b97fcc191fe0a6befc'
    resolved.install_command = """#!/bin/sh
exit 0
"""
    resolved.exec_path = ''
    install_source(resolved)
Exemple #11
0
def test_install_source():
    from rosdep2.platforms.source import install_source, SourceInstall
    resolved = SourceInstall()
    resolved.tarball = 'https://kforge.ros.org/rosrelease/rosdep/raw-file/tip/test/source/foo.tar.gz'
    resolved.tarball_md5sum = 'fd34dc39f8f192b97fcc191fe0a6befc'
    resolved.install_command = """#!/bin/sh
exit 0
"""
    resolved.exec_path = ''
    install_source(resolved)
Exemple #12
0
def test_SourceInstaller_get_install_command():
    from rosdep2.platforms.source import SourceInstaller, SourceInstall
    installer = SourceInstaller()

    resolved = SourceInstall()
    resolved.manifest_url = 'http://fake/foo'
    resolved.check_presence_command = """#!/bin/bash
exit 1
"""
    commands = installer.get_install_command([resolved])
    assert len(commands) == 1
    assert commands[0] == ['rosdep-source', 'install', 'http://fake/foo']

    resolved = SourceInstall()
    resolved.manifest_url = 'http://fake/foo'
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    commands = installer.get_install_command([resolved])
    assert not (commands)
def test_SourceInstaller_get_install_command():
    from rosdep2.platforms.source import SourceInstaller, SourceInstall
    installer = SourceInstaller()

    resolved = SourceInstall()
    resolved.manifest_url = 'http://fake/foo'
    resolved.check_presence_command = """#!/bin/bash
exit 1
"""
    commands = installer.get_install_command([resolved])
    assert len(commands) == 1
    assert commands[0] == ['rosdep-source', 'install', 'http://fake/foo']

    resolved = SourceInstall()
    resolved.manifest_url = 'http://fake/foo'
    resolved.check_presence_command = """#!/bin/bash
exit 0
"""
    commands = installer.get_install_command([resolved])
    assert not(commands)