@@ -47,7 +47,17 @@ def pytest_addoption(parser):
47
47
parser .addoption (
48
48
"--ci" ,
49
49
action = "store_true" ,
50
- help = "run just the tests appropiate for CI" ,
50
+ help = "run just the tests appropriate for CI" ,
51
+ )
52
+ parser .addoption (
53
+ "--skips-file" ,
54
+ action = "store" ,
55
+ help = "file with tests to skip. Defaults to skips.txt"
56
+ )
57
+ parser .addoption (
58
+ "--xfails-file" ,
59
+ action = "store" ,
60
+ help = "file with tests to skip. Defaults to xfails.txt"
51
61
)
52
62
53
63
@@ -82,26 +92,49 @@ def xp_has_ext(ext: str) -> bool:
82
92
return False
83
93
84
94
85
- skip_ids = []
86
- skips_path = Path (__file__ ).parent / "skips.txt"
87
- if skips_path .exists ():
88
- with open (skips_path ) as f :
89
- for line in f :
90
- if line .startswith ("array_api_tests" ):
91
- id_ = line .strip ("\n " )
92
- skip_ids .append (id_ )
95
+ def pytest_collection_modifyitems (config , items ):
96
+ skips_file = skips_path = config .getoption ('--skips-file' )
97
+ if skips_file is None :
98
+ skips_file = Path (__file__ ).parent / "skips.txt"
99
+ if skips_file .exists ():
100
+ skips_path = skips_file
93
101
102
+ skip_ids = []
103
+ if skips_path :
104
+ with open (skips_path ) as f :
105
+ for line in f :
106
+ if line .startswith ("array_api_tests" ):
107
+ id_ = line .strip ("\n " )
108
+ skip_ids .append (id_ )
109
+
110
+ xfails_file = xfails_path = config .getoption ('--xfails-file' )
111
+ if xfails_file is None :
112
+ xfails_file = Path (__file__ ).parent / "xfails.txt"
113
+ if xfails_file .exists ():
114
+ xfails_path = xfails_file
115
+
116
+ xfail_ids = []
117
+ if xfails_path :
118
+ with open (xfails_path ) as f :
119
+ for line in f :
120
+ if line .startswith ("array_api_tests" ):
121
+ id_ = line .strip ("\n " )
122
+ xfail_ids .append (id_ )
94
123
95
- def pytest_collection_modifyitems (config , items ):
96
124
disabled_exts = config .getoption ("--disable-extension" )
97
125
disabled_dds = config .getoption ("--disable-data-dependent-shapes" )
98
126
ci = config .getoption ("--ci" )
99
127
for item in items :
100
128
markers = list (item .iter_markers ())
101
- # skip if specified in skips.txt
129
+ # skip if specified in skips file
102
130
for id_ in skip_ids :
103
131
if item .nodeid .startswith (id_ ):
104
- item .add_marker (mark .skip (reason = "skips.txt" ))
132
+ item .add_marker (mark .skip (reason = "skips file" ))
133
+ break
134
+ # xfail if specified in xfails file
135
+ for id_ in xfail_ids :
136
+ if item .nodeid .startswith (id_ ):
137
+ item .add_marker (mark .xfails (reason = "xfails file" ))
105
138
break
106
139
# skip if disabled or non-existent extension
107
140
ext_mark = next ((m for m in markers if m .name == "xp_extension" ), None )
0 commit comments