def test_install_and_execution(self): with fixture_setup.WithoutSnapInstalled('cmake-hello'): self.run_snapcraft(project_dir='cmake-hello') self.install_snap() self.assertThat( subprocess.check_output( ['cmake-hello'], universal_newlines=True), Equals("It's a CMake world\n"))
def test_install_and_execution(self): with fixture_setup.WithoutSnapInstalled('python-hello'): self.run_snapcraft(project_dir='python-hello') self.install_snap() self.assertThat( subprocess.check_output(['python-hello'], universal_newlines=True), Equals('Hello world!\n'))
def setUp(self): super().setUp() # We cannot install snaps on the adt test bed at this time. # - Mount snap "core" (2775) ([start snap-core-2775.mount] \ # failed with exit status 1: Job for snap-core-2775.mount failed. if os.environ.get('ADT_TEST') and self.deb_arch == 'armhf': self.skipTest('snap installation not working well with ' 'adt on armhf') self.useFixture(fixture_setup.WithoutSnapInstalled('hello'))
def test_ament_support(self): self.useFixture(fixture_setup.WithoutSnapInstalled('ros2-example')) self.run_snapcraft(project_dir='ros2') self.install_snap() self.assertThat( subprocess.check_output(['ros2-example.launch-project'], universal_newlines=True, stderr=subprocess.STDOUT), Contains('I heard: Hello world'))
def test_catkin_pip_support(self): with fixture_setup.WithoutSnapInstalled('ros-pip-example'): self.run_snapcraft(project_dir='ros-pip') self.install_snap() # If pip support didn't work properly, the import should fail. self.assertThat( subprocess.check_output(['ros-pip-example.launch-project'], universal_newlines=True, stderr=subprocess.STDOUT), Contains("Local timezone:"))
def test_install_and_execution(self): if self.deb_arch != 'amd64': self.skipTest('The dotnet plugin only supports amd64, for now') with fixture_setup.WithoutSnapInstalled('dotnet-hello'): self.run_snapcraft(project_dir='dotnet-hello') self.install_snap() self.assertThat( subprocess.check_output(['dotnet-hello'], universal_newlines=True), Equals('Hello World!\n'))
def test_build_snap(self): self.useFixture(fixture_setup.WithoutSnapInstalled(self.snap)) snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path) snapcraft_yaml.update_part('test-part-with-build-snap', { 'plugin': 'nil', 'build-snaps': [self.snap] }) self.useFixture(snapcraft_yaml) self.run_snapcraft('build') self.assertTrue( snapcraft.repo.snaps.SnapPackage.is_snap_installed(self.snap))
def test_build_snap(self): if os.environ.get('ADT_TEST') and self.deb_arch == 'armhf': self.skipTest("The autopkgtest armhf runners can't install snaps") self.useFixture(fixture_setup.WithoutSnapInstalled(self.snap)) snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path) snapcraft_yaml.update_part('test-part-with-build-snap', { 'plugin': 'nil', 'build-snaps': [self.snap] }) self.useFixture(snapcraft_yaml) self.run_snapcraft('build') self.assertTrue( snapcraft.repo.snaps.SnapPackage.is_snap_installed(self.snap))
def test_install_and_execution(self) -> None: self.useFixture( fixture_setup.WithoutSnapInstalled('catkin-tools-example')) self.run_snapcraft(project_dir='catkin-tools-talker-listener') self.install_snap() # Run the ROS system. By default this will never exit, but the code # supports an `exit-after-receive` parameter that, if true, will cause # the system to shutdown after the listener has successfully received # a message. output = subprocess.check_output([ 'catkin-tools-example.launch-project', 'exit-after-receive:=true' ]).decode() self.assertThat( output, MatchesRegex(r'.*I heard Hello world.*', flags=re.DOTALL))
def test_install_and_execution(self): with fixture_setup.WithoutSnapInstalled('go-hello'): # If we just put the source in the temp dir, go will generate # the binary with the name of the temp dir, instead of go-hello. dir_util.copy_tree( os.path.join(self.snaps_dir, 'go-hello'), os.path.join(self.path, 'go-hello'), preserve_symlinks=True) os.chdir('go-hello') self.run_snapcraft() self.install_snap() self.assertThat( subprocess.check_output( ['go-hello'], universal_newlines=True), Equals('Hello snapcrafter\n'))
def test_prime_records_build_snaps(self): self.useFixture(fixture_setup.WithoutSnapInstalled('hello')) snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path) snapcraft_yaml.update_part('test-part', { 'plugin': 'nil', 'build-snaps': ['hello'] }) self.useFixture(snapcraft_yaml) self.run_snapcraft('prime') expected_revision = snaps.SnapPackage( 'hello').get_local_snap_info()['revision'] recorded_yaml_path = os.path.join(self.prime_dir, 'snap', 'manifest.yaml') with open(recorded_yaml_path) as recorded_yaml_file: recorded_yaml = yaml.load(recorded_yaml_file) self.assertThat(recorded_yaml['build-snaps'], Equals(['hello={}'.format(expected_revision)]))
def test_install_and_execution(self): with fixture_setup.WithoutSnapInstalled('plainbox-simple'): self.run_snapcraft(project_dir='plainbox-simple') self.install_snap() # This test fails if the binary is executed from /tmp. os.chdir(os.path.expanduser('~')) expected = textwrap.dedent("""\ com.canonical.plainbox::collect-manifest com.canonical.plainbox::manifest com.example::always-fail com.example::always-pass """) self.assertThat( subprocess.check_output( ['plainbox-simple.plainbox', 'dev', 'special', '-j'], universal_newlines=True), Equals(expected)) subprocess.check_call( ['plainbox-simple.plainbox', 'run', '-i com.example::.*'])
def test_install_and_execution(self): self.useFixture(fixture_setup.WithoutSnapInstalled('ros-example')) try: failed = True self.run_snapcraft(project_dir='ros-talker-listener') failed = False except subprocess.CalledProcessError: if self.deb_arch == 'arm64': # https://bugs.launchpad.net/snapcraft/+bug/1662915 self.expectFailure( 'There are no arm64 Indigo packages in the ROS archive', self.assertFalse, failed) else: raise self.install_snap() # check that the hardcoded /usr/bin/python in rosversion # is changed to using /usr/bin/env python expected = b'#!/usr/bin/env python\n' output = subprocess.check_output( "sed -n '/env/p;1q' prime/usr/bin/rosversion", shell=True) self.assertThat(output, Equals(expected)) # This test fails if the binary is executed from /tmp. os.chdir(os.path.expanduser('~')) # Regression test for LP: #1660852. Make sure --help actually gets # passed to roslaunch instead of being eaten by setup.sh. output = subprocess.check_output( ['ros-example.launch-project', '--help']).decode() self.assertThat(output, MatchesRegex(r'.*Usage: roslaunch.*')) # Run the ROS system. By default this will never exit, but the demo # supports an `exit-after-receive` parameter that, if true, will cause # the system to shutdown after the listener has successfully received # a message. output = subprocess.check_output( ['ros-example.launch-project', 'exit-after-receive:=true']).decode() self.assertThat( output, MatchesRegex(r'.*I heard Hello world.*', flags=re.DOTALL))
def test_prime_records_build_snaps(self): if os.environ.get('ADT_TEST') and self.deb_arch == 'armhf': self.skipTest("The autopkgtest armhf runners can't install snaps") self.useFixture(fixture_setup.WithoutSnapInstalled('hello')) snapcraft_yaml = fixture_setup.SnapcraftYaml(self.path) snapcraft_yaml.update_part('test-part', { 'plugin': 'nil', 'build-snaps': ['hello'] }) self.useFixture(snapcraft_yaml) self.run_snapcraft('prime') expected_revision = snaps.SnapPackage( 'hello').get_local_snap_info()['revision'] recorded_yaml_path = os.path.join(self.prime_dir, 'snap', 'manifest.yaml') with open(recorded_yaml_path) as recorded_yaml_file: recorded_yaml = yaml.load(recorded_yaml_file) self.assertThat(recorded_yaml['build-snaps'], Equals(['hello={}'.format(expected_revision)]))