Skip to content

Commit

Permalink
Calling pytest from python code since skip list too long
Browse files Browse the repository at this point in the history
Signed-off-by: Cheng Penghui <[email protected]>
  • Loading branch information
PenghuiCheng committed Nov 5, 2024
1 parent f224138 commit ef07d17
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
9 changes: 4 additions & 5 deletions test/xpu/extended/run_test_with_skip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pytest
import sys
from skip_list_common import skip_dict
from skip_list_win import skip_dict as skip_dict_win
Expand All @@ -9,14 +10,12 @@
if IS_WINDOWS:
skip_list += skip_dict_win["test_ops_xpu.py"]

skip_options = " -k \"not " + skip_list[0]
skip_options = "not " + skip_list[0]
for skip_case in skip_list[1:]:
skip_option = " and not " + skip_case
skip_options += skip_option
skip_options += "\""

os.environ["PYTORCH_TEST_WITH_SLOW"]="1"
test_command = "pytest -v test_ops_xpu.py"
test_command += skip_options
res = os.system(test_command)
test_command = ["-k", skip_options, "test_ops_xpu.py", "-v"]
res = pytest.main(test_command)
sys.exit(res)
9 changes: 4 additions & 5 deletions test/xpu/extended/run_test_with_skip_arc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pytest
import sys
from skip_list_common import skip_dict
from skip_list_arc import skip_dict as skip_dict_specifical
Expand All @@ -11,14 +12,12 @@
if IS_WINDOWS:
skip_list += skip_dict_win["test_ops_xpu.py"] + skip_dict_win_arc["test_ops_xpu.py"]

skip_options = " -k \"not " + skip_list[0]
skip_options = "not " + skip_list[0]
for skip_case in skip_list[1:]:
skip_option = " and not " + skip_case
skip_options += skip_option
skip_options += "\""

os.environ["PYTORCH_TEST_WITH_SLOW"]="1"
test_command = "pytest -v test_ops_xpu.py"
test_command += skip_options
res = os.system(test_command)
test_command = ["-k", skip_options, "test_ops_xpu.py", "-v"]
res = pytest.main(test_command)
sys.exit(res)
26 changes: 7 additions & 19 deletions test/xpu/xpu_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import copy
import os
import pytest
import sys
import unittest

Expand Down Expand Up @@ -1019,30 +1020,17 @@ def launch_test(test_case, skip_list=None, exe_list=None):
os.environ["PYTORCH_ENABLE_XPU_FALLBACK"]="1"
os.environ["PYTORCH_TEST_WITH_SLOW"]="1"
if skip_list != None:
skip_options = " -k \"not " + skip_list[0]
skip_options = "not " + skip_list[0]
for skip_case in skip_list[1:]:
skip_option = " and not " + skip_case
skip_options += skip_option
skip_options += "\""
test_command = (
"pytest -v "
+ test_case
)
test_command += skip_options
test_command = ["-k", skip_options, test_case, "-v"]
elif exe_list != None:
exe_options = " -k \"" + exe_list[0]
exe_options = exe_list[0]
for exe_case in exe_list[1:]:
exe_option = " or " + exe_case
exe_options += exe_option
exe_options += "\""
test_command = (
"pytest -v "
+ test_case
)
test_command += exe_options
test_command = ["-k", exe_options, test_case, "-v"]
else:
test_command = (
"pytest -v "
+ test_case
)
return os.system(test_command)
test_command = [test_case, "-v"]
return pytest.main(test_command)

0 comments on commit ef07d17

Please sign in to comment.