Coverage for snapcraft/tests/test_meta : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright (C) 2015 Canonical Ltd # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
call, patch, )
common, meta, tests )
'name': 'my-package', 'version': '1.0', 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>', 'icon': 'my-icon.png', }
['armhf', 'amd64'])
'name': 'my-package', 'version': '1.0', 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>', 'icon': 'my-icon.png', 'architectures': ['armhf', 'amd64'], }
'name': 'my-package', 'version': '1.0', 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>', 'icon': 'my-icon.png', }
'binary1': {'exec': 'binary1.sh go'}, 'binary2': {'exec': 'binary2.sh'}, }
['armhf', 'amd64'])
else:
'service1': {'start': 'binary1'}, 'service2': { 'start': 'binary2 --start', 'stop': 'binary2 --stop', }, }
['armhf', 'amd64'])
else:
['armhf', 'amd64'])
'name': 'my-package', 'version': '1.0', 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>', 'icon': 'my-icon.png', 'architectures': ['armhf', 'amd64'], 'frameworks': ['mir', ], }
'the description\nwhich can be longer'
the description which can be longer '''
'name': 'my-package', 'version': '1.0', 'vendor': 'Sergio Schvezov <sergio.schvezov@canonical.com>', 'description': 'my description', 'summary': 'my summary', 'icon': 'my-icon.png', 'config': 'bin/config', 'binaries': { 'bash': { 'exec': 'bin/bash', 'security-policy': { 'apparmor': 'file.apparmor', 'seccomp': 'file.seccomp', }, } } }
'snap', 'meta')
call(os.path.join(self.meta_dir, 'package.yaml'), 'w'), call().__enter__(), call().__enter__().write('architectures'), call().__enter__().write(':'), call().__enter__().write('\n'), call().__enter__().write('-'), call().__enter__().write(' '), call().__enter__().write('amd64'), call().__enter__().write('\n'), call().__enter__().write('binaries'), call().__enter__().write(':'), call().__enter__().write('\n'), call().__enter__().write('-'), call().__enter__().write(' '), call().__enter__().write('exec'), call().__enter__().write(':'), call().__enter__().write(' '), call().__enter__().write('bin/bash.wrapper'), call().__enter__().write('\n'), call().__enter__().write(' '), call().__enter__().write('name'), call().__enter__().write(':'), call().__enter__().write(' '), call().__enter__().write('bash'), call().__enter__().write('\n'), call().__enter__().write(' '), call().__enter__().write('security-policy'), call().__enter__().write(':'), call().__enter__().write('\n'), call().__enter__().write(' '), call().__enter__().write('apparmor'), call().__enter__().write(':'), call().__enter__().write(' '), call().__enter__().write('meta/file.apparmor'), call().__enter__().write('\n'), call().__enter__().write(' '), call().__enter__().write('seccomp'), call().__enter__().write(':'), call().__enter__().write(' '), call().__enter__().write('meta/file.seccomp'), call().__enter__().write('\n'), call().__enter__().write('icon'), call().__enter__().write(':'), call().__enter__().write(' '), call().__enter__().write('meta/my-icon.png'), call().__enter__().write('\n'), call().__enter__().write('name'), call().__enter__().write(':'), call().__enter__().write(' '), call().__enter__().write('my-package'), call().__enter__().write('\n'), call().__enter__().write('vendor'), call().__enter__().write(':'), call().__enter__().write(' '), call().__enter__().write('Sergio'), call().__enter__().write(' '), call().__enter__().write('Schvezov'), call().__enter__().write(' '), call().__enter__().write('<sergio.schvezov@canonical.com>'), call().__enter__().write('\n'), call().__enter__().write('version'), call().__enter__().write(':'), call().__enter__().write(" '"), call().__enter__().write('1.0'), call().__enter__().write("'"), call().__enter__().write('\n'), call().__enter__().flush(), call().__enter__().flush(), call().__exit__(None, None, None), call(os.path.join(self.meta_dir, 'readme.md'), 'w'), call().__enter__(), call().__enter__().write('my summary\nmy description\n'), call().__exit__(None, None, None), ]
def test_create_meta(self, mock_the_open, mock_wrap_exe):
call(self.meta_dir, exist_ok=True), call(self.hooks_dir), ])
call( '$SNAP_APP_PATH/bin/bash', os.path.join(os.path.abspath(os.curdir), 'snap/bin/bash.wrapper'), shebang=None, ), call( 'bin/config', os.path.join(self.hooks_dir, 'config'), args=[], cwd='$SNAP_APP_PATH', ), ]) call('my-icon.png', os.path.join(self.meta_dir, 'my-icon.png')), call('file.apparmor', os.path.join(self.meta_dir, 'file.apparmor')), call('file.seccomp', os.path.join(self.meta_dir, 'file.seccomp')), ])
def test_create_meta_with_vararg_config(self, mock_the_open, mock_wrap_exe):
call(self.meta_dir, exist_ok=True), call(self.hooks_dir), ])
call( '$SNAP_APP_PATH/bin/bash', os.path.join(os.path.abspath(os.curdir), 'snap/bin/bash.wrapper'), shebang=None, ), call( 'python3', os.path.join(self.hooks_dir, 'config'), args=['my.py', '--config'], cwd='$SNAP_APP_PATH', ), ])
def test_create_meta_without_config(self, mock_the_open, mock_wrap_exe):
exist_ok=True)
# TODO this needs more tests.
'\n\n' 'exec "$SNAP_APP_PATH/test_relexepath" $*\n')
"""Shebangs pointing to the snap's install dir get extracted.
If the exe has a shebang that points to the snap's install dir, the wrapper script will execute it directly rather than relying the shebang.
The shebang needs to be and absolute path, and we don't know where in which directory the snap will be installed. Executing it in the wrapper script allows us to use the $SNAP_APP_PATH environment variable. """
partsdir, 'testsnap', 'install', 'snap_exe')
'#!/bin/sh\n' '\n\n' 'exec "$SNAP_APP_PATH/snap_exe"' ' "$SNAP_APP_PATH/test_relexepath" $*\n')
# The shebang wasn't changed, since we don't know what the # path will be on the installed system.
"""Shebangs not pointing to the snap's install dir are ignored.
If the shebang points to a system executable, there's no need to interfere. """
'\n\n' 'exec "$SNAP_APP_PATH/test_relexepath" $*\n')
"""Native binaries are ignored.
If the executable is a native binary, and thus not have a shebang, it's ignored. """
# Choose a content which can't be decoded with utf-8, to make # sure no decoding errors happen.
'\n\n' 'exec "$SNAP_APP_PATH/test_relexepath" $*\n')
|