mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Bug 1040069 - Return None for the gaia commit if it can't be found. r=ahalberstadt
This commit is contained in:
parent
3bc0df27dc
commit
7c95173e9a
@ -140,6 +140,9 @@ class B2GVersion(Version):
|
||||
self._info['gaia_changeset'] = re.match(
|
||||
'^\w{40}$', changeset) and changeset or None
|
||||
self._info['gaia_date'] = date
|
||||
except KeyError:
|
||||
self.warn('Unable to find resources/gaia_commit.txt in '
|
||||
'application.zip')
|
||||
finally:
|
||||
mozfile.remove(tempdir)
|
||||
|
||||
|
@ -29,27 +29,38 @@ class SourcesTest(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
mozfile.remove(self.tempdir)
|
||||
|
||||
def _create_zip(self, revision, date='date'):
|
||||
def _create_zip(self, revision=None, date=None):
|
||||
zip_path = os.path.join(
|
||||
self.tempdir, 'gaia', 'profile', 'webapps',
|
||||
'settings.gaiamobile.org', 'application.zip')
|
||||
os.makedirs(os.path.dirname(zip_path))
|
||||
app_zip = zipfile.ZipFile(zip_path, 'w')
|
||||
app_zip.writestr('resources/gaia_commit.txt', revision + '\n' + date)
|
||||
if revision or date:
|
||||
app_zip.writestr('resources/gaia_commit.txt',
|
||||
'%s\n%s' % (revision, date))
|
||||
app_zip.close()
|
||||
|
||||
def test_gaia_commit(self):
|
||||
self._create_zip('a' * 40, 'date')
|
||||
revision, date = ('a' * 40, 'date')
|
||||
self._create_zip(revision, date)
|
||||
v = get_version(self.binary)
|
||||
self.assertEqual(v.get('gaia_changeset'), 'a' * 40)
|
||||
self.assertEqual(v.get('gaia_date'), 'date')
|
||||
self.assertEqual(v.get('gaia_changeset'), revision)
|
||||
self.assertEqual(v.get('gaia_date'), date)
|
||||
|
||||
def test_invalid_gaia_commit(self):
|
||||
self._create_zip('a' * 41)
|
||||
revision, date = ('a' * 41, 'date')
|
||||
self._create_zip(revision, date)
|
||||
v = get_version(self.binary)
|
||||
self.assertIsNone(v.get('gaia_changeset'))
|
||||
self.assertEqual(v.get('gaia_date'), date)
|
||||
|
||||
def test_missing_zip_file(self):
|
||||
v = get_version(self.binary)
|
||||
self.assertIsNone(v.get('gaia_changeset'))
|
||||
self.assertIsNone(v.get('gaia_date'))
|
||||
|
||||
def test_missing_gaia_commit(self):
|
||||
self._create_zip()
|
||||
v = get_version(self.binary)
|
||||
self.assertIsNone(v.get('gaia_changeset'))
|
||||
self.assertIsNone(v.get('gaia_date'))
|
||||
|
Loading…
Reference in New Issue
Block a user