Skip to content

Commit 48e81c7

Browse files
committed
[tests] add utility to replace direct call to pytest.main
1 parent c216cbe commit 48e81c7

File tree

168 files changed

+381
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+381
-234
lines changed

python/tvm/testing/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def test_something():
6262
`TVM_TEST_TARGETS` environment variable in the CI.
6363
6464
"""
65+
import inspect
6566
import copy
6667
import copyreg
6768
import ctypes
@@ -1513,3 +1514,8 @@ def identity_after(x, sleep):
15131514
def terminate_self():
15141515
"""Testing function to terminate the process."""
15151516
sys.exit(-1)
1517+
1518+
1519+
def main():
1520+
test_file = inspect.getsourcefile(sys._getframe(1))
1521+
sys.exit(pytest.main([test_file] + sys.argv[1:]))

tests/micro/arduino/test_arduino_error_detection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from tvm.micro.project_api.server import ServerError
2222

2323
import test_utils
24+
import tvm.testing
2425

2526
# A new project and workspace dir is created for EVERY test
2627
@pytest.fixture
@@ -46,4 +47,4 @@ def test_bugged_project_compile_fails(workspace_dir, project):
4647

4748

4849
if __name__ == "__main__":
49-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
50+
tvm.testing.main()

tests/micro/arduino/test_arduino_rpc_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,6 @@ def test_tensors(sess):
367367

368368

369369
if __name__ == "__main__":
370-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
370+
import tvm.testing
371+
372+
tvm.testing.main()

tests/micro/arduino/test_arduino_workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,6 @@ def test_project_inference_runtime(serial_output):
218218

219219

220220
if __name__ == "__main__":
221-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
221+
import tvm.testing
222+
223+
tvm.testing.main()

tests/micro/common/test_tvmc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,6 @@ def test_tvmc_model_run(board, output_dir):
217217

218218

219219
if __name__ == "__main__":
220-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
220+
import tvm.testing
221+
222+
tvm.testing.main()

tests/micro/zephyr/test_zephyr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,6 @@ def test_autotune_conv2d(temp_dir, board, west_cmd, tvm_debug):
504504

505505

506506
if __name__ == "__main__":
507-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
507+
import tvm.testing
508+
509+
tvm.testing.main()

tests/micro/zephyr/test_zephyr_aot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ def test_qemu_make_fail(temp_dir, board, west_cmd, tvm_debug):
135135

136136

137137
if __name__ == "__main__":
138-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
138+
tvm.testing.main()

tests/micro/zephyr/test_zephyr_armv7m.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@ def test_armv7m_intrinsic(temp_dir, board, west_cmd, tvm_debug):
187187

188188

189189
if __name__ == "__main__":
190-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
190+
tvm.testing.main()

tests/python/ci/test_ci.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,4 +732,6 @@ def run(type, data, check):
732732

733733

734734
if __name__ == "__main__":
735-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
735+
import tvm.testing
736+
737+
tvm.testing.main()

tests/python/contrib/test_cmsisnn/test_binary_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,4 @@ def test_invalid_parameters(
275275

276276

277277
if __name__ == "__main__":
278-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
278+
tvm.testing.main()

0 commit comments

Comments
 (0)