test: add ptyunit test suite (CLI + PTY/TUI)#1
Open
fissible wants to merge 1 commit intoflathead:masterfrom
Open
test: add ptyunit test suite (CLI + PTY/TUI)#1fissible wants to merge 1 commit intoflathead:masterfrom
fissible wants to merge 1 commit intoflathead:masterfrom
Conversation
Adds tests/ptyunit as a git submodule (fissible/ptyunit) and a test suite covering both the CLI and interactive TUI. Unit tests (tests/unit/test-cli.sh): - Password length, character set, and quiet/verbose output - DB-safe charset constraints - First-character invariant (never - or .) - Flag conflict: -d vs -s ordering bug - Error handling: missing -l value, out-of-range lengths, unknown flags Integration/PTY tests (tests/integration/test-tui.sh): - TUI renders all expected labels and hotkeys - Key handling: r, Enter, Space, +, -, numeric presets - DB-safe mode toggle (R key) - History navigation (< and > keys, position display) - Help screen (? key, dismiss and return) Run with: bash tests/run.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a test suite using ptyunit, a bash test framework that can drive interactive terminal UIs via a real pseudoterminal — making it possible to test both the CLI flags and the interactive TUI.
ptyunit is added as a git submodule at
tests/ptyunit. To run the tests:What's covered
Unit tests (
tests/unit/test-cli.sh) — CLI flag mode:-nno-newline--simple,--db-safe-or.-dand-s-lvalue, out-of-range lengths, unknown flagsIntegration tests (
tests/integration/test-tui.sh) — interactive TUI:r, Enter, Space,+,-, numeric presets (1–8)Rkey)</>keys, position counter)?key, dismiss and return)Bugs the tests catch
A few bugs surface when the tests run — leaving them for discussion rather than fixing here, since the fixes are straightforward but warrant a separate commit:
-lwithout a value causes ashift 2crash underset -euo pipefailinstead of a clean error message-d -sflag ordering — the last flag wins, sopassgen -d -sproduces an alphanumeric-only password labeled "DB-safe"HISTORY[-1]requires bash 4.3+ (negative array indices); fails silently on 4.0–4.2Tests written with ptyunit — a bash testing framework with built-in PTY/TUI support, mocking, and parameterized tests.