diff --git a/src/rosdep2/platforms/debian.py b/src/rosdep2/platforms/debian.py index 8bb78c5b2..404b6d84f 100644 --- a/src/rosdep2/platforms/debian.py +++ b/src/rosdep2/platforms/debian.py @@ -294,13 +294,11 @@ def get_version_strings(self): return ['apt-get {}'.format(version)] def _get_install_commands_for_package(self, base_cmd, package_or_list): - def pkg_command(p): - return self.elevate_priv(base_cmd + [p]) - - if isinstance(package_or_list, list): - return [pkg_command(p) for p in package_or_list] + if isinstance(package_or_list, str): + return self.elevate_priv(base_cmd + [package_or_list]) else: - return pkg_command(package_or_list) + # sort to make the output deterministic + return self.elevate_priv(base_cmd + sorted(package_or_list)) def get_install_command(self, resolved, interactive=True, reinstall=False, quiet=False): packages = self.get_packages_to_install(resolved, reinstall=reinstall) @@ -312,4 +310,9 @@ def get_install_command(self, resolved, interactive=True, reinstall=False, quiet if quiet: base_cmd.append('-qq') - return [self._get_install_commands_for_package(base_cmd, p) for p in _iterate_packages(packages, reinstall)] + return [ + self._get_install_commands_for_package( + base_cmd, + _iterate_packages(packages, reinstall), + ) + ] diff --git a/test/test_rosdep_debian.py b/test/test_rosdep_debian.py index 428b301f4..bba212927 100644 --- a/test/test_rosdep_debian.py +++ b/test/test_rosdep_debian.py @@ -126,13 +126,11 @@ def test(expected_prefix, mock_get_packages_to_install, mock_read_stdout): assert [] == installer.get_install_command(['fake']) mock_get_packages_to_install.return_value = ['a', 'b'] - expected = [expected_prefix + ['apt-get', 'install', '-y', 'a'], - expected_prefix + ['apt-get', 'install', '-y', 'b']] + expected = [expected_prefix + ['apt-get', 'install', '-y', 'a', 'b']] val = installer.get_install_command(['whatever'], interactive=False) print('VAL', val) assert val == expected, val - expected = [expected_prefix + ['apt-get', 'install', 'a'], - expected_prefix + ['apt-get', 'install', 'b']] + expected = [expected_prefix + ['apt-get', 'install', 'a', 'b']] val = installer.get_install_command(['whatever'], interactive=True) assert val == expected, val try: diff --git a/test/test_rosdep_installers.py b/test/test_rosdep_installers.py index 4b91a3f22..e7609b290 100644 --- a/test/test_rosdep_installers.py +++ b/test/test_rosdep_installers.py @@ -617,7 +617,6 @@ def test_RosdepInstaller_install_resolved(mock_geteuid): raise return True stdout_lines = [x.strip() for x in stdout.getvalue().split('\n') if x.strip()] - assert len(stdout_lines) == 3 + assert len(stdout_lines) == 2 assert stdout_lines[0] == '#[apt] Installation commands:' - assert 'sudo -H apt-get install rosdep-fake1' in stdout_lines, 'stdout_lines: %s' % stdout_lines - assert 'sudo -H apt-get install rosdep-fake2' in stdout_lines, 'stdout_lines: %s' % stdout_lines + assert 'sudo -H apt-get install rosdep-fake1 rosdep-fake2' in stdout_lines, 'stdout_lines: %s' % stdout_lines diff --git a/test/test_rosdep_main.py b/test/test_rosdep_main.py index c94143c24..d24759722 100644 --- a/test/test_rosdep_main.py +++ b/test/test_rosdep_main.py @@ -199,15 +199,11 @@ def read_stdout(cmd, capture_stderr=False): '--from-paths', catkin_tree ] + cmd_extras) stdout, stderr = b + # the output is sorted in ascending order expected = [ '#[apt] Installation commands:', - ' sudo -H apt-get install ros-fuerte-catkin', - ' sudo -H apt-get install libboost1.40-all-dev', - ' sudo -H apt-get install libeigen3-dev', - ' sudo -H apt-get install libtinyxml-dev', - ' sudo -H apt-get install libltdl-dev', - ' sudo -H apt-get install libtool', - ' sudo -H apt-get install libcurl4-openssl-dev', + ' sudo -H apt-get install libboost1.40-all-dev libcurl4-openssl-dev' + ' libeigen3-dev libltdl-dev libtinyxml-dev libtool ros-fuerte-catkin', ] lines = stdout.getvalue().splitlines() assert set(lines) == set(expected), lines