Skip to content

Commit abaa319

Browse files
committed
Split into scripts
1 parent 6585fc1 commit abaa319

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

scripts/smoke-test/__main__.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22
import pathlib
33
import subprocess
44
import sys
5+
from typing import Generator
56

67
SELF_FILE = pathlib.Path(__file__)
7-
COMMANDS_FILE = SELF_FILE.parent / "commands.sh"
88

99

10-
def read_commands() -> list[list[str]]:
11-
return [
12-
line.split()
13-
for line in COMMANDS_FILE.read_text().splitlines()
14-
# Skip empty lines and comments
15-
if line.strip() and not line.strip().startswith("#")
16-
]
10+
def find_test_scripts() -> Generator[pathlib.Path, None, None]:
11+
for child in SELF_FILE.parent.iterdir():
12+
if child.suffix == ".sh":
13+
yield child
1714

1815

19-
def run_command(command: list[str]) -> subprocess.CompletedProcess:
16+
def run_script(script: pathlib.Path) -> subprocess.CompletedProcess:
2017
env = os.environ.copy()
2118
# Prepend either the parent uv path to the PATH or the current directory
2219
env = {
@@ -27,12 +24,14 @@ def run_command(command: list[str]) -> subprocess.CompletedProcess:
2724
+ os.pathsep
2825
+ env.get("PATH"),
2926
}
30-
return subprocess.run(command, capture_output=True, text=True, env=env)
27+
return subprocess.run(
28+
["sh", str(script.absolute())], capture_output=True, text=True, env=env
29+
)
3130

3231

3332
def report_result(result: subprocess.CompletedProcess):
3433
print("=============================================")
35-
print(f"command: {' '.join(result.args)}")
34+
print(f"script: {result.args[-1].rsplit(os.path.sep, 1)[-1]}")
3635
print(f"exit code: {result.returncode}")
3736
print()
3837
print("------- stdout -------")
@@ -43,17 +42,17 @@ def report_result(result: subprocess.CompletedProcess):
4342

4443

4544
def main():
46-
results = [run_command(command) for command in read_commands()]
45+
results = [run_script(script) for script in find_test_scripts()]
4746
failed = sum(result.returncode != 0 for result in results)
4847
for result in results:
4948
report_result(result)
5049

5150
print("=============================================")
5251
if failed:
53-
print(f"FAILURE - {failed}/{len(results)} commands failed")
52+
print(f"FAILURE - {failed}/{len(results)} scripts failed")
5453
sys.exit(1)
5554
else:
56-
print(f"SUCCESS - {len(results)}/{len(results)} commands succeeded")
55+
print(f"SUCCESS - {len(results)}/{len(results)} scripts succeeded")
5756

5857

5958
main()

scripts/smoke-test/commands.sh

-7
This file was deleted.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Install a package via `uv pip`
2+
set -ex
3+
4+
uv venv -v
5+
uv pip install ruff -v
6+

scripts/smoke-test/uvx-ruff.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Run `ruff` via `uvx`
2+
set -ex
3+
4+
uvx -v ruff --version

0 commit comments

Comments
 (0)