|
1 | | -from subprocess import Popen |
| 1 | +import subprocess |
2 | 2 |
|
3 | 3 |
|
4 | | -def spawn(cmd: str) -> Popen: |
5 | | - return Popen(cmd.split()) |
| 4 | +def uvx(*cmds: str): |
| 5 | + return subprocess.run(["uv", "run", *cmds], check=True) |
6 | 6 |
|
7 | 7 |
|
8 | | -def spawn_precommit() -> Popen: |
9 | | - return spawn("uv run pre-commit run --all-files") |
| 8 | +def precommit(): |
| 9 | + return uvx("pre-commit", "run", "--all-files") |
10 | 10 |
|
11 | 11 |
|
12 | | -def spawn_pytest() -> Popen: |
13 | | - return spawn("uv run pytest --cov=./ --cov-report=xml --cov-report=html -vv") |
| 12 | +def pytest(): |
| 13 | + return uvx("pytest", "--cov=./", "--cov-report=xml", "--cov-report=html", "-vv") |
14 | 14 |
|
15 | 15 |
|
| 16 | +def unasync(): |
| 17 | + return uvx("unasync", "supabase", "tests") |
| 18 | + |
| 19 | + |
| 20 | +def sed(before: str, after: str): |
| 21 | + return subprocess.run(["sed", "-i", "", before, after], check=True) |
| 22 | + |
| 23 | +def build_sync(): |
| 24 | + substs = [ |
| 25 | + ('s/asyncio.create_task(self.realtime.set_auth(access_token))//g', "supabase/_sync/client.py"), |
| 26 | + ('s/asynch/synch/g', "supabase/_sync/auth_client.py"), |
| 27 | + ('s/Async/Sync/g', "supabase/_sync/auth_client.py"), |
| 28 | + ('s/Async/Sync/g', "supabase/_sync/client.py"), |
| 29 | + ('s/create_async_client/create_client/g', "tests/_sync/test_client.py"), |
| 30 | + ('s/SyncClient/Client/gi', "tests/_sync/test_client.py"), |
| 31 | + ('s/SyncHTTPTransport/HTTPTransport/g', "tests/_sync/test_client.py"), |
| 32 | + ('s/SyncMock/Mock/g', "tests/_sync/test_client.py"), |
| 33 | + ] |
| 34 | + unasync() |
| 35 | + for (left, right) in substs: |
| 36 | + sed(left, right) |
| 37 | + |
16 | 38 | def run_tests(): |
17 | 39 | # Install requirements |
18 | | - with spawn_precommit() as precommit, spawn_pytest() as pytests: |
19 | | - pass # implicitly wait for all of them to return |
20 | | - return precommit.returncode and pytests.returncode |
| 40 | + precommit() |
| 41 | + pytest() |
0 commit comments