Ai
2 Star 0 Fork 0

chromium_develop/chromium_tools

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
preprocess_if_expr_test.py 1.36 KB
Copy Edit Raw Blame History
李想 authored 2022-08-16 16:29 +08:00 . chromium origin init
# 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 os
import shutil
import tempfile
import unittest
import preprocess_if_expr
_HERE_DIR = os.path.dirname(__file__)
class PreprocessIfExprTest(unittest.TestCase):
def setUp(self):
self._out_folder = None
def tearDown(self):
if self._out_folder:
shutil.rmtree(self._out_folder)
def _read_out_file(self, file_name):
assert self._out_folder
return open(os.path.join(self._out_folder, file_name), 'r').read()
def _run_test(self, defines, file_name):
assert not self._out_folder
self._out_folder = tempfile.mkdtemp(dir=_HERE_DIR)
preprocess_if_expr.main([
'--in-folder',
os.path.join(_HERE_DIR, 'preprocess_tests'),
'--out-folder',
self._out_folder,
'--in-files',
file_name,
] + defines)
def testPreprocess(self):
self._run_test(['-D', 'foo', '-D', 'bar'], 'test_with_ifexpr.js')
actual = self._read_out_file('test_with_ifexpr.js')
self.assertIn('I should be included in HTML', actual)
self.assertIn('I should be included in JS', actual)
self.assertNotIn('I should be excluded from HTML', actual)
self.assertNotIn('I should be excluded from JS', actual)
if __name__ == '__main__':
unittest.main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chromium_develop/chromium_tools.git
git@gitee.com:chromium_develop/chromium_tools.git
chromium_develop
chromium_tools
chromium_tools
master

Search