Bug 1068956 - mozversion should throw some kind of exception if binary specified and nothing found. r=wlach

This commit is contained in:
Julien Pagès 2014-10-15 03:49:00 +02:00
Родитель 08eb5e39bf
Коммит b56d64d309
3 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -248,8 +248,8 @@ def get_version(binary=None, sources=None, dm_type=None, host=None,
a path to the binary of the application or an Android APK file (to get
version information for Firefox for Android). If this is omitted then the
current directory is checked for the existance of an application.ini
file. If not found, then it is assumed the target application is a remote
Firefox OS instance.
file. If not found and that the binary path was not specified, then it is
assumed the target application is a remote Firefox OS instance.
:param binary: Path to the binary for the application or Android APK file
:param sources: Path to the sources.xml file (Firefox OS)
@ -266,13 +266,13 @@ def get_version(binary=None, sources=None, dm_type=None, host=None,
if version._info.get('application_name') == 'B2G':
version = LocalB2GVersion(binary, sources=sources)
except errors.LocalAppNotFoundError:
try:
version = RemoteB2GVersion(sources=sources,
dm_type=dm_type,
host=host,
device_serial=device_serial)
except errors.RemoteAppNotFoundError:
raise errors.AppNotFoundError('No application found')
if binary:
# we had a binary argument, do not search for remote B2G
raise
version = RemoteB2GVersion(sources=sources,
dm_type=dm_type,
host=host,
device_serial=device_serial)
for (key, value) in sorted(version._info.items()):
if value:

Просмотреть файл

@ -10,7 +10,7 @@ import unittest
import zipfile
import mozfile
from mozversion import get_version
from mozversion import get_version, errors
class SourcesTest(unittest.TestCase):
@ -65,6 +65,8 @@ class SourcesTest(unittest.TestCase):
self.assertIsNone(v.get('gaia_changeset'))
self.assertIsNone(v.get('gaia_date'))
def test_b2g_fallback_when_no_binary(self):
self.assertRaises(errors.RemoteAppNotFoundError, get_version)
if __name__ == '__main__':
unittest.main()

Просмотреть файл

@ -102,6 +102,9 @@ SourceRepository = PlatformSourceRepo
f.write('foobar')
self._check_version(get_version(exe_name_unprefixed))
def test_not_found_with_binary_specified(self):
self.assertRaises(errors.LocalAppNotFoundError, get_version, self.binary)
def _write_ini_files(self, application=True, platform=True):
if application:
with open(os.path.join(self.tempdir, 'application.ini'), 'w') as f: