Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor changes to support testing on windows #790

Merged
merged 10 commits into from
Aug 31, 2024
Merged
23 changes: 15 additions & 8 deletions test/xpu/extended/run_test_with_skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,22 @@
)


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

res = os.system(test_command)
exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
if os.name == "nt":
test_command = "pytest -v test_ops_xpu.py"
test_command += skip_options
print("running", test_command)
min-jean-cho marked this conversation as resolved.
Show resolved Hide resolved
res = os.system(test_command)
# fixme: exit code does not match
sys.exit(res)
else:
test_command = "PYTORCH_TEST_WITH_SLOW=1 && pytest -v test_ops_xpu.py"
test_command += skip_options
res = os.system(test_command)
exit_code = os.WEXITSTATUS(res)
sys.exit(exit_code)
67 changes: 44 additions & 23 deletions test/xpu/run_test_with_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,53 @@

def launch_test(test_case, skip_list=None, exe_list=None):
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
return os.system(test_command)
skip_options += "\""
if os.name == "nt":
min-jean-cho marked this conversation as resolved.
Show resolved Hide resolved
os.system('set PYTORCH_ENABLE_XPU_FALLBACK=1 ')
os.system('set PYTORCH_TEST_WITH_SLOW=1 ')
test_command = "pytest -v " + test_case + skip_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 += 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
return os.system(test_command)
exe_options += "\""
if os.name == "nt":
os.system('set PYTORCH_ENABLE_XPU_FALLBACK=1 ')
os.system('set PYTORCH_TEST_WITH_SLOW=1 ')
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 += exe_options
return os.system(test_command)
else:
test_command = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
+ test_case
)
return os.system(test_command)
if os.name == "nt":
os.system('set PYTORCH_ENABLE_XPU_FALLBACK=1 ')
os.system('set PYTORCH_TEST_WITH_SLOW=1 ')
test_command = "pytest -v "
return os.system(test_command)
else:
test_command = (
"PYTORCH_ENABLE_XPU_FALLBACK=1 PYTORCH_TEST_WITH_SLOW=1 pytest -v "
+ test_case
)
return os.system(test_command)


res = 0
Expand All @@ -51,5 +69,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)
Loading