diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /xpcom/idl-parser/xpidl/runtests.py | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xpcom/idl-parser/xpidl/runtests.py')
-rwxr-xr-x | xpcom/idl-parser/xpidl/runtests.py | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/xpcom/idl-parser/xpidl/runtests.py b/xpcom/idl-parser/xpidl/runtests.py index 2dd269dfd9..b889d40010 100755 --- a/xpcom/idl-parser/xpidl/runtests.py +++ b/xpcom/idl-parser/xpidl/runtests.py @@ -5,6 +5,8 @@ # # Unit tests for xpidl.py +import json +import os import sys # Hack: the first entry in sys.path is the directory containing the script. @@ -16,7 +18,7 @@ import unittest import mozunit -from xpidl import header, xpidl +from xpidl import header, typescript, xpidl class TestParser(unittest.TestCase): @@ -253,5 +255,42 @@ attribute long bar; self.assertEqual(e.args[0], ("cannot find symbol 'Y'")) +class TestTypescript(unittest.TestCase): + """A few basic smoke tests for typescript generation.""" + + dir = os.path.dirname(__file__) + src = os.path.join(dir, "..", "..", "..") + + # We use the xpctest.xpt *.idl files from: + tests_dir = os.path.join(src, "js/xpconnect/tests/idl") + files = [ + "xpctest_attributes.idl", + "xpctest_bug809674.idl", + "xpctest_cenums.idl", + "xpctest_interfaces.idl", + "xpctest_params.idl", + "xpctest_returncode.idl", + "xpctest_utils.idl", + ] + + fixtures = os.path.join(dir, "fixtures") + inc_dirs = [os.path.join(src, "xpcom/base")] + + def setUp(self): + self.parser = xpidl.IDLParser() + + def test_d_json(self): + mods = [] + for file in self.files: + path = os.path.join(self.tests_dir, file) + idl = self.parser.parse(open(path).read(), path) + idl.resolve(self.inc_dirs, self.parser, {}) + mods.append(typescript.ts_source(idl)) + + result = json.dumps(mods, indent=2, sort_keys=True) + expected = open(os.path.join(self.fixtures, "xpctest.d.json")).read() + self.assertEqual(result, expected, "types data json does not match") + + if __name__ == "__main__": mozunit.main(runwith="unittest") |