Skip to content

Commit 438db73

Browse files
authored
Print message when P4TEST_IGNORE_STDERR is used (#5358)
Signed-off-by: Bryan Richter <[email protected]>
1 parent b223ad0 commit 438db73

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

backends/p4test/run-p4-sample.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ def isError(p4filename):
7373
return "_errors" in p4filename
7474

7575

76+
ignoreStderrDirective = 'P4TEST_IGNORE_STDERR'
77+
78+
7679
def ignoreStderr(options):
7780
for line in open(options.p4filename):
78-
if "P4TEST_IGNORE_STDERR" in line:
81+
if ignoreStderrDirective in line:
7982
return True
8083
return False
8184

@@ -210,9 +213,16 @@ def check_generated_files(options, tmpdir, expecteddir):
210213
' or rerun all tests using "P4TEST_REPLACE=True make check".' % expected
211214
)
212215
return FAILURE
213-
result = compare_files(options, produced, expected, file[-7:] == "-stderr")
214-
if result != SUCCESS and (file[-7:] != "-stderr" or not ignoreStderr(options)):
215-
return result
216+
is_stderr = file[-7:] == "-stderr"
217+
result = compare_files(options, produced, expected, is_stderr)
218+
if result != SUCCESS:
219+
if is_stderr and ignoreStderr(options):
220+
print(
221+
'(Ignoring stderr differences for file %s due to %s in sample file)'
222+
% (file, ignoreStderrDirective)
223+
)
224+
else:
225+
return result
216226
return SUCCESS
217227

218228

0 commit comments

Comments
 (0)