Skip to content

Commit 81a1d95

Browse files
authored
chore: remove shell flag usage in project scripts (#538)
* remove shell flag usage in project scripts Signed-off-by: gruebel <anton.gruebel@gmail.com> * adjust copy command Signed-off-by: gruebel <anton.gruebel@gmail.com> --------- Signed-off-by: gruebel <anton.gruebel@gmail.com>
1 parent 74409bf commit 81a1d95

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

scripts/scripts.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
# ruff: noqa: S602, S607
1+
# ruff: noqa: S607
2+
import shutil
23
import subprocess
4+
from pathlib import Path
35

46

57
def test():
68
"""Run pytest tests."""
7-
subprocess.run("pytest tests", shell=True, check=True)
9+
subprocess.run(["pytest", "tests"], check=True)
810

911

1012
def test_cov():
1113
"""Run tests with coverage."""
12-
subprocess.run("coverage run -m pytest tests", shell=True, check=True)
14+
subprocess.run(["coverage", "run", "-m", "pytest", "tests"], check=True)
1315

1416

1517
def cov_report():
1618
"""Generate coverage report."""
17-
subprocess.run("coverage xml", shell=True, check=True)
19+
subprocess.run(["coverage", "xml"], check=True)
1820

1921

2022
def cov():
@@ -25,14 +27,21 @@ def cov():
2527

2628
def e2e():
2729
"""Run end-to-end tests."""
28-
subprocess.run("git submodule update --init --recursive", shell=True, check=True)
29-
subprocess.run(
30-
"cp spec/specification/assets/gherkin/* tests/features/", shell=True, check=True
31-
)
32-
subprocess.run("behave tests/features/", shell=True, check=True)
33-
subprocess.run("rm tests/features/*.feature", shell=True, check=True)
30+
source_dir = Path("spec/specification/assets/gherkin")
31+
dest_dir = Path("tests/features")
32+
33+
subprocess.run(["git", "submodule", "update", "--init", "--recursive"], check=True)
34+
35+
for file in source_dir.glob("*"):
36+
if file.is_file():
37+
shutil.copy(file, dest_dir)
38+
39+
subprocess.run(["behave", "tests/features/"], check=True)
40+
41+
for feature_file in dest_dir.glob("*.feature"):
42+
feature_file.unlink()
3443

3544

3645
def precommit():
3746
"""Run pre-commit hooks."""
38-
subprocess.run("uv run pre-commit run --all-files", shell=True, check=True)
47+
subprocess.run(["uv", "run", "pre-commit", "run", "--all-files"], check=True)

0 commit comments

Comments
 (0)