Permalink
Browse files

Merge pull request #203 from kmaglione/xpi-path

Fix Jetpack module presence tests
  • Loading branch information...
2 parents 3d94b19 + 0c1c581 commit 0ae0a96fb723e14872373252947581abed04a240 @mattbasta committed Jun 7, 2013
Showing with 32 additions and 0 deletions.
  1. BIN tests/resources/jetpack/jetpack-1.14.xpi
  2. +13 −0 tests/test_jetpack.py
  3. +19 −0 validator/testcases/jetpack.py
Binary file not shown.
View
@@ -313,6 +313,19 @@ def test_mismatched_module_version():
assert any(w["id"][2] == "mismatched_version" for w in err.warnings)
+def test_new_module_location_spec():
+ """
+ Tests that we don't fail for missing modules in add-ons generated with
+ newer versions of the SDK.
+ """
+
+ xpi = XPIManager("tests/resources/jetpack/jetpack-1.14.xpi")
+ err = _do_test(xpi)
+
+ assert not any(w["id"][2] == "missing_jetpack_module"
+ for w in err.warnings)
+
+
def test_components_flagged():
"""Test that `Components` is flagged in Jetpack."""
@@ -174,6 +174,25 @@ def inspect_jetpack(err, xpi_package, allow_old_sdk=False):
uri = uri[11:]
zip_path = "resources/%s" % uri.replace("@", "-at-")
+ # The key is no longer a URI in newer versions of the SDK
+ if zip_path not in xpi_package:
+ zip_path = 'resources/%s/%s/%s.js' % (
+ module['packageName'], module['sectionName'],
+ module['moduleName'])
+
+ # Check the zipname element if it exists.
+ if zip_path not in xpi_package:
+ err.warning(
+ err_id=("testcases_jetpack",
+ "inspect_jetpack",
+ "missing_jetpack_module"),
+ warning="Missing Jetpack module",
+ description=["A Jetpack module listed in harness-options.json "
+ "could not be found in the add-on.",
+ "Path: %s" % zip_path],
+ filename="harness-options.json")
+ continue
+
blob_hash = hashlib.sha256(xpi_package.read(zip_path)).hexdigest()
file_hashes[zip_path] = blob_hash

0 comments on commit 0ae0a96

Please sign in to comment.