@eu-cpsc/lecture-utils
v0.6.0
Published
CLI and libraries for executing commands and verifying their output against expected files.
Readme
Lecture Utilities
Various items to assist with lecture code repositories.
Executes a command and compares its output with the contents of a specified file.
For example:
lecture-utils -c "python tests/test1.py" -e "tests/test1.out"Development
Install dependencies:
npm installBuild:
npm run buildFor CLI:
./dist/cli.jsTest options
LectureItemTest supports two execution modes:
ioMode: "pipe"(default): existing spawn-with-pipes behaviorioMode: "pty": runs command in a pseudo-terminal usingnode-pty
PTY mode is opt-in and can be configured per test:
{
"cmd": "python cases/test4-pty.py",
"ioMode": "pty",
"stdin": "Ada Lovelace\n",
"pty": {
"cols": 80,
"rows": 24,
"env": { "TERM": "xterm-256color" },
"inputDelayMs": 0,
"stripAnsi": true,
"normalizeNewlines": true,
"timeoutMs": 2000
}
}Notes:
- PTY mode is opt-in; existing tests keep default pipe behavior.
- PTY output can vary across operating systems and shells.
- Interactive output/input interleaving is not guaranteed to be perfectly deterministic for all programs.
