Parse testcase.input into steps. Each command starts with a line starting with '$'. The first line (less '$') is sent to the shell. The remaining lines are expected output.
(input: list[str])
| 56 | |
| 57 | |
| 58 | def parse_script(input: list[str]) -> list[list[str]]: |
| 59 | """Parse testcase.input into steps. |
| 60 | |
| 61 | Each command starts with a line starting with '$'. |
| 62 | The first line (less '$') is sent to the shell. |
| 63 | The remaining lines are expected output. |
| 64 | """ |
| 65 | steps = [] |
| 66 | step: list[str] = [] |
| 67 | for line in input: |
| 68 | if line.startswith("$"): |
| 69 | if step: |
| 70 | assert step[0].startswith("$") |
| 71 | steps.append(step) |
| 72 | step = [] |
| 73 | step.append(line) |
| 74 | if step: |
| 75 | steps.append(step) |
| 76 | return steps |
| 77 | |
| 78 | |
| 79 | def run_cmd(input: str) -> tuple[int, str]: |
no test coverage detected
searching dependent graphs…