Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 723012: fix jetpackID which accidentally changed in 1.4 . r=mhammond

This removes the code in packaging.py which accidentally override the code in
__init__.py which converts package.json:id into
harness-options.json:jetpackID . The consequence of that override was that a
"@jetpack" suffix was not appended when necessary, which caused "jetpackID"
to be wrong in 1.4, which caused simple-storage to look in the wrong place
for its saved data.

This also changes the build_xpi() convenience method (used by a couple tests)
to include the id-to-jetpackID conversion step. The lack of that conversion
step is what prompted the addition to packaging.py, as it was the quickest
way to get the tests to pass at the time.

The simple-prefs tests have been enhanced, and new tests were added to assert
that the id-to-jetpackID conversion happens properly for both "jid" and
"jid@jetpack" (i.e. with and without suffix-adding).

Cherry-picked from master: 582a8ea and b1dbb63
  • Loading branch information...
commit 34d7cf81c6487c75b646d87fb727134325c8f118 1 parent 4bc2bdb
@KWierso KWierso authored
View
17 python-lib/cuddlefish/__init__.py
@@ -472,6 +472,15 @@ def get_unique_prefix(jid):
return unique_prefix
+def buildJID(target_cfg, harness_guid):
+ if "id" in target_cfg:
+ jid = target_cfg["id"]
+ else:
+ jid = harness_guid
+ if not ("@" in jid or jid.startswith("{")):
+ jid = jid + "@jetpack"
+ return jid
+
def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
defaults=None, env_root=os.environ.get('CUDDLEFISH_ROOT'),
stdout=sys.stdout):
@@ -612,13 +621,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
else:
assert command == "test"
- if "id" in target_cfg:
- jid = target_cfg["id"]
- else:
- jid = harness_guid
- if not ("@" in jid or jid.startswith("{")):
- jid = jid + "@jetpack"
-
+ jid = buildJID(target_cfg, harness_guid)
targets = [target]
if command == "test":
View
3  python-lib/cuddlefish/packaging.py
@@ -333,9 +333,6 @@ def add_dep_to_build(dep):
if ('preferences' in target_cfg):
build['preferences'] = target_cfg.preferences
- if ('id' in target_cfg):
- build['jetpackID'] = target_cfg.id
-
return build
def _get_files_in_dir(path):
View
1  python-lib/cuddlefish/tests/linker-files/one/package.json
@@ -1,3 +1,4 @@
{ "name": "one",
+ "id": "jid1@jetpack",
"main": "main"
}
View
2  python-lib/cuddlefish/tests/linker-files/seven/package.json
@@ -1,4 +1,4 @@
{
"name": "seven",
- "id": "jid1"
+ "id": "jid7"
}
View
5 python-lib/cuddlefish/tests/preferences-files/packages/no-prefs/package.json
@@ -1,3 +1,6 @@
{
- "loader": "lib/main.js"
+ "id": "jid1-fZHqN9JfrDBa8A",
+ "fullName": "No Prefs Test",
+ "author": "Erik Vold",
+ "loader": "lib/main.js"
}
View
37 python-lib/cuddlefish/tests/test_linker.py
@@ -2,6 +2,7 @@
import shutil
import zipfile
from StringIO import StringIO
+import simplejson as json
import unittest
import cuddlefish
from cuddlefish import packaging, manifest
@@ -131,6 +132,42 @@ def run_in_subdir(self, dirname, f, *args, **kwargs):
def assertIn(self, what, inside_what):
self.failUnless(what in inside_what, inside_what)
+ def test_jetpackID(self):
+ # this uses "id": "jid7", to which a @jetpack should be appended
+ seven = get_linker_files_dir("seven")
+ def _test(basedir):
+ stdout = StringIO()
+ shutil.copytree(seven, "seven")
+ os.chdir("seven")
+ try:
+ # regrettably, run() always finishes with sys.exit()
+ cuddlefish.run(["xpi", "--no-strip-xpi"],
+ stdout=stdout)
+ except SystemExit, e:
+ self.failUnlessEqual(e.args[0], 0)
+ zf = zipfile.ZipFile("seven.xpi", "r")
+ hopts = json.loads(zf.read("harness-options.json"))
+ self.failUnlessEqual(hopts["jetpackID"], "jid7@jetpack")
+ self.run_in_subdir("x", _test)
+
+ def test_jetpackID_suffix(self):
+ # this uses "id": "jid1@jetpack", so no suffix should be appended
+ one = get_linker_files_dir("one")
+ def _test(basedir):
+ stdout = StringIO()
+ shutil.copytree(one, "one")
+ os.chdir("one")
+ try:
+ # regrettably, run() always finishes with sys.exit()
+ cuddlefish.run(["xpi", "--no-strip-xpi"],
+ stdout=stdout)
+ except SystemExit, e:
+ self.failUnlessEqual(e.args[0], 0)
+ zf = zipfile.ZipFile("one.xpi", "r")
+ hopts = json.loads(zf.read("harness-options.json"))
+ self.failUnlessEqual(hopts["jetpackID"], "jid1@jetpack")
+ self.run_in_subdir("x", _test)
+
def test_strip_default(self):
seven = get_linker_files_dir("seven")
# now run 'cfx xpi' in that directory, except put the generated .xpi
View
19 python-lib/cuddlefish/tests/test_xpi.py
@@ -3,9 +3,10 @@
import zipfile
import pprint
import shutil
+import uuid
import simplejson as json
-from cuddlefish import xpi, packaging, manifest
+from cuddlefish import xpi, packaging, manifest, buildJID
from cuddlefish.tests import test_packaging
from test_linker import up
@@ -34,11 +35,20 @@ def tearDown(self):
def testPackageWithSimplePrefs(self):
self.makexpi('simple-prefs')
- assert 'options.xul' in self.xpi.namelist()
+ self.failUnless('options.xul' in self.xpi.namelist())
+ prefs = self.xpi.read('options.xul')
+ self.failUnless('pref="extensions.jid1-fZHqN9JfrDBa8A@jetpack.test"'
+ in prefs, prefs)
+ self.failUnless('type="bool"' in prefs, prefs)
+ self.failUnless('title="test"' in prefs, prefs)
+ self.failUnlessEqual(self.xpi_harness_options["jetpackID"],
+ "jid1-fZHqN9JfrDBa8A@jetpack")
def testPackageWithNoPrefs(self):
self.makexpi('no-prefs')
- assert 'options.xul' not in self.xpi.namelist()
+ self.failIf('options.xul' in self.xpi.namelist())
+ self.failUnlessEqual(self.xpi_harness_options["jetpackID"],
+ "jid1-fZHqN9JfrDBa8A@jetpack")
class Bug588119Tests(unittest.TestCase):
@@ -272,7 +282,8 @@ def document_dir_files(path):
def create_xpi(xpiname, pkg_name='aardvark', dirname='static-files',
extra_harness_options={}):
configs = test_packaging.get_configs(pkg_name, dirname)
- options = {'main': configs.target_cfg.main}
+ options = {'main': configs.target_cfg.main,
+ 'jetpackID': buildJID(configs.target_cfg, str(uuid.uuid4())), }
options.update(configs.build)
xpi.build_xpi(template_root_dir=xpi_template_path,
manifest=fake_manifest,
Please sign in to comment.
Something went wrong with that request. Please try again.