Skip to content

Commit 1ef557c

Browse files
committed
Python: Address Copilot's comments
1 parent f5c3b63 commit 1ef557c

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

python/ql/test/library-tests/ControlFlow/evaluation-order/TimerUtils.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/**
22
* Utility library for identifying timer annotations in evaluation-order tests.
33
*
4-
* Identifies `expr @ t[n]` (matmul), `t(expr, n)` (call), and
5-
* `expr @ t.dead[n]` (dead-code) patterns, extracts timestamp values,
6-
* and provides predicates for traversing consecutive annotated CFG nodes.
4+
* Identifies `expr @ t[n]` (matmul) and `t(expr, n)` (call) patterns,
5+
* including `dead(n)` and `never` markers within subscripts, extracts
6+
* timestamp values, and provides predicates for traversing consecutive
7+
* annotated CFG nodes.
78
*/
89

910
import python

python/ql/test/library-tests/ControlFlow/evaluation-order/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
operands of binary operators, elements of collection literals, etc.)
66
77
Every evaluated expression has a timestamp annotation, except the
8-
timer mechanism itself (t[n], t.dead[n]).
8+
timer mechanism itself (t[n], t[dead(n)], t[never]).
99
"""
1010

1111
from timer import test, never

python/ql/test/library-tests/ControlFlow/evaluation-order/timer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_sequential(t):
2626
"""
2727

2828
import atexit
29+
import os
2930
import sys
3031

3132
_results = []
@@ -53,6 +54,10 @@ def __init__(self, timer, elements):
5354
self._dead.add(e.timestamp)
5455
elif isinstance(e, _NeverSentinel):
5556
self._never = True
57+
else:
58+
raise TypeError(
59+
f"Unknown element in timer subscript: {e!r} (type {type(e).__name__})"
60+
)
5661

5762
def __rmatmul__(self, value):
5863
ts = self._timer._tick()
@@ -183,7 +188,7 @@ def _report():
183188
print("---")
184189
print(f"{passed}/{total} tests passed")
185190
if passed < total:
186-
sys.exit(1)
191+
os._exit(1)
187192

188193

189194
atexit.register(_report)

0 commit comments

Comments
 (0)