OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 from ast import literal_eval | 6 from ast import literal_eval |
7 import os | 7 import os |
8 import tempfile | 8 import tempfile |
9 import unittest | 9 import unittest |
10 | 10 |
11 from compile import Checker | 11 from compile import Checker |
12 from processor import FileCache, Processor | 12 from processor import FileCache, Processor |
13 | 13 |
14 | 14 |
15 _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 15 _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
16 _SRC_DIR = os.path.join(_SCRIPT_DIR, os.pardir, os.pardir) | 16 _SRC_DIR = os.path.join(_SCRIPT_DIR, os.pardir, os.pardir) |
17 _RESOURCES_DIR = os.path.join(_SRC_DIR, "ui", "webui", "resources", "js") | 17 _RESOURCES_DIR = os.path.join(_SRC_DIR, "ui", "webui", "resources", "js") |
18 _ASSERT_JS = os.path.join(_RESOURCES_DIR, "assert.js") | 18 _ASSERT_JS = os.path.join(_RESOURCES_DIR, "assert.js") |
19 _CR_JS = os.path.join(_RESOURCES_DIR, "cr.js") | 19 _CR_JS = os.path.join(_RESOURCES_DIR, "cr.js") |
20 _CR_UI_JS = os.path.join(_RESOURCES_DIR, "cr", "ui.js") | 20 _CR_UI_JS = os.path.join(_RESOURCES_DIR, "cr", "ui.js") |
21 _PROMISE_RESOLVER_JS = os.path.join(_RESOURCES_DIR, "promise_resolver.js") | 21 _PROMISE_RESOLVER_JS = os.path.join(_RESOURCES_DIR, "promise_resolver.js") |
22 _POLYMER_EXTERNS = os.path.join(_SRC_DIR, "third_party", "polymer", "v1_0", | 22 _POLYMER_EXTERNS = os.path.join(_SCRIPT_DIR, "externs", "polymer-1.0.js") |
23 "components-chromium", "polymer-externs", | |
24 "polymer.externs.js") | |
25 _CHROME_SEND_EXTERNS = os.path.join(_SRC_DIR, "third_party", "closure_compiler", | 23 _CHROME_SEND_EXTERNS = os.path.join(_SRC_DIR, "third_party", "closure_compiler", |
26 "externs", "chrome_send.js") | 24 "externs", "chrome_send.js") |
27 _CLOSURE_ARGS_GYPI = os.path.join(_SCRIPT_DIR, "closure_args.gypi") | 25 _CLOSURE_ARGS_GYPI = os.path.join(_SCRIPT_DIR, "closure_args.gypi") |
28 _GYPI_DICT = literal_eval(open(_CLOSURE_ARGS_GYPI).read()) | 26 _GYPI_DICT = literal_eval(open(_CLOSURE_ARGS_GYPI).read()) |
29 _COMMON_CLOSURE_ARGS = _GYPI_DICT["closure_args"] + \ | 27 _COMMON_CLOSURE_ARGS = _GYPI_DICT["closure_args"] + \ |
30 _GYPI_DICT["default_disabled_closure_args"] | 28 _GYPI_DICT["default_disabled_closure_args"] |
31 | 29 |
32 | 30 |
33 class CompilerTest(unittest.TestCase): | 31 class CompilerTest(unittest.TestCase): |
34 _ASSERT_DEFINITION = Processor(_ASSERT_JS).contents | 32 _ASSERT_DEFINITION = Processor(_ASSERT_JS).contents |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 """ | 366 """ |
369 args = ['warning_level=VERBOSE'] | 367 args = ['warning_level=VERBOSE'] |
370 self._runCheckerTestExpectError(template % '', 'Missing return', | 368 self._runCheckerTestExpectError(template % '', 'Missing return', |
371 closure_args=args) | 369 closure_args=args) |
372 self._runCheckerTestExpectSuccess(template % 'assertNotReached();', | 370 self._runCheckerTestExpectSuccess(template % 'assertNotReached();', |
373 closure_args=args) | 371 closure_args=args) |
374 | 372 |
375 | 373 |
376 if __name__ == "__main__": | 374 if __name__ == "__main__": |
377 unittest.main() | 375 unittest.main() |
OLD | NEW |