This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 0941969d9e Fixes some test errors from previous commits (#12345)
0941969d9e is described below
commit 0941969d9e5ea8bb9acccb424e8df90c2940fb12
Author: Leif Hedstrom <[email protected]>
AuthorDate: Wed Jul 9 17:47:37 2025 -0500
Fixes some test errors from previous commits (#12345)
---
tools/hrw4u/scripts/hrw4u | 9 ++++++---
tools/hrw4u/src/errors.py | 2 +-
tools/hrw4u/tests/data/conds/cookie.ast.txt | 2 +-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/hrw4u/scripts/hrw4u b/tools/hrw4u/scripts/hrw4u
index a2b5e42ad7..edb1f25242 100755
--- a/tools/hrw4u/scripts/hrw4u
+++ b/tools/hrw4u/scripts/hrw4u
@@ -50,7 +50,10 @@ def main():
input_content = args.input_file.read()
if args.input_file is not sys.stdin:
+ filename = args.input_file.name
args.input_file.close()
+ else:
+ filename = "<stdin>"
if not (args.ast or args.hrw):
args.hrw = True
@@ -59,12 +62,12 @@ def main():
lexer = hrw4uLexer(input_stream)
lexer.removeErrorListeners()
- lexer.addErrorListener(ThrowingErrorListener(filename=args.input_file))
+ lexer.addErrorListener(ThrowingErrorListener(filename=filename))
token_stream = CommonTokenStream(lexer)
parser_obj = hrw4uParser(token_stream)
parser_obj.removeErrorListeners()
-
parser_obj.addErrorListener(ThrowingErrorListener(filename=args.input_file))
+ parser_obj.addErrorListener(ThrowingErrorListener(filename=filename))
parser_obj.errorHandler = BailErrorStrategy()
try:
@@ -77,7 +80,7 @@ def main():
if args.ast:
print(tree.toStringTree(recog=parser_obj))
else:
- visitor = HRW4UVisitor(filename=args.input_file, debug=args.debug)
+ visitor = HRW4UVisitor(filename=filename, debug=args.debug)
try:
result = visitor.visit(tree)
print("\n".join(result))
diff --git a/tools/hrw4u/src/errors.py b/tools/hrw4u/src/errors.py
index e9e8b7e84c..34f4a1b860 100644
--- a/tools/hrw4u/src/errors.py
+++ b/tools/hrw4u/src/errors.py
@@ -48,7 +48,7 @@ class Hrw4uSyntaxError(Exception):
super().__init__(self._format_error(filename, line, column, message,
source_line))
def _format_error(self, filename, line, col, message, source_line):
- error = f"{filename.name}:{line}:{col}: error: {message}"
+ error = f"{filename}:{line}:{col}: error: {message}"
lineno = f"{line:4d}"
code_line = f"{lineno} | {source_line}"
diff --git a/tools/hrw4u/tests/data/conds/cookie.ast.txt
b/tools/hrw4u/tests/data/conds/cookie.ast.txt
index 0d21b9355c..78d89562b2 100644
--- a/tools/hrw4u/tests/data/conds/cookie.ast.txt
+++ b/tools/hrw4u/tests/data/conds/cookie.ast.txt
@@ -1 +1 @@
-(program (section REMAP { (conditional (ifStatement if (condition (expression
(term (factor (comparison (comparable inbound.cookie.bar) ~ (regex /bar/))))))
(block { (statement inbound.cookie.mybar = (value "1") ;) }))) }) (section
SEND_RESPONSE { (conditional (ifStatement if (condition (expression (term
(factor ! (factor inbound.cookie.bar))))) (block { (statement
inbound.cookie.mybar = (value "1") ;) }))) }) <EOF>)
+(program (section REMAP { (sectionBody (conditional (ifStatement if (condition
(expression (term (factor (comparison (comparable inbound.cookie.bar) ~ (regex
/bar/)))))) (block { (statement inbound.cookie.mybar = (value "1") ;) })))) })
(section SEND_RESPONSE { (sectionBody (conditional (ifStatement if (condition
(expression (term (factor ! (factor inbound.cookie.bar))))) (block { (statement
inbound.cookie.mybar = (value "1") ;) })))) }) <EOF>)