From 8f6e8cfcc71d91a0676378bd1d859f7193b95da2 Mon Sep 17 00:00:00 2001 From: Mohammad Azim Khan Date: Tue, 26 Jun 2018 16:57:37 +0100 Subject: [PATCH] Print line number with data file error --- tests/scripts/generate_test_code.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/scripts/generate_test_code.py b/tests/scripts/generate_test_code.py index 22066f7e6d..c62b5b9a8a 100755 --- a/tests/scripts/generate_test_code.py +++ b/tests/scripts/generate_test_code.py @@ -421,8 +421,9 @@ def parse_test_data(data_f, debug=False): # Blank line indicates end of test if len(line) == 0: if state == STATE_READ_ARGS: - raise GeneratorInputError("Newline before arguments. " \ - "Test function and arguments missing for %s" % name) + raise GeneratorInputError("[%s:%d] Newline before arguments. " \ + "Test function and arguments missing for %s" % \ + (data_f.name, data_f.line_no, name)) continue if state == STATE_READ_NAME: @@ -443,8 +444,9 @@ def parse_test_data(data_f, debug=False): deps = [] state = STATE_READ_NAME if state == STATE_READ_ARGS: - raise GeneratorInputError("Newline before arguments. " \ - "Test function and arguments missing for %s" % name) + raise GeneratorInputError("[%s:%d] Newline before arguments. " \ + "Test function and arguments missing for %s" % \ + (data_f.name, data_f.line_no, name)) def gen_dep_check(dep_id, dep): @@ -650,7 +652,7 @@ def generate_code(funcs_file, data_file, template_file, platform_file, help_file out_data_file.replace('\\', '\\\\')) # escape '\' # Function code - with FileWrapper(funcs_file) as funcs_f, open(data_file, 'r') as data_f, open(out_data_file, 'w') as out_data_f: + with FileWrapper(funcs_file) as funcs_f, FileWrapper(data_file) as data_f, open(out_data_file, 'w') as out_data_f: suite_deps, dispatch_code, func_code, func_info = parse_functions(funcs_f) snippets['functions_code'] = func_code snippets['dispatch_code'] = dispatch_code