Beispiel #1
0
def test_colcon_defaults(tmpdir):
    ws = Path(str(tmpdir))
    this_dir = Path(__file__).parent
    src = ws / 'src'
    src.mkdir()
    shutil.copytree(str(this_dir / 'dummy_pkg_ros2_cpp'),
                    str(src / 'dummy_pkg_ros2_cpp'))
    shutil.copytree(str(this_dir / 'dummy_pkg_ros2_py'),
                    str(src / 'dummy_pkg_ros2_py'))

    client = DockerClient()
    platform = Platform(arch='aarch64', os_name='ubuntu', ros_distro='dashing')
    out_script = ws / rosdep_install_script(platform)

    # no defaults file should get everything
    gather_rosdeps(client, platform, workspace=ws)

    result = out_script.read_text()
    assert 'ros-dashing-ament-cmake' in result
    assert 'ros-dashing-rclcpp' in result
    assert 'ros-dashing-rclpy' in result

    # write defaults file and expect selective dependency output
    (ws / 'defaults.yaml').write_text("""
list:
  packages-select: [dummy_pkg_ros2_py]
""")
    gather_rosdeps(client, platform, workspace=ws)
    result = out_script.read_text()
    assert 'ros-dashing-ament-cmake' not in result
    assert 'ros-dashing-rclcpp' not in result
    assert 'ros-dashing-rclpy' in result
def test_install_rosdep_script_doesnot_exist(tmpdir):
    ws = Path(str(tmpdir))
    platform = Platform('aarch64', 'ubuntu', 'dashing')
    data_file = ws / rosdep_install_script(platform)
    data_file.parent.mkdir(parents=True)
    with pytest.raises(RuntimeError):
        assert_install_rosdep_script_exists(ws, platform)
Beispiel #3
0
def test_custom_rosdep_no_data_dir(tmpdir):
    script_contents = """
cat > /test_rules.yaml <<EOF
definitely_does_not_exist:
  ubuntu:
    bionic: [successful_test]
EOF
echo "yaml file:/test_rules.yaml" > /etc/ros/rosdep/sources.list.d/22-test-rules.list
"""
    ws = Path(str(tmpdir))
    pkg_xml = Path(ws) / 'src' / 'dummy' / 'package.xml'
    pkg_xml.parent.mkdir(parents=True)
    pkg_xml.write_text(CUSTOM_KEY_PKG_XML)
    client = DockerClient()
    platform = Platform(arch='aarch64', os_name='ubuntu', ros_distro='dashing')

    rosdep_setup = ws / 'rosdep_setup.sh'
    rosdep_setup.write_text(script_contents)

    gather_rosdeps(client, platform, workspace=ws, custom_script=rosdep_setup)
    out_script = ws / rosdep_install_script(platform)
    result = out_script.read_text().splitlines()
    expected = [
        '#!/bin/bash',
        'set -euxo pipefail',
        '#[apt] Installation commands:',
        '  apt-get install -y successful_test',
    ]
    assert result == expected, 'Rosdep output did not meet expectations.'
def test_install_rosdep_script_exist(tmpdir):
    ws = Path(str(tmpdir))
    platform = Platform('aarch64', 'ubuntu', 'dashing')
    data_file = ws / rosdep_install_script(platform)
    data_file.parent.mkdir(parents=True)
    data_file.touch()
    check_script = assert_install_rosdep_script_exists(ws, platform)
    assert check_script
Beispiel #5
0
def test_dummy_skip_rosdep_multiple_keys_pkg(tmpdir):
    ws = Path(str(tmpdir))
    pkg_xml = ws / 'src' / 'dummy' / 'package.xml'
    pkg_xml.parent.mkdir(parents=True)
    pkg_xml.write_text(RCLCPP_PKG_XML)
    client = DockerClient()
    platform = Platform(arch='aarch64', os_name='ubuntu', ros_distro='dashing')
    out_script = ws / rosdep_install_script(platform)

    skip_keys = ['ament_cmake', 'rclcpp']
    gather_rosdeps(client, platform, workspace=ws, skip_rosdep_keys=skip_keys)
    result = out_script.read_text()
    assert 'ros-dashing-ament-cmake' not in result
    assert 'ros-dashing-rclcpp' not in result
Beispiel #6
0
def buildable_env(request, tmpdir):
    """Set up a temporary directory with everything needed to run the EmulatedDockerBuildStage."""
    platform = Platform('aarch64', 'ubuntu', 'foxy')
    ros_workspace = Path(str(tmpdir)) / 'ros_ws'
    _touch_anywhere(ros_workspace / rosdep_install_script(platform))
    build_context = prepare_docker_build_environment(platform, ros_workspace)
    docker = DockerClient(disable_cache=False,
                          default_docker_dir=build_context)
    options = default_pipeline_options()
    data_collector = DataCollector()

    CreateSysrootStage()(platform, docker, ros_workspace, options,
                         data_collector)

    return BuildableEnv(platform, docker, ros_workspace, options,
                        data_collector)
Beispiel #7
0
def test_dummy_ros2_pkg(tmpdir):
    ws = Path(str(tmpdir))
    pkg_xml = ws / 'src' / 'dummy' / 'package.xml'
    pkg_xml.parent.mkdir(parents=True)
    pkg_xml.write_text(RCLCPP_PKG_XML)

    client = DockerClient()
    platform = Platform(arch='aarch64', os_name='ubuntu', ros_distro='dashing')
    out_script = ws / rosdep_install_script(platform)
    test_collector = DataCollector()

    stage = CollectDependencyListStage()
    stage(platform, client, ws, default_pipeline_options(), test_collector)

    result = out_script.read_text()
    assert 'ros-dashing-ament-cmake' in result
    assert 'ros-dashing-rclcpp' in result
def test_dummy_ros2_pkg(tmpdir):
    ws = Path(str(tmpdir))
    pkg_xml = ws / 'src' / 'dummy' / 'package.xml'
    pkg_xml.parent.mkdir(parents=True)
    pkg_xml.write_text(RCLCPP_PKG_XML)

    client = DockerClient()
    platform = Platform(arch='aarch64', os_name='ubuntu', ros_distro='dashing')
    out_script = ws / rosdep_install_script(platform)

    # a default set of customizations for the dependencies stage
    customizations = PipelineStageConfigOptions(False, [], None, None, None)
    temp_stage = DependenciesStage()

    temp_stage(platform, client, ws, customizations)

    result = out_script.read_text()
    assert 'ros-dashing-ament-cmake' in result
    assert 'ros-dashing-rclcpp' in result
Beispiel #9
0
def test_dummy_ros2_pkg(tmpdir):
    ws = Path(str(tmpdir))
    pkg_xml = ws / 'src' / 'dummy' / 'package.xml'
    pkg_xml.parent.mkdir(parents=True)
    pkg_xml.write_text(RCLCPP_PKG_XML)

    client = DockerClient()
    platform = Platform(arch='aarch64', os_name='ubuntu', ros_distro='dashing')
    out_script = ws / rosdep_install_script(platform)

    gather_rosdeps(client, platform, workspace=ws)
    result = out_script.read_text().splitlines()
    expected = [
        '#!/bin/bash',
        'set -euxo pipefail',
        '#[apt] Installation commands:',
        '  apt-get install -y ros-dashing-ament-cmake',
        '  apt-get install -y ros-dashing-rclcpp',
    ]
    assert result == expected, 'Rosdep output did not meet expectations.'
Beispiel #10
0
def test_custom_rosdep_no_data_dir(tmpdir):
    script_contents = """
cat > /test_rules.yaml <<EOF
definitely_does_not_exist:
  ubuntu:
    bionic: [successful_test]
EOF
echo "yaml file:/test_rules.yaml" > /etc/ros/rosdep/sources.list.d/22-test-rules.list
"""
    ws = Path(str(tmpdir))
    pkg_xml = Path(ws) / 'src' / 'dummy' / 'package.xml'
    pkg_xml.parent.mkdir(parents=True)
    pkg_xml.write_text(CUSTOM_KEY_PKG_XML)
    client = DockerClient()
    platform = Platform(arch='aarch64', os_name='ubuntu', ros_distro='dashing')

    rosdep_setup = ws / 'rosdep_setup.sh'
    rosdep_setup.write_text(script_contents)

    gather_rosdeps(client, platform, workspace=ws, custom_script=rosdep_setup)
    out_script = ws / rosdep_install_script(platform)
    result = out_script.read_text()
    assert 'successful_test' in result
Beispiel #11
0
def test_custom_post_build_script(tmpdir):
    created_filename = 'file-created-by-post-build'
    platform = Platform('aarch64', 'ubuntu', 'foxy')
    ros_workspace = Path(str(tmpdir)) / 'ros_ws'
    _touch_anywhere(ros_workspace / rosdep_install_script(platform))
    post_build_script = ros_workspace / 'post_build'
    post_build_script.write_text("""
    #!/bin/bash
    echo "success" > {}
    """.format(created_filename))
    build_context = prepare_docker_build_environment(
        platform, ros_workspace, custom_post_build_script=post_build_script)
    docker = DockerClient(disable_cache=False,
                          default_docker_dir=build_context)
    options = default_pipeline_options()
    data_collector = DataCollector()

    CreateSysrootStage()(platform, docker, ros_workspace, options,
                         data_collector)
    EmulatedDockerBuildStage()(platform, docker, ros_workspace, options,
                               data_collector)

    assert (ros_workspace / created_filename).is_file()