summaryrefslogtreecommitdiff
path: root/chromium/mojo/public/tools/mojom/mojom_parser_unittest.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/mojo/public/tools/mojom/mojom_parser_unittest.py
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-c30a6232df03e1efbd9f3b226777b07e087a1122.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/mojo/public/tools/mojom/mojom_parser_unittest.py')
-rw-r--r--[-rwxr-xr-x]chromium/mojo/public/tools/mojom/mojom_parser_unittest.py56
1 files changed, 2 insertions, 54 deletions
diff --git a/chromium/mojo/public/tools/mojom/mojom_parser_unittest.py b/chromium/mojo/public/tools/mojom/mojom_parser_unittest.py
index 9aa655dbed2..a93f34bacb4 100755..100644
--- a/chromium/mojo/public/tools/mojom/mojom_parser_unittest.py
+++ b/chromium/mojo/public/tools/mojom/mojom_parser_unittest.py
@@ -1,67 +1,15 @@
-#!/usr/bin/env python
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import json
-import os
-import os.path
-import shutil
-import tempfile
-import unittest
+from mojom_parser_test_case import MojomParserTestCase
-import mojom_parser
-from mojom.generate import module
-
-
-class MojomParserTest(unittest.TestCase):
+class MojomParserTest(MojomParserTestCase):
"""Tests covering the behavior defined by the main mojom_parser.py script.
This includes behavior around input and output path manipulation, dependency
resolution, and module serialization and deserialization."""
- def __init__(self, method_name):
- super(MojomParserTest, self).__init__(method_name)
- self._temp_dir = None
-
- def setUp(self):
- self._temp_dir = tempfile.mkdtemp()
-
- def tearDown(self):
- shutil.rmtree(self._temp_dir)
- self._temp_dir = None
-
- def GetPath(self, path):
- assert not os.path.isabs(path)
- return os.path.join(self._temp_dir, path)
-
- def GetModulePath(self, path):
- assert not os.path.isabs(path)
- return os.path.join(self.GetPath('out'), path) + '-module'
-
- def WriteFile(self, path, contents):
- full_path = self.GetPath(path)
- dirname = os.path.dirname(full_path)
- if not os.path.exists(dirname):
- os.makedirs(dirname)
- with open(full_path, 'w') as f:
- f.write(contents)
-
- def LoadModule(self, mojom_path):
- with open(self.GetModulePath(mojom_path), 'rb') as f:
- return module.Module.Load(f)
-
- def ParseMojoms(self, mojoms, metadata=None):
- """Parse all input mojoms relative the temp dir."""
- out_dir = self.GetPath('out')
- args = [
- '--input-root', self._temp_dir, '--input-root', out_dir,
- '--output-root', out_dir, '--mojoms'
- ] + list(map(lambda mojom: os.path.join(self._temp_dir, mojom), mojoms))
- if metadata:
- args.extend(['--check-imports', self.GetPath(metadata)])
- mojom_parser.Run(args)
-
def testBasicParse(self):
"""Basic test to verify that we can parse a mojom file and get a module."""
mojom = 'foo/bar.mojom'