Skip to content

test: comprehensive C++ unit testing and black-box CLI bash test suite#6

Merged
etcoder-642 merged 20 commits into
devfrom
test/all
Jul 1, 2026
Merged

test: comprehensive C++ unit testing and black-box CLI bash test suite#6
etcoder-642 merged 20 commits into
devfrom
test/all

Conversation

@etcoder-642

Copy link
Copy Markdown
Owner

Overview

This PR introduces a testing infrastructure to ensure the reliability and stability of flowhook. It covers low-level component validation via unit tests and end-to-end black-box verification of the CLI layer using native Bash scripting.

Changes Implemented

  1. Core Component Unit Tests (C++)

Wrote and updated comprehensive unit tests for the core structural elements of the engine:

FileWatcher: Verified inotify event handling.

TaskRunner: Validated process execution, on_success/on_failure branching logic, and child process signaling. Recursive file watching and management of the Task struct also happens here.

SessionLogger: Tested decoupled thread-safe logging and TUI/CLI output consistency.

ConfigManager: Ensured fault-tolerant JSON serialization/deserialization from the config.json file, dirty-state tracking (isflushed), and handling of edge-case sentinels (INT_MIN).

FlowHookCore: Validated the orchestrator layer, fixing critical initialization ordering bugs (handling path injection before scanning, resetting state guards, and stale path cleanup).

  1. Black-Box CLI Test Suite (Bash)
    Built a modular, isolated integration test suite from scratch using native Bash to verify UX correctness:

Isolation: Implemented FLOWHOOK_CONFIG_DIR_TEST environment overrides to prevent clobbering user configurations during execution.

Subcommand Coverage: Comprehensive test scripts (test_init.sh, test_add.sh, test_list.sh, test_remove.sh, test_set.sh, test_run.sh) covering all options, flag combinations, active/inactive toggles, duplicate entries, and forced removals (-f).

Harness (test_cli.sh): A unified orchestrator that exits with status code 1 on any failure, explicitly designed for continuous integration.

  1. CI/CD Integration
    Integrated the full CLI test harness into the GitHub Actions workflow (tests.yml).

Fixed CMake installation targets and binary renaming mechanics to guarantee reliable, clean compilation in remote environments.

Status: All 58+ integration tests and core unit tests are passing successfully on CI.

How to Manually Run Tests

# Run C++ unit tests
ctest --output-on-failure

# Run CLI black-box test suite
cd test/
./test_cli.sh

Update the CI trigger branches and the test runner command. Modify unit
tests to align with the updated Task schema and correct the JSON
configuration filename.
Split path management into separate file and directory paths, implement
idempotent path addition, and update CLI list command to display
resolved files. Update test runner configuration to include missing
test suites.
Standardize task identification by replacing task names with file paths
across the API. Update internal logic to ensure idempotency for task
activation and start operations.
- Added `set` CLI command to configure active status and watching depth.
- Updated core logic to persist task settings and validation.
- Enabled running tasks by active status.
- Cleaned up output formatting in list command.
- Removed unused `isRunning` property from task configuration.
- add tests to test the add, run, init and list subcommands
- refactored existing code to make the tests pass
- Added a `-f` flag to bypass the confirmation dialog when removing a
  task.
- Added a suite of unit tests for the remove command.
- Improved SIGINT handling in `test_run.sh` to ensure clean process
  cleanup.
Implement the `check` subcommand to verify task status (active/inactive)
and retrieve the watching depth for the current directory.
- Add `set` command support for --active, --deactive, and --depth
- Update FlowHookCore to manage task depth and activation status
- Normalize output streams to standard output across CLI commands
- Add unit tests for configuration persistence and validation
Run the project binary installation and execute the full suite of CLI
shell scripts.
Add missing install rule to CMakeLists and verify the binary path in CI.
Install the flowhook_cli executable and create a symlink or rename it to
flowhook in the bin directory to maintain legacy command support.
Automatically remove non-existent file and directory paths when
initializing a task instead of failing the process.
@etcoder-642 etcoder-642 merged commit 4e96565 into dev Jul 1, 2026
1 check passed
@etcoder-642 etcoder-642 deleted the test/all branch July 1, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant