Skip to content

Commit 50e6fb1

Browse files
committed
chore: remove Makefile in favor of cli_scripts.py
this way we only have one way to run tests, and their dependencies are managed by uv itself.
1 parent 6703649 commit 50e6fb1

3 files changed

Lines changed: 33 additions & 38 deletions

File tree

Makefile

Lines changed: 0 additions & 27 deletions
This file was deleted.

cli_scripts.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1-
from subprocess import Popen
1+
import subprocess
22

33

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)
66

77

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")
1010

1111

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")
1414

1515

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+
1638
def run_tests():
1739
# 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()

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ dependencies = [
3131
]
3232

3333
[project.scripts]
34-
tests = 'cli_scripts:run_tests'
34+
tests = "cli_scripts:run_tests"
35+
build_sync = "cli_scripts:build_sync"
3536

3637
[dependency-groups]
3738
dev = [

0 commit comments

Comments
 (0)