# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os import unittest
import mozunit
from mozpack.chrome.manifest import (
MANIFESTS_TYPES,
Manifest,
ManifestBinaryComponent,
ManifestCategory,
ManifestComponent,
ManifestContent,
ManifestContract,
ManifestInterfaces,
ManifestLocale,
ManifestOverlay,
ManifestOverride,
ManifestResource,
ManifestSkin,
ManifestStyle,
parse_manifest,
parse_manifest_line,
) from mozpack.errors import AccumulatedErrors, errors from test_errors import TestErrors
def test_manifest_rebase(self):
m = parse_manifest_line("chrome", "content global content/global/")
m = m.rebase("")
self.assertEqual(str(m), "content global chrome/content/global/")
m = m.rebase("chrome")
self.assertEqual(str(m), "content global content/global/")
m = parse_manifest_line("chrome/foo", "content global content/global/")
m = m.rebase("chrome")
self.assertEqual(str(m), "content global foo/content/global/")
m = m.rebase("chrome/foo")
self.assertEqual(str(m), "content global content/global/")
m = parse_manifest_line("modules/foo", "resource foo ./")
m = m.rebase("modules")
self.assertEqual(str(m), "resource foo foo/")
m = m.rebase("modules/foo")
self.assertEqual(str(m), "resource foo ./")
m = parse_manifest_line("chrome", "content browser browser/content/")
m = m.rebase("chrome/browser").move("jar:browser.jar!").rebase("")
self.assertEqual(str(m), "content browser jar:browser.jar!/content/")
class TestManifestErrors(TestErrors, unittest.TestCase): def test_parse_manifest_errors(self):
manifest = [ "skin global classic/1.0 content/skin/classic/ platform", "", "binary-component bar.so", "unsupported foo",
] with mozunit.MockedOpen({"manifest": "\n".join(manifest)}): with self.assertRaises(AccumulatedErrors): with errors.accumulate():
list(parse_manifest(os.curdir, "manifest"))
out = self.get_output() # Expecting 2 errors
self.assertEqual(len(out), 2)
path = os.path.abspath("manifest") # First on line 1
self.assertTrue(out[0].startswith("error: %s:1: " % path)) # Second on line 4
self.assertTrue(out[1].startswith("error: %s:4: " % path))
if __name__ == "__main__":
mozunit.main()
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.