Skip to content

Commit d70f300

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

File tree

169 files changed

+265
-254
lines changed

Some content is hidden

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

169 files changed

+265
-254
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import pytest
3030

3131
import tvm
32+
import tvm.testing
3233
from PIL import Image
3334
from tvm import relay
3435
from tvm.relay.testing import byoc
@@ -367,4 +368,4 @@ def test_tensors(sess):
367368

368369

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

tests/micro/arduino/test_arduino_workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import sys
2222
import pytest
2323

24+
import tvm.testing
25+
2426
import test_utils
2527

2628
"""
@@ -218,4 +220,4 @@ def test_project_inference_runtime(serial_output):
218220

219221

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

tests/micro/common/test_tvmc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import shutil
2727

2828
import tvm
29+
import tvm.testing
2930
from tvm.contrib.download import download_testdata
3031

3132
from ..zephyr.test_utils import ZEPHYR_BOARDS
@@ -217,4 +218,4 @@ def test_tvmc_model_run(board, output_dir):
217218

218219

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

tests/micro/zephyr/test_zephyr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from PIL import Image
2727

2828
import tvm
29+
import tvm.testing
2930
import tvm.relay as relay
3031
from tvm.relay.backend import Executor, Runtime
3132
from tvm.relay.testing import byoc
@@ -504,4 +505,4 @@ def test_autotune_conv2d(temp_dir, board, west_cmd, tvm_debug):
504505

505506

506507
if __name__ == "__main__":
507-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
508+
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import json
2121
import textwrap
2222
import pytest
23+
import tvm.testing
2324

2425
from test_utils import REPO_ROOT
2526

@@ -732,4 +733,4 @@ def run(type, data, check):
732733

733734

734735
if __name__ == "__main__":
735-
sys.exit(pytest.main([__file__] + sys.argv[1:]))
736+
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)