Move serve and asyncio tests to bazel (#6979)

This commit is contained in:
Simon Mo
2020-02-04 08:29:16 -08:00
committed by GitHub
parent 844f607c93
commit dd095c476a
6 changed files with 164 additions and 92 deletions
+28
View File
@@ -0,0 +1,28 @@
# This is a dummy test dependency that causes the above tests to be
# re-run if any of these files changes.
py_library(
name = "serve_lib",
srcs = glob(["**/*.py"], exclude=["tests/*.py"]),
)
# This test aggregates all serve tests and run them in a single session
# similar to `pytest .`
# Serve tests need to run in a single session because starting and stopping
# serve cluster take a large chunk of time. All serve tests use a shared
# cluster.
py_test(
name = "test_serve",
size = "medium",
srcs = glob(["tests/*.py"]),
tags = ["exclusive"],
deps = [":serve_lib"],
)
# Make sure the example showing in doc is tested
py_test(
name = "echo_full",
size = "small",
srcs = glob(["examples/*.py"]),
tags = ["exclusive"],
deps = [":serve_lib"]
)
@@ -0,0 +1,15 @@
import pytest
from pathlib import Path
import sys
if __name__ == "__main__":
curr_dir = Path(__file__).parent
test_paths = curr_dir.rglob("test_*.py")
sorted_path = sorted(map(lambda path: str(path.absolute()), test_paths))
serve_tests_files = list(sorted_path)
print("Testing the following files")
for test_file in serve_tests_files:
print("->", test_file.split("/")[-1])
sys.exit(pytest.main(["-v", "-s"] + serve_tests_files))