Bug 1439742 - Post: Fix tests. r=ted.mielczarek
There's no particular advantage to locating the scripts in
mobile/android/base/locales, especially because the goal is to move
the functionality into mobile/android/base, next to where we compile
the Java that depends on these resources. There's an advantage to
keeping generate_browsersearch.py in python/mozbuild/mozbuild/action;
the Python testing harness is already set up in that location. It's
not worth setting up the testing harness in mobile/android (anywhere),
so let's just leave these in python/mozbuild/mozbuild/action.
This will be folded into the commit sequence, undoing the earlier
move, after review.
MozReview-Commit-ID: EXIxLT1FggB
--- a/mobile/android/base/locales/moz.build
+++ b/mobile/android/base/locales/moz.build
@@ -17,34 +17,34 @@
# (res/{values,raw}-AB-rCD), depending on Make target magic controlled in
# mobile/android/base (for regular builds) and in mobile/android/locales (for
# multi-locale builds and single-locale repacks).
for f in ['../res/raw/browsersearch.json',
'../res/raw{AB_rCD}/browsersearch.json']:
LOCALIZED_GENERATED_FILES += [f]
browsersearch = LOCALIZED_GENERATED_FILES[f]
- browsersearch.script = 'generate_browsersearch.py'
+ browsersearch.script = '/python/mozbuild/mozbuild/action/generate_browsersearch.py'
browsersearch.inputs = [
# The `locales/en-US/` in this path will be rewritten to the
# locale-specific path.
'/mobile/locales/en-US/chrome/region.properties',
]
browsersearch.flags += ['--verbose']
browsersearch.flags += [
'--fallback',
# The `locales/en-US` in this path will not be rewritten.
TOPSRCDIR + '/mobile/locales/en-US/chrome/region.properties'
]
for f in ['../res/raw/suggestedsites.json',
'../res/raw{AB_rCD}/suggestedsites.json']:
LOCALIZED_GENERATED_FILES += [f]
suggestedsites = LOCALIZED_GENERATED_FILES[f]
- suggestedsites.script = 'generate_suggestedsites.py'
+ suggestedsites.script = '/python/mozbuild/mozbuild/action/generate_suggestedsites.py'
suggestedsites.inputs = [
# The `locales/en-US/` in this path will be rewritten to the
# locale-specific path.
'/mobile/locales/en-US/chrome/region.properties',
]
suggestedsites.flags += ['--verbose']
suggestedsites.flags += ['--android-package-name', CONFIG['ANDROID_PACKAGE_NAME']]
suggestedsites.flags += ['--resources', TOPSRCDIR + '/mobile/android/app/src/photon/res']
@@ -53,15 +53,15 @@ for f in ['../res/raw/suggestedsites.jso
# The `locales/en-US` in this path will not be rewritten.
TOPSRCDIR + '/mobile/locales/en-US/chrome/region.properties'
]
for f in ['../res/values/strings.xml',
'../res/values{AB_rCD}/strings.xml']:
LOCALIZED_GENERATED_FILES += [f]
strings = LOCALIZED_GENERATED_FILES[f]
- strings.script = 'generate_strings_xml.py'
+ strings.script = '/python/mozbuild/mozbuild/action/generate_strings_xml.py'
strings.inputs = [
'../strings.xml.in',
# The `en-US/` will be rewritten to the locale-specific path.
'en-US/android_strings.dtd',
'en-US/sync_strings.dtd',
]
rename from mobile/android/base/locales/generate_browsersearch.py
rename to python/mozbuild/mozbuild/action/generate_browsersearch.py
--- a/mobile/android/base/locales/generate_browsersearch.py
+++ b/python/mozbuild/mozbuild/action/generate_browsersearch.py
@@ -132,12 +132,8 @@ def main(output, *args, **kwargs):
if not opts.silent:
if updated:
print('{output} updated'.format(output=os.path.abspath(output.name)))
else:
print('{output} already up-to-date'.format(output=os.path.abspath(output.name)))
return set([opts.fallback])
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
rename from mobile/android/base/locales/generate_strings_xml.py
rename to python/mozbuild/mozbuild/action/generate_strings_xml.py
rename from mobile/android/base/locales/generate_suggestedsites.py
rename to python/mozbuild/mozbuild/action/generate_suggestedsites.py
--- a/python/mozbuild/mozbuild/test/action/test_generate_browsersearch.py
+++ b/python/mozbuild/mozbuild/test/action/test_generate_browsersearch.py
@@ -8,16 +8,19 @@ from __future__ import unicode_literals
import json
import os
import unittest
import mozunit
import mozbuild.action.generate_browsersearch as generate_browsersearch
+from mozbuild.util import (
+ FileAvoidWrite,
+)
from mozfile.mozfile import (
NamedTemporaryFile,
TemporaryDirectory,
)
import mozpack.path as mozpath
@@ -30,20 +33,23 @@ class TestGenerateBrowserSearch(unittest
Unit tests for generate_browsersearch.py.
"""
def _test_one(self, name):
with TemporaryDirectory() as tmpdir:
with NamedTemporaryFile(mode='r+') as temp:
srcdir = os.path.join(test_data_path, name)
- generate_browsersearch.main([
- '--silent',
- '--srcdir', srcdir,
- temp.name])
+ with FileAvoidWrite(temp.name) as faw:
+ generate_browsersearch.main(faw,
+ '--silent',
+ '--fallback',
+ mozpath.join(srcdir, 'region.properties'),
+ )
+
return json.load(temp)
def test_valid_unicode(self):
o = self._test_one('valid-zh-CN')
self.assertEquals(o['default'], '百度')
self.assertEquals(o['engines'], ['百度', 'Google'])
def test_invalid_unicode(self):