Commit e5dd87c4 authored by Chris Mumford's avatar Chris Mumford Committed by Commit Bot

sqlite: Corrected formatting of Python scripts.

Corrected indent to be four spaces IAW the style guide. Doing this
makes all Python scripts uniformaly formatted in //third_party/sqlite/scripts.

Bug: None
Change-Id: I476654c330bf957e0ad65d46c44df53e1eacdf2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2150236Reviewed-by: default avatarDarwin Huang <huangdarwin@chromium.org>
Commit-Queue: Chris Mumford <cmumford@google.com>
Cr-Commit-Position: refs/heads/master@{#759702}
parent e13e0b1b
# TODO(cmumford): Format older files in a future CL.
extract_sqlite_api.py
extract_sqlite_api_unittest.py
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# Copyright 2018 The Chromium Authors. All rights reserved. # Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
''' '''
Parses SQLite source code and produces renaming macros for its exported symbols. Parses SQLite source code and produces renaming macros for its exported symbols.
...@@ -18,10 +17,12 @@ For example, the following renaming macro is produced for sqlite3_initialize(). ...@@ -18,10 +17,12 @@ For example, the following renaming macro is produced for sqlite3_initialize().
import re import re
import sys import sys
class ExtractError(ValueError): class ExtractError(ValueError):
def __init__(self, message): def __init__(self, message):
self.message = message self.message = message
def ExtractLineTuples(string): def ExtractLineTuples(string):
'''Returns a list of lines, with start/end whitespace stripped. '''Returns a list of lines, with start/end whitespace stripped.
...@@ -31,14 +32,15 @@ def ExtractLineTuples(string): ...@@ -31,14 +32,15 @@ def ExtractLineTuples(string):
stripped_lines = [line.strip() for line in raw_lines] stripped_lines = [line.strip() for line in raw_lines]
return list(enumerate(stripped_lines, start=1)) return list(enumerate(stripped_lines, start=1))
def ExtractPreprocessorDirectives(lines): def ExtractPreprocessorDirectives(lines):
'''Extracts preprocessor directives from lines of C code. '''Extracts preprocessor directives from lines of C code.
Each input line should be a tuple of (line number, string). Each input line should be a tuple of (line number, string).
Returns a list of preprocessor directives, and a list of C code lines with the Returns a list of preprocessor directives, and a list of C code lines with
preprocessor directives removed. The returned code lines are a subset of the the preprocessor directives removed. The returned code lines are a subset
input tuples. of the input tuples.
''' '''
code_lines = [] code_lines = []
directives = [] directives = []
...@@ -71,11 +73,12 @@ def ExtractPreprocessorDirectives(lines): ...@@ -71,11 +73,12 @@ def ExtractPreprocessorDirectives(lines):
# Regular expression used to parse a macro definition. # Regular expression used to parse a macro definition.
DEFINITION_RE = re.compile(r'^\#\s*define\s+(\w+)(\s|$)') DEFINITION_RE = re.compile(r'^\#\s*define\s+(\w+)(\s|$)')
def ExtractDefineMacroName(line): def ExtractDefineMacroName(line):
'''Extracts the macro name from a non-function preprocessor definition. '''Extracts the macro name from a non-function preprocessor definition.
Returns None if the preprocessor line is not a preprocessor macro definition. Returns None if the preprocessor line is not a preprocessor macro
Macro functions are not considered preprocessor definitions. definition. Macro functions are not considered preprocessor definitions.
''' '''
match = DEFINITION_RE.match(line) match = DEFINITION_RE.match(line)
if match is None: if match is None:
...@@ -86,12 +89,15 @@ def ExtractDefineMacroName(line): ...@@ -86,12 +89,15 @@ def ExtractDefineMacroName(line):
# Matches C++-style // single-line comments. # Matches C++-style // single-line comments.
SINGLE_LINE_COMMENT_RE = re.compile(r'//.*$') SINGLE_LINE_COMMENT_RE = re.compile(r'//.*$')
# Matches C-style /* multi-line comments */. # Matches C-style /* multi-line comments */.
MULTI_LINE_COMMENT_RE = re.compile(r'/\*.*?\*/', flags=re.MULTILINE|re.DOTALL) MULTI_LINE_COMMENT_RE = re.compile(
r'/\*.*?\*/', flags=re.MULTILINE | re.DOTALL)
def RemoveLineComments(line): def RemoveLineComments(line):
'''Returns the given C code line with comments removed. '''Returns the given C code line with comments removed.
This handles both C-style /* comments */ and C++-style // comments, but cannot This handles both C-style /* comments */ and C++-style // comments, but
tackle C-style comments that extend over multiple lines. cannot tackle C-style comments that extend over multiple lines.
''' '''
return SINGLE_LINE_COMMENT_RE.sub('', MULTI_LINE_COMMENT_RE.sub('', line)) return SINGLE_LINE_COMMENT_RE.sub('', MULTI_LINE_COMMENT_RE.sub('', line))
...@@ -118,6 +124,7 @@ def RemoveComments(code_tuples): ...@@ -118,6 +124,7 @@ def RemoveComments(code_tuples):
# Splits a line of C code into statement pieces. # Splits a line of C code into statement pieces.
STATEMENT_BREAK_RE = re.compile(r'[;{}]') STATEMENT_BREAK_RE = re.compile(r'[;{}]')
def ToStatementTuples(code_tuples): def ToStatementTuples(code_tuples):
'''Converts C code lines into statements. '''Converts C code lines into statements.
...@@ -136,8 +143,8 @@ def ToStatementTuples(code_tuples): ...@@ -136,8 +143,8 @@ def ToStatementTuples(code_tuples):
for piece in pieces[:-1]: # The last piece is an unfinished statement. for piece in pieces[:-1]: # The last piece is an unfinished statement.
if current_statement != '': if current_statement != '':
current_statement = current_statement + '\n' + piece current_statement = current_statement + '\n' + piece
statements.append( statements.append((current_start, line_number,
(current_start, line_number, current_statement.strip())) current_statement.strip()))
current_statement = '' current_statement = ''
else: else:
statements.append((line_number, line_number, piece.strip())) statements.append((line_number, line_number, piece.strip()))
...@@ -159,12 +166,7 @@ WHITESPACE_RE = re.compile(r'\s+') ...@@ -159,12 +166,7 @@ WHITESPACE_RE = re.compile(r'\s+')
# them before incorporating them into exported symbols. We can avoid matching # them before incorporating them into exported symbols. We can avoid matching
# curly braces because we do not support enum, struct, or union, and we only # curly braces because we do not support enum, struct, or union, and we only
# need to consider declarations involving typedef names and primitive types. # need to consider declarations involving typedef names and primitive types.
UNSUPPORTED_KEYWORDS = set([ UNSUPPORTED_KEYWORDS = set(['enum', 'struct', 'union', 'typedef'])
'enum',
'struct',
'union',
'typedef'
])
# Type qualifiers that we can skip over. # Type qualifiers that we can skip over.
# #
...@@ -198,11 +200,12 @@ COMPOSITE_TYPE_SPECIFIERS = set([ ...@@ -198,11 +200,12 @@ COMPOSITE_TYPE_SPECIFIERS = set([
# Matches an identifier. # Matches an identifier.
IDENTIFIER_RE = re.compile(r'^[a-zA-Z_0-9]+$') IDENTIFIER_RE = re.compile(r'^[a-zA-Z_0-9]+$')
def ExtractApiExport(macro_names, api_export_macro, statement): def ExtractApiExport(macro_names, api_export_macro, statement):
'''Extracts the symbol name from a statement exporting a function. '''Extracts the symbol name from a statement exporting a function.
Returns None if the statement does not export a symbol. Throws ExtractError if Returns None if the statement does not export a symbol. Throws ExtractError
the parser cannot understand the statement. if the parser cannot understand the statement.
''' '''
# See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf, section 6.7 # See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf, section 6.7
# for how to parse C declarations. Note that a declaration is a number of # for how to parse C declarations. Note that a declaration is a number of
...@@ -253,7 +256,8 @@ def ExtractApiExport(macro_names, api_export_macro, statement): ...@@ -253,7 +256,8 @@ def ExtractApiExport(macro_names, api_export_macro, statement):
if word in COMPOSITE_TYPE_SPECIFIERS: if word in COMPOSITE_TYPE_SPECIFIERS:
if seen_simple_type: if seen_simple_type:
raise ExtractError('Mixed simple (struct_name) and composite (int) types') raise ExtractError(
'Mixed simple (struct_name) and composite (int) types')
seen_composite_type = True seen_composite_type = True
continue continue
...@@ -314,9 +318,11 @@ def ProcessSource(api_export_macro, symbol_prefix, header_line, footer_line, ...@@ -314,9 +318,11 @@ def ProcessSource(api_export_macro, symbol_prefix, header_line, footer_line,
symbol_name = ExtractApiExport(macro_names, api_export_macro, line) symbol_name = ExtractApiExport(macro_names, api_export_macro, line)
if symbol_name: if symbol_name:
output_lines.append( output_lines.append(
ExportedSymbolLine(symbol_prefix, symbol_name, statement_tuple)) ExportedSymbolLine(symbol_prefix, symbol_name,
statement_tuple))
except ExtractError as exception: except ExtractError as exception:
output_lines.append(ExportedExceptionLine(exception, statement_tuple)) output_lines.append(
ExportedExceptionLine(exception, statement_tuple))
output_lines.sort() output_lines.sort()
return [header_line] + output_lines + [footer_line] return [header_line] + output_lines + [footer_line]
...@@ -334,7 +340,8 @@ def ProcessSourceFile(api_export_macro, symbol_prefix, header_line, ...@@ -334,7 +340,8 @@ def ProcessSourceFile(api_export_macro, symbol_prefix, header_line,
with open(output_file, 'w') as f: with open(output_file, 'w') as f:
f.write('\n'.join(output_lines)) f.write('\n'.join(output_lines))
header_line='''// Copyright 2018 The Chromium Authors. All rights reserved.
header_line = '''// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -344,11 +351,15 @@ header_line='''// Copyright 2018 The Chromium Authors. All rights reserved. ...@@ -344,11 +351,15 @@ header_line='''// Copyright 2018 The Chromium Authors. All rights reserved.
#define THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_ #define THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
''' '''
footer_line =''' footer_line = '''
#endif // THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_ #endif // THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
''' '''
if __name__ == '__main__': if __name__ == '__main__':
ProcessSourceFile(api_export_macro='SQLITE_API', symbol_prefix='chrome_', ProcessSourceFile(
header_line=header_line, footer_line=footer_line, api_export_macro='SQLITE_API',
input_file=sys.argv[1], output_file=sys.argv[2]) symbol_prefix='chrome_',
header_line=header_line,
footer_line=footer_line,
input_file=sys.argv[1],
output_file=sys.argv[2])
...@@ -15,12 +15,15 @@ import sys ...@@ -15,12 +15,15 @@ import sys
import tempfile import tempfile
import unittest import unittest
class ExtractSqliteApiUnittest(unittest.TestCase): class ExtractSqliteApiUnittest(unittest.TestCase):
def setUp(self): def setUp(self):
self.test_root = tempfile.mkdtemp() self.test_root = tempfile.mkdtemp()
source_path = os.path.join( source_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'extract_sqlite_api.py') os.path.dirname(os.path.realpath(__file__)),
self.extractor = SourceFileLoader('extract_api', source_path).load_module() 'extract_sqlite_api.py')
self.extractor = SourceFileLoader('extract_api',
source_path).load_module()
def tearDown(self): def tearDown(self):
if self.test_root: if self.test_root:
...@@ -29,13 +32,13 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -29,13 +32,13 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
def testExtractLineTuples(self): def testExtractLineTuples(self):
golden = [(1, 'Line1'), (2, ''), (3, 'Line 2'), (4, 'Line3'), (5, '')] golden = [(1, 'Line1'), (2, ''), (3, 'Line 2'), (4, 'Line3'), (5, '')]
text_with_newline = "Line1\n\nLine 2 \nLine3\n" text_with_newline = "Line1\n\nLine 2 \nLine3\n"
self.assertEqual(self.extractor.ExtractLineTuples(text_with_newline), self.assertEqual(
golden) self.extractor.ExtractLineTuples(text_with_newline), golden)
golden = [(1, 'Line1'), (2, ''), (3, 'Line 2'), (4, 'Line3')] golden = [(1, 'Line1'), (2, ''), (3, 'Line 2'), (4, 'Line3')]
text_without_newline = "Line1\n\nLine 2 \nLine3" text_without_newline = "Line1\n\nLine 2 \nLine3"
self.assertEqual(self.extractor.ExtractLineTuples(text_without_newline), self.assertEqual(
golden) self.extractor.ExtractLineTuples(text_without_newline), golden)
def testExtractPreprocessorDirectives(self): def testExtractPreprocessorDirectives(self):
lines = [ lines = [
...@@ -50,7 +53,8 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -50,7 +53,8 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
(9, 'void code() { }'), (9, 'void code() { }'),
] ]
directives, code_lines = self.extractor.ExtractPreprocessorDirectives(lines) directives, code_lines = self.extractor.ExtractPreprocessorDirectives(
lines)
self.assertEqual(directives, [ self.assertEqual(directives, [
'#define DIRECTIVE 1', '#define DIRECTIVE 1',
'#define MULTILINE \nMORE_MULTILINE_DIRECTIVE\nEND_MULTILINE_DIRECTIVE', '#define MULTILINE \nMORE_MULTILINE_DIRECTIVE\nEND_MULTILINE_DIRECTIVE',
...@@ -65,43 +69,42 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -65,43 +69,42 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
def testExtractDefineMacroName(self): def testExtractDefineMacroName(self):
self.assertEqual( self.assertEqual(
'SQLITE_API', self.extractor.ExtractDefineMacroName( 'SQLITE_API',
'#define SQLITE_API 1')) self.extractor.ExtractDefineMacroName('#define SQLITE_API 1'))
self.assertEqual( self.assertEqual(
'SQLITE_API', self.extractor.ExtractDefineMacroName( 'SQLITE_API',
'#define SQLITE_API')) self.extractor.ExtractDefineMacroName('#define SQLITE_API'))
self.assertEqual( self.assertEqual(
'SQLITE_API', self.extractor.ExtractDefineMacroName( 'SQLITE_API',
'#define SQLITE_API\n1')) self.extractor.ExtractDefineMacroName('#define SQLITE_API\n1'))
self.assertEqual( self.assertEqual(
'SQLITE_API', self.extractor.ExtractDefineMacroName( 'SQLITE_API',
self.extractor.ExtractDefineMacroName(
'# define SQLITE_API 1')) '# define SQLITE_API 1'))
self.assertEqual( self.assertEqual(
'SQLITE_API', self.extractor.ExtractDefineMacroName( 'SQLITE_API',
'#\tdefine\tSQLITE_API\t1')) self.extractor.ExtractDefineMacroName('#\tdefine\tSQLITE_API\t1'))
self.assertEqual( self.assertEqual(
None, self.extractor.ExtractDefineMacroName( None,
' #define SQLITE_API 1')) self.extractor.ExtractDefineMacroName(' #define SQLITE_API 1'))
self.assertEqual( self.assertEqual(
None, self.extractor.ExtractDefineMacroName( None,
' #define SQLITE_API() 1')) self.extractor.ExtractDefineMacroName(' #define SQLITE_API() 1'))
self.assertEqual(None, self.extractor.ExtractDefineMacroName('')) self.assertEqual(None, self.extractor.ExtractDefineMacroName(''))
def testRemoveLineComments(self): def testRemoveLineComments(self):
self.assertEqual( self.assertEqual('word;', self.extractor.RemoveLineComments('word;'))
'word;', self.extractor.RemoveLineComments('word;')) self.assertEqual('', self.extractor.RemoveLineComments(''))
self.assertEqual( self.assertEqual('', self.extractor.RemoveLineComments('// comment'))
'', self.extractor.RemoveLineComments('')) self.assertEqual('',
self.assertEqual( self.extractor.RemoveLineComments('/* comment */'))
'', self.extractor.RemoveLineComments('// comment')) self.assertEqual('word;',
self.assertEqual( self.extractor.RemoveLineComments('wo/*comment*/rd;'))
'', self.extractor.RemoveLineComments('/* comment */'))
self.assertEqual(
'word;', self.extractor.RemoveLineComments('wo/*comment*/rd;'))
self.assertEqual( self.assertEqual(
'word;*/', self.extractor.RemoveLineComments('wo/*comment*/rd;*/')) 'word;*/', self.extractor.RemoveLineComments('wo/*comment*/rd;*/'))
self.assertEqual( self.assertEqual(
'word;*/', self.extractor.RemoveLineComments('wo/*/*comment*/rd;*/')) 'word;*/',
self.extractor.RemoveLineComments('wo/*/*comment*/rd;*/'))
self.assertEqual( self.assertEqual(
'word;', self.extractor.RemoveLineComments('wo/*comm//ent*/rd;')) 'word;', self.extractor.RemoveLineComments('wo/*comm//ent*/rd;'))
...@@ -112,12 +115,15 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -112,12 +115,15 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
(3, '/**'), (3, '/**'),
(4, 'Spec text'), (4, 'Spec text'),
(5, '**/ spec_code();'), (5, '**/ spec_code();'),
(6, 'late_code(); /* with comment */ more_late_code(); /* late comment'), (6,
'late_code(); /* with comment */ more_late_code(); /* late comment'
),
(7, 'ends here // C++ trap */ code(); // /* C trap'), (7, 'ends here // C++ trap */ code(); // /* C trap'),
(8, 'last_code();'), (8, 'last_code();'),
] ]
self.assertEqual(self.extractor.RemoveComments(lines), [ self.assertEqual(
self.extractor.RemoveComments(lines), [
(1, 'code();'), (1, 'code();'),
(2, 'more_code(); more_code();'), (2, 'more_code(); more_code();'),
(3, ''), (3, ''),
...@@ -128,19 +134,14 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -128,19 +134,14 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
]) ])
def testToStatementTuples(self): def testToStatementTuples(self):
lines = [ lines = [(1, 'void function();'), (2, 'int main('),
(1, 'void function();'),
(2, 'int main('),
(3, ' int argc, char* argv) {'), (3, ' int argc, char* argv) {'),
(4, ' statement1; statement2;'), (4, ' statement1; statement2;'), (5, '}'), (6, 'stat'),
(5, '}'), (7, 'ement4; statement5; sta'), (8, 'tem'),
(6, 'stat'), (9, 'ent6; statement7;')]
(7, 'ement4; statement5; sta'),
(8, 'tem'),
(9, 'ent6; statement7;')
]
self.assertEqual(self.extractor.ToStatementTuples(lines), [ self.assertEqual(
self.extractor.ToStatementTuples(lines), [
(1, 1, 'void function()'), (1, 1, 'void function()'),
(2, 3, 'int main(\n int argc, char* argv)'), (2, 3, 'int main(\n int argc, char* argv)'),
(4, 4, 'statement1'), (4, 4, 'statement1'),
...@@ -155,8 +156,8 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -155,8 +156,8 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
def testExtractApiExport(self): def testExtractApiExport(self):
self.assertEqual( self.assertEqual(
'sqlite3_init', 'sqlite3_init',
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(set(), 'SQLITE_API',
set(), 'SQLITE_API', 'SQLITE_API void sqlite3_init()')) 'SQLITE_API void sqlite3_init()'))
self.assertEqual( self.assertEqual(
'sqlite3_sleep', 'sqlite3_sleep',
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(
...@@ -170,18 +171,21 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -170,18 +171,21 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
'sqlite3rbu_temp_size', 'sqlite3rbu_temp_size',
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(
set(), 'SQLITE_API', set(), 'SQLITE_API',
'SQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu)')) 'SQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu)'
))
self.assertEqual( self.assertEqual(
'sqlite3_expired', 'sqlite3_expired',
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(
set(['SQLITE_DEPRECATED']), 'SQLITE_API', set(['SQLITE_DEPRECATED']), 'SQLITE_API',
'SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*)')) 'SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*)'
))
# SQLite's header actually #defines double (in some cases). # SQLite's header actually #defines double (in some cases).
self.assertEqual( self.assertEqual(
'sqlite3_column_double', 'sqlite3_column_double',
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(
set(['double']), 'SQLITE_API', set(['double']), 'SQLITE_API',
'SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol)')) 'SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol)'
))
self.assertEqual( self.assertEqual(
'sqlite3_temp_directory', 'sqlite3_temp_directory',
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(
...@@ -201,7 +205,8 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -201,7 +205,8 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
with self.assertRaisesRegex(self.extractor.ExtractError, with self.assertRaisesRegex(self.extractor.ExtractError,
'Mixed simple .* and composite'): 'Mixed simple .* and composite'):
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(
set(), 'SQLITE_API', 'SQLITE_API void int sqlite3_sleep(int ms)') set(), 'SQLITE_API',
'SQLITE_API void int sqlite3_sleep(int ms)')
with self.assertRaisesRegex(self.extractor.ExtractError, with self.assertRaisesRegex(self.extractor.ExtractError,
'Unsupported keyword struct'): 'Unsupported keyword struct'):
self.extractor.ExtractApiExport( self.extractor.ExtractApiExport(
...@@ -280,11 +285,11 @@ class ExtractSqliteApiUnittest(unittest.TestCase): ...@@ -280,11 +285,11 @@ class ExtractSqliteApiUnittest(unittest.TestCase):
output_file = os.path.join(self.test_root, 'macros.h') output_file = os.path.join(self.test_root, 'macros.h')
with open(input_file, 'w') as f: with open(input_file, 'w') as f:
f.write(file_content) f.write(file_content)
self.extractor.ProcessSourceFile( self.extractor.ProcessSourceFile('SQLITE_API', 'chrome_', '// Header',
'SQLITE_API', 'chrome_', '// Header', '// Footer', input_file, '// Footer', input_file, output_file)
output_file)
with open(output_file, 'r') as f: with open(output_file, 'r') as f:
self.assertEqual(f.read(), golden_output) self.assertEqual(f.read(), golden_output)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -115,7 +115,7 @@ def _read_flags(file_name, param_name): ...@@ -115,7 +115,7 @@ def _read_flags(file_name, param_name):
config_globals = dict() config_globals = dict()
with open(file_name) as input_file: with open(file_name) as input_file:
code = compile(input_file.read(), file_name, 'exec') code = compile(input_file.read(), file_name, 'exec')
exec(code, config_globals) exec (code, config_globals)
return config_globals[param_name] return config_globals[param_name]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment