simplefe

Log | Files | Refs

commit c7dc80d87532774b6e9f62ad0de8a70b2859cf21
parent 8daba43d772530360f9eea4b8e35a9caf2490c5c
Author: Chris Roberts <chris.roberts@learningunix.net>
Date:   Thu, 16 Jul 2026 18:54:16 -0500

Add pexpect-based job runner, proven against a fake fixture

run_job() spawns a command, waits for a known prompt, sends a
response, then waits for the process to finish and returns its
output. Tested against tests/fixtures/fake_job.py rather than
the real .scripts/rip, since rip needs real hardware and isn't
part of this repo (see .gitignore).

Diffstat:
Asrc/simplefe/runner.py | 9+++++++++
Atests/fixtures/fake_job.py | 2++
Atests/test_runner.py | 11+++++++++++
3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/simplefe/runner.py b/src/simplefe/runner.py @@ -0,0 +1,9 @@ +import pexpect + + +def run_job(command, prompt, response): + child = pexpect.spawn(command) + child.expect(prompt) + child.sendline(response) + child.expect(pexpect.EOF) + return child.before diff --git a/tests/fixtures/fake_job.py b/tests/fixtures/fake_job.py @@ -0,0 +1,2 @@ +name = input("Enter movie name: ") +print(f"Got: {name}") diff --git a/tests/test_runner.py b/tests/test_runner.py @@ -0,0 +1,11 @@ +from pathlib import Path + +from simplefe.runner import run_job + +FIXTURES = Path(__file__).parent / "fixtures" + + +def test_run_job(): + fake_job = FIXTURES / "fake_job.py" + result = run_job(f"python3 {fake_job}", "Enter movie name:", "The Matrix") + assert b"Got: The Matrix" in result