Skip to content

Commit ca41911

Browse files
committed
Allow hiding warning WXXX codes
Useful for not having to change tests everytime the warning code is updated
1 parent 41630d6 commit ca41911

5 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/api/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def init():
7070
OPTIONS.add_option('zxnext', bool, False) # True to enable ZX Next ASM opcodes
7171
OPTIONS.add_option('architecture', str, None) # Architecture
7272
OPTIONS.add_option('expect_warnings', int, 0) # Expected Warnings that will be silenced
73+
OPTIONS.add_option('hide_warning_codes', bool, False) # Whether to show WXXX warning codes or not
7374

7475

7576
init()

src/api/errmsg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def decorator(func: Callable) -> Callable:
104104
def wrapper(*args, **kwargs):
105105
global WARNING_PREFIX
106106
if global_.ENABLED_WARNINGS.get(code, True):
107-
WARNING_PREFIX = f'warning: [W{code}]'
107+
if not OPTIONS.hide_warning_codes:
108+
WARNING_PREFIX = f'warning: [W{code}]'
108109
func(*args, **kwargs)
109110
WARNING_PREFIX = ''
110111

src/libzxbc/args_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,6 @@ def parser() -> argparse.ArgumentParser:
9696
help='Disables warning WXXX (i.e. -W100 disables warning with code W100)')
9797
parser_.add_argument('+W', '--enable-warning', type=parse_warning_option, action='append',
9898
help='Disables warning WXXX (i.e. -W100 disables warning with code W100)')
99+
parser_.add_argument('--hide-warning-codes', action='store_true',
100+
help='Hides WXXX codes')
99101
return parser_

src/libzxbc/zxbc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def main(args=None, emitter=None):
108108
OPTIONS.headerless = options.headerless
109109
OPTIONS.zxnext = options.zxnext
110110
OPTIONS.expect_warnings = gl.EXPECTED_WARNINGS = options.expect_warnings
111+
OPTIONS.hide_warning_codes = options.hide_warning_codes
111112

112113
if options.arch not in arch.AVAILABLE_ARCHITECTURES:
113114
parser.error(f"Invalid architecture '{options.arch}'")

tests/symbols/test_symbolTYPECAST.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def setUp(self):
2323
if 'stderr' in OPTIONS:
2424
del OPTIONS.stderr
2525
OPTIONS.add_option('stderr', type_=None, default_value=StringIO())
26+
OPTIONS.hide_warning_codes = True
2627

2728
def test_operand(self):
2829
self.assertEqual(self.t.operand, 3)

0 commit comments

Comments
 (0)