Skip to content

Commit

Permalink
[2.5][Windows] minor changes to support testing on windows (#854)
Browse files Browse the repository at this point in the history
cherry-pick #790

---------

Co-authored-by: sandeep.polisetty@intel.com <sandeep.polisetty@intel.com>
  • Loading branch information
min-jean-cho and poliset1 authored Aug 31, 2024
1 parent c77e902 commit de0c7cb
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 42 deletions.
12 changes: 6 additions & 6 deletions test/xpu/extended/run_test_with_skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@
)


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

test_command = "PYTORCH_TEST_WITH_SLOW=1 pytest -v test_ops_xpu.py"
test_command += 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)
exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
sys.exit(res)
34 changes: 14 additions & 20 deletions test/xpu/run_test_with_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,26 @@


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 = " -k \"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 = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
+ test_case
)
test_command += skip_options
skip_options += "\""
test_command = "pytest -v " + test_case + skip_options
return os.system(test_command)
elif exe_list != None:
exe_options = " -k '" + exe_list[0]
exe_options = " -k \"" + exe_list[0]
for exe_case in exe_list[1:]:
exe_option = " or " + exe_case
exe_options += exe_option
exe_options += "'"
test_command = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
+ test_case
)
test_command += exe_options
exe_options += "\""
test_command = "pytest -v " + test_case + exe_options
return os.system(test_command)
else:
test_command = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
+ test_case
)
test_command = "pytest -v "
return os.system(test_command)


Expand All @@ -51,5 +42,8 @@ def launch_test(test_case, skip_list=None, exe_list=None):
)
res += launch_test("test_decomp_xpu.py", exe_list=execute_list)

exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
if os.name == "nt":
sys.exit(res)
else:
exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
8 changes: 6 additions & 2 deletions test/xpu/run_test_with_skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
skip_list = skip_dict[key]
res += launch_test(key, skip_list)

exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)

if os.name == "nt":
sys.exit(res)
else:
exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
7 changes: 5 additions & 2 deletions test/xpu/run_test_with_skip_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
skip_list += skip_dict_win[key]
res += launch_test(key, skip_list)

exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
if os.name == "nt":
sys.exit(res)
else:
exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
7 changes: 5 additions & 2 deletions test/xpu/run_test_with_skip_mtl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
skip_list += skip_dict_win[key]
res += launch_test(key, skip_list)

exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
if os.name == "nt":
sys.exit(res)
else:
exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
20 changes: 10 additions & 10 deletions test/xpu/xpu_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,33 +956,33 @@ def copy_tests(


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 = " -k \"not " + skip_list[0]
for skip_case in skip_list[1:]:
skip_option = " and not " + skip_case
skip_options += skip_option
skip_options += "'"
skip_options += "\""
test_command = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
"pytest -v "
+ test_case
)
test_command += skip_options
return os.system(test_command)
elif exe_list != None:
exe_options = " -k '" + exe_list[0]
exe_options = " -k \"" + exe_list[0]
for exe_case in exe_list[1:]:
exe_option = " or " + exe_case
exe_options += exe_option
exe_options += "'"
exe_options += "\""
test_command = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
"pytest -v "
+ test_case
)
test_command += exe_options
return os.system(test_command)
else:
test_command = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
"pytest -v "
+ test_case
)
return os.system(test_command)
return os.system(test_command)

0 comments on commit de0c7cb

Please sign in to comment.