| Index: Source/bindings/scripts/blink_idl_lexer_test.py
|
| diff --git a/Source/core/scripts/in_file_unittest.py b/Source/bindings/scripts/blink_idl_lexer_test.py
|
| old mode 100644
|
| new mode 100755
|
| similarity index 53%
|
| copy from Source/core/scripts/in_file_unittest.py
|
| copy to Source/bindings/scripts/blink_idl_lexer_test.py
|
| index e065d442987150afe98b0910ff3a814f53e5fbae..69484920e3106f5feff705163f09d59dea3f714c
|
| --- a/Source/core/scripts/in_file_unittest.py
|
| +++ b/Source/bindings/scripts/blink_idl_lexer_test.py
|
| @@ -27,51 +27,52 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| +import fnmatch
|
| +import glob
|
| +import os
|
| import unittest
|
|
|
| -from in_file import InFile
|
| +from blink_idl_lexer import BlinkIDLLexer
|
|
|
| -class InFileTest(unittest.TestCase):
|
| - def test_basic_parse(self):
|
| - contents = """
|
| -name1 arg=value, arg2=value2, arg2=value3
|
| -name2
|
| -"""
|
| - lines = contents.split("\n")
|
| - defaults = {
|
| - 'arg': None,
|
| - 'arg2': [],
|
| - }
|
| - in_file = InFile(lines, defaults, None)
|
| - expected_values = [
|
| - {'name': 'name1', 'arg': 'value', 'arg2': ['value2', 'value3']},
|
| - {'name': 'name2', 'arg': None, 'arg2': []},
|
| - ]
|
| - self.assertEquals(in_file.name_dictionaries, expected_values)
|
| +module_path = os.path.dirname(__file__)
|
|
|
| - def test_with_parameters(self):
|
| - contents = """namespace=TestNamespace
|
| -fruit
|
|
|
| -name1 arg=value, arg2=value2, arg2=value3
|
| -name2
|
| -"""
|
| - lines = contents.split("\n")
|
| - defaults = {
|
| - 'arg': None,
|
| - 'arg2': [],
|
| - }
|
| - default_parameters = {
|
| - 'namespace': '',
|
| - 'fruit': False,
|
| - }
|
| - in_file = InFile(lines, defaults, default_parameters)
|
| - expected_parameters = {
|
| - 'namespace': 'TestNamespace',
|
| - 'fruit': True,
|
| - }
|
| - self.assertEquals(in_file.parameters, expected_parameters)
|
| +def has_preprocessor_directives(filename):
|
| + with open(filename) as idl_file:
|
| + for line in idl_file:
|
| + if line.startswith('#'):
|
| + return True
|
| + return False
|
|
|
|
|
| -if __name__ == "__main__":
|
| +def lex_files(lexer, file_list):
|
| + for filename in file_list:
|
| + # Can't process preprocessor directives
|
| + if has_preprocessor_directives(filename):
|
| + continue
|
| +
|
| + with open(filename, 'rb') as srcfile:
|
| + lexer.Tokenize(srcfile.read(), filename)
|
| + lexer.GetTokens()
|
| +
|
| +
|
| +class BlinkIDLLexerTest(unittest.TestCase):
|
| + def setUp(self):
|
| + self.lexer = BlinkIDLLexer()
|
| +
|
| + def test_lex_test_idl_files(self):
|
| + test_idl_dir = os.path.join(module_path, os.pardir, 'tests', 'idls')
|
| + test_idl_glob = os.path.join(test_idl_dir, '*.idl')
|
| + idl_list = glob.glob(test_idl_glob)
|
| + lex_files(self.lexer, idl_list)
|
| +
|
| + def test_lex_real_idl_files(self):
|
| + idl_list = []
|
| + source_dir = os.path.join(module_path, os.pardir, os.pardir, os.pardir, 'Source')
|
| + for root, _, filenames in os.walk(source_dir):
|
| + for filename in fnmatch.filter(filenames, '*.idl'):
|
| + idl_list.append(os.path.join(root, filename))
|
| + lex_files(self.lexer, idl_list)
|
| +
|
| +if __name__ == '__main__':
|
| unittest.main()
|
|
|