Skip to content

Commit 415d646

Browse files
Copilotev-br
andcommitted
Add ARRAY_API_TESTS_VERBOSE_SPECIAL_CASES environment variable
When ARRAY_API_TESTS_VERBOSE_SPECIAL_CASES=1 is set, the parser emits each special case line during parsing in the format: "SPEC_CASE: function_name: special_case_line" This allows real-time tracking of special cases during test runs with: ARRAY_API_TESTS_VERBOSE_SPECIAL_CASES=1 ARRAY_API_TESTS_MODULE=array_api_strict pytest array_api_tests/test_special_cases.py -s Changes: - Added _VERBOSE_SPECIAL_CASES flag based on environment variable - Modified parse_unary_case_block() to emit SPEC_CASE lines when enabled - Modified parse_binary_case_block() to emit SPEC_CASE lines when enabled Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
1 parent 710f52d commit 415d646

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

array_api_tests/test_special_cases.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import inspect
1616
import math
1717
import operator
18+
import os
1819
import re
1920
from dataclasses import dataclass, field
2021
from decimal import ROUND_HALF_EVEN, Decimal
@@ -35,6 +36,9 @@
3536
from . import xp, xps
3637
from .stubs import category_to_funcs
3738

39+
# Check if verbose special case logging is enabled
40+
_VERBOSE_SPECIAL_CASES = os.environ.get("ARRAY_API_TESTS_VERBOSE_SPECIAL_CASES") == "1"
41+
3842
UnaryCheck = Callable[[float], bool]
3943
BinaryCheck = Callable[[float, float], bool]
4044

@@ -879,6 +883,10 @@ def parse_unary_case_block(case_block: str, func_name: str, record_list: Optiona
879883
if record_list is not None:
880884
record_list.append(f"{func_name}: {case_str}.")
881885

886+
# Emit the special case line if verbose mode is enabled
887+
if _VERBOSE_SPECIAL_CASES:
888+
print(f"SPEC_CASE: {func_name}: {case_str}.")
889+
882890

883891
# Try to parse complex cases if we're in the complex section
884892
if in_complex_section and (m := r_complex_case.search(case_str)):
@@ -1386,6 +1394,10 @@ def parse_binary_case_block(case_block: str, func_name: str, record_list: Option
13861394
if record_list is not None:
13871395
record_list.append(f"{func_name}: {case_str}.")
13881396

1397+
# Emit the special case line if verbose mode is enabled
1398+
if _VERBOSE_SPECIAL_CASES:
1399+
print(f"SPEC_CASE: {func_name}: {case_str}.")
1400+
13891401
if r_redundant_case.search(case_str):
13901402
continue
13911403
if r_binary_case.match(case_str):

0 commit comments

Comments
 (0)