Skip to content
Snippets Groups Projects
Commit 62a41570 authored by Florian Angerer's avatar Florian Angerer
Browse files

Fix: Fuzzy compare did not properly synchronize.

parent 82c52bb3
No related branches found
No related tags found
No related merge requests found
...@@ -674,34 +674,40 @@ def _fuzzy_compare(gnur_content, fastr_content, gnur_filename, fastr_filename, v ...@@ -674,34 +674,40 @@ def _fuzzy_compare(gnur_content, fastr_content, gnur_filename, fastr_filename, v
if fastr_content[fastr_i].startswith('NULL') and not gnur_line.startswith('NULL'): if fastr_content[fastr_i].startswith('NULL') and not gnur_line.startswith('NULL'):
# ignore additional visible NULL # ignore additional visible NULL
fastr_i = fastr_i + 1 fastr_i = fastr_i + 1
continue sync = True
if gnur_line.startswith('Warning') and gnur_i + 1 < gnur_end and 'closing unused connection' in gnur_content[gnur_i + 1]: elif gnur_line.startswith('Warning') and gnur_i + 1 < gnur_end and 'closing unused connection' in gnur_content[gnur_i + 1]:
# ignore message about closed connection # ignore message about closed connection
gnur_i = gnur_i + 2 gnur_i = gnur_i + 2
continue sync = True
if gnur_i > 0 and gnur_content[gnur_i - 1].startswith(' user system elapsed'): elif gnur_i > 0 and gnur_content[gnur_i - 1].startswith(' user system elapsed'):
# ignore differences in timing # ignore differences in timing
gnur_i = gnur_i + 1 gnur_i = gnur_i + 1
fastr_i = fastr_i + 1 fastr_i = fastr_i + 1
continue sync = True
# we are fuzzy on Error/Warning as FastR often differs # we are fuzzy on Error/Warning as FastR often differs
# in the context/format of the error/warning message AND GnuR is sometimes # in the context/format of the error/warning message AND GnuR is sometimes
# inconsistent over which error message it uses. Unlike the unit test environment, # inconsistent over which error message it uses. Unlike the unit test environment,
# we cannot tag tests in any way, so we simply check that FastR does report # we cannot tag tests in any way, so we simply check that FastR does report
# an error. We then scan forward to try to get the files back in sync, as the # an error. We then scan forward to try to get the files back in sync, as the
# the number of error/warning lines may differ. # the number of error/warning lines may differ.
if 'Error' in gnur_line or 'Warning' in gnur_line: elif 'Error' in gnur_line or 'Warning' in gnur_line:
to_match = 'Error' if 'Error' in gnur_line else 'Warning' to_match = 'Error' if 'Error' in gnur_line else 'Warning'
if to_match not in fastr_line: if to_match not in fastr_line:
result = 1 result = 1
else: else:
# accept differences in the error/warning messages but we need to synchronize # accept differences in the error/warning messages but we need to synchronize
gnur_i = gnur_i + 1
fastr_i = fastr_i + 1
sync = True sync = True
elif _is_ignored_function("sessionInfo", gnur_content, gnur_cur_statement_start, fastr_content, fastr_cur_statement_start): elif _is_ignored_function("sessionInfo", gnur_content, gnur_cur_statement_start, fastr_content, fastr_cur_statement_start):
# ignore differences in 'sessionInfo' output # ignore differences in 'sessionInfo' output
gnur_i = gnur_i + 1
fastr_i = fastr_i + 1
sync = True sync = True
elif _is_ignored_function("extSoftVersion", gnur_content, gnur_cur_statement_start, fastr_content, fastr_cur_statement_start): elif _is_ignored_function("extSoftVersion", gnur_content, gnur_cur_statement_start, fastr_content, fastr_cur_statement_start):
# ignore differences in 'extSoftVersion' output # ignore differences in 'extSoftVersion' output
gnur_i = gnur_i + 1
fastr_i = fastr_i + 1
sync = True sync = True
else: else:
# genuine difference (modulo whitespace) # genuine difference (modulo whitespace)
...@@ -717,6 +723,8 @@ def _fuzzy_compare(gnur_content, fastr_content, gnur_filename, fastr_filename, v ...@@ -717,6 +723,8 @@ def _fuzzy_compare(gnur_content, fastr_content, gnur_filename, fastr_filename, v
print fastr_line.strip() print fastr_line.strip()
# we need to synchronize the indices such that we can continue # we need to synchronize the indices such that we can continue
gnur_i = gnur_i + 1
fastr_i = fastr_i + 1
sync = True sync = True
# report the last statement to produce different output # report the last statement to produce different output
assert fastr_cur_statement_start != -1 assert fastr_cur_statement_start != -1
...@@ -734,8 +742,6 @@ def _fuzzy_compare(gnur_content, fastr_content, gnur_filename, fastr_filename, v ...@@ -734,8 +742,6 @@ def _fuzzy_compare(gnur_content, fastr_content, gnur_filename, fastr_filename, v
# synchronize: skip until lines match (or file end reached) # synchronize: skip until lines match (or file end reached)
if sync: if sync:
gnur_i = gnur_i + 1
fastr_i = fastr_i + 1
if gnur_i == gnur_end - 1: if gnur_i == gnur_end - 1:
# at end (there is always a blank line) # at end (there is always a blank line)
break break
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment