diff options
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.py | 56 |
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' |