Skip to main content

A powerful command line testing framework in Python with setup modules, parallel execution, and file comparison capabilities.

Project description

CLI Test Framework

A lightweight automated testing framework for command-line applications. Define test cases in JSON/YAML, run all validations with a single command.

Particularly suited for scientific computing — deep HDF5 support with regex table matching, data filtering, and tolerance-based comparison, making simulation result verification effortless.

Highlights

  • Parallel Execution — Multi-thread / multi-process, 3-5x speedup
  • Resource-Aware Scheduling — Automatic CPU core management, prevents solver thread runaway
  • Sequence Steps — Multi-step execution within a single test case, fail-fast
  • Setup Module — Auto-configure environment variables before tests, auto-cleanup after
  • File Comparison — Text / JSON / HDF5 / Binary, ready to use from command line
  • Filtered Execution — Run specific test cases by name

Quick Start

pip install cli-test-framework

30-Second Setup

  1. Create test_cases.json:
{
    "test_cases": [
        {
            "name": "hello",
            "command": "echo",
            "args": ["Hello World"],
            "expected": {
                "return_code": 0,
                "output_contains": ["Hello World"]
            }
        }
    ]
}
  1. Run:
cli-test run test_cases.json

Parallel Execution

cli-test run test_cases.json --parallel --workers 4

Python API

from cli_test_framework.runners import JSONRunner, ParallelJSONRunner

# Sequential
runner = JSONRunner(config_file="test_cases.json")
success = runner.run_tests()

# Parallel
runner = ParallelJSONRunner(config_file="test_cases.json", max_workers=4, execution_mode="thread")
success = runner.run_tests()

File Comparison

compare-files result1.h5 result2.h5 --h5-table-regex "output_.*" --h5-rtol 1e-5

📖 Full Documentation: docs/user_manual.md

Changelog

0.5.2

  • Runtime history tracking (--history-dir): persist per-case execution time in .symtest, enable smart scheduling & regression detection
  • Regression warning: alert when a case runs slower than historical average × threshold (--regression-threshold, default 1.5)
  • Smart scheduling: parallel runner prioritizes historical avg_duration over config estimated_time for task ordering
  • Per-case duration now shown in test result output

0.5.1

  • Run specific test cases by name (-t / test_case_filter)

0.5.0

  • Steps feature: sequential multi-command execution within a single test case, fail-fast

0.4.2

  • Resource-aware scheduling: auto-detect CPU cores, semaphore-based core allocation
  • Auto-inject OMP_NUM_THREADS / MKL_NUM_THREADS / NPROC to prevent solver thread runaway
  • Per-test timeout support to prevent hanging

0.4.1

  • Multi-thread / multi-process parallel execution, 3-5x speedup

Contributing

Before submitting a PR, please make sure all tests pass:

python tests\run_all.py

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli_test_framework-0.5.2.tar.gz (189.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_test_framework-0.5.2-py3-none-any.whl (60.1 kB view details)

Uploaded Python 3

File details

Details for the file cli_test_framework-0.5.2.tar.gz.

File metadata

  • Download URL: cli_test_framework-0.5.2.tar.gz
  • Upload date:
  • Size: 189.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for cli_test_framework-0.5.2.tar.gz
Algorithm Hash digest
SHA256 34457069f8e92080915d8534e6e173b815c2db9d86d60abab32191857e386e15
MD5 ab4d5b06ae7e52b8ee106930188ba41f
BLAKE2b-256 13a1f7b4344e3e695da5ac94ab775e45ec46074d0d1bb8c77c15fb8550e70aa2

See more details on using hashes here.

File details

Details for the file cli_test_framework-0.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for cli_test_framework-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 197d2c3ed37d605ca25ab7f17daea17967c6627052205b43ad85cff0e7e642c6
MD5 6f899f4b9b2dc20e8e7b2abbba157bf5
BLAKE2b-256 8f56da71adb7adc3f00a554cdf8e2a223626d445f6ebc0004270af7b07241e41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page