Skip to content

test: add --program option #794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions auto_editor/cmds/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
class TestArgs:
only: list[str] = field(default_factory=list)
help: bool = False
program: bool = False
no_fail_fast: bool = False
category: str = "cli"


def test_options(parser: ArgumentParser) -> ArgumentParser:
parser.add_argument("--only", "-n", nargs="*")
parser.add_argument("--no-fail-fast", flag=True)
parser.add_argument("--program", flag=True)
parser.add_required(
"category",
nargs=1,
Expand Down Expand Up @@ -79,8 +81,11 @@ class SkipTest(Exception):


class Runner:
def __init__(self) -> None:
self.program = [sys.executable, "-m", "auto_editor"]
def __init__(self, is_program: bool) -> None:
if is_program:
self.program = ["./auto-editor"]
else:
self.program = [sys.executable, "-m", "auto_editor"]
self.temp_dir = mkdtemp()

def main(self, inputs: list[str], cmd: list[str], output: str | None = None) -> str:
Expand Down Expand Up @@ -776,7 +781,7 @@ def main(sys_args: list[str] | None = None) -> None:
sys_args = sys.argv[1:]

args = test_options(ArgumentParser("test")).parse_args(TestArgs, sys_args)
run = Runner()
run = Runner(args.program)
tests = []

test_methods = {
Expand All @@ -785,7 +790,7 @@ def main(sys_args: list[str] | None = None) -> None:
if callable(getattr(Runner, name)) and name not in ["main", "raw", "check"]
}

if args.category in {"palet", "all"}:
if not args.program and args.category in {"palet", "all"}:
tests.extend(
[test_methods[name] for name in ["palet_python_bridge", "palet_scripts"]]
)
Expand Down
Loading