test-cmd


Nametest-cmd JSON
Version 2.0.6 PyPI version JSON
download
home_pagehttps://github.com/arjun-menon/test_cmd
SummaryTool for black-box testing command-line programs using STDIN, STDOUT and STDERR, with multiple CPUs
upload_time2023-09-26 15:52:52
maintainer
docs_urlNone
authorArjun G. Menon
requires_python
licenseApache-2.0
keywords command line terminal functional black box testing arguments stdin stdout stderr
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            test_cmd |pypi|
===============
This is a tool for black-box testing command-line programs simply based on STDIN, STDOUT, and STDERR, **with multiple
CPUs**. A sempahore keeps track of which CPUs are in use; and thus, tests are run in parallel on all CPUs, and new test
runs are dispatched as tests complete (or fail). ``test_cmd`` waits until all tests have completed (either successfully
or failed), and prints failed tests' ``STDERR`` output, as they fail, in real time.

Tutorial
--------
Test cases usually consist of pairs of input and output files, as well as an optional ``tests.json`` file specifying applicable command-line arguments.  The input file is piped in via ``STDIN``. If the command being tested emits the expected output file via ``STDOUT``, the test case passes. A file representing an expected ``STDERR`` output can also optionally be specified.

The input/output file pairs must follow this naming pattern::

  test-A.in.txt  ->  test-A.out.txt
  test-B.in.txt  ->  test-B.out.txt, test-B.err.txt
  test-C.in.txt  ->  test-C.out.txt

The file extension (``.txt`` here) can be anything. The file naming pattern is ``*.in*`` for input files, ``*.out*`` for expected output files, and ``*.err*`` for expected error files. The content of the ``*.in.*`` file is piped to the command being tested, and its ``STDOUT`` is compared against the ``*.out*`` file. If a ``*.err.*`` file has been provided, then the command ``STDERR`` is matched against it as well.

For an example of test_cmd in action, see the `pypage project <https://github.com/arjun-menon/pypage>`_, particularly its `tests folder <https://github.com/arjun-menon/pypage/tree/master/tests>`_.

Usage
*****
::

    usage: test_cmd.py [-h] [-b] [-d] [-u] [-t] tests_dir cmd ...

    Functional Testing Utility for Command-Line Applications

    positional arguments:
      tests_dir      Path to the directory containing test cases
      cmd            Path to the command to be tested
      args           The command-line arguments with an ampersand character '@' markingwhere arguments from test.json should be injected

    options:
      -h, --help     show this help message and exit
      -b, --bw       black & white output
      -d, --diff     diff output
      -u, --to-unix  convert CR+LF to LF in cmd output and test files
      -t, --rtrim    ignore trailing whitespaces at the end of each line as well as trailing newlines

Command-line arguments for test cases can be specified by creating a special file named ``tests.json``, and placing it in the directory containing your test cases. This ``tests.json`` file maps test cases to objects representing command-line arguments for that test case. If a command-line argument is a non-string value (e.g. a complex JavaScript object), the argument is stringified (with Python's ``json.dumps``), and passed in as JSON.

.. |pypi| image:: https://badge.fury.io/py/test_cmd.svg
   :target: https://pypi.python.org/pypi/test_cmd

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/arjun-menon/test_cmd",
    "name": "test-cmd",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "command line terminal functional black box testing arguments stdin stdout stderr",
    "author": "Arjun G. Menon",
    "author_email": "contact@arjungmenon.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/7a/cefe5c04af32bd8b2f64fa5353b8ade65076b3262a9c82cd8d4a51c7697d/test_cmd-2.0.6.tar.gz",
    "platform": null,
    "description": "test_cmd |pypi|\n===============\nThis is a tool for black-box testing command-line programs simply based on STDIN, STDOUT, and STDERR, **with multiple\nCPUs**. A sempahore keeps track of which CPUs are in use; and thus, tests are run in parallel on all CPUs, and new test\nruns are dispatched as tests complete (or fail). ``test_cmd`` waits until all tests have completed (either successfully\nor failed), and prints failed tests' ``STDERR`` output, as they fail, in real time.\n\nTutorial\n--------\nTest cases usually consist of pairs of input and output files, as well as an optional ``tests.json`` file specifying applicable command-line arguments.  The input file is piped in via ``STDIN``. If the command being tested emits the expected output file via ``STDOUT``, the test case passes. A file representing an expected ``STDERR`` output can also optionally be specified.\n\nThe input/output file pairs must follow this naming pattern::\n\n  test-A.in.txt  ->  test-A.out.txt\n  test-B.in.txt  ->  test-B.out.txt, test-B.err.txt\n  test-C.in.txt  ->  test-C.out.txt\n\nThe file extension (``.txt`` here) can be anything. The file naming pattern is ``*.in*`` for input files, ``*.out*`` for expected output files, and ``*.err*`` for expected error files. The content of the ``*.in.*`` file is piped to the command being tested, and its ``STDOUT`` is compared against the ``*.out*`` file. If a ``*.err.*`` file has been provided, then the command ``STDERR`` is matched against it as well.\n\nFor an example of test_cmd in action, see the `pypage project <https://github.com/arjun-menon/pypage>`_, particularly its `tests folder <https://github.com/arjun-menon/pypage/tree/master/tests>`_.\n\nUsage\n*****\n::\n\n    usage: test_cmd.py [-h] [-b] [-d] [-u] [-t] tests_dir cmd ...\n\n    Functional Testing Utility for Command-Line Applications\n\n    positional arguments:\n      tests_dir      Path to the directory containing test cases\n      cmd            Path to the command to be tested\n      args           The command-line arguments with an ampersand character '@' markingwhere arguments from test.json should be injected\n\n    options:\n      -h, --help     show this help message and exit\n      -b, --bw       black & white output\n      -d, --diff     diff output\n      -u, --to-unix  convert CR+LF to LF in cmd output and test files\n      -t, --rtrim    ignore trailing whitespaces at the end of each line as well as trailing newlines\n\nCommand-line arguments for test cases can be specified by creating a special file named ``tests.json``, and placing it in the directory containing your test cases. This ``tests.json`` file maps test cases to objects representing command-line arguments for that test case. If a command-line argument is a non-string value (e.g. a complex JavaScript object), the argument is stringified (with Python's ``json.dumps``), and passed in as JSON.\n\n.. |pypi| image:: https://badge.fury.io/py/test_cmd.svg\n   :target: https://pypi.python.org/pypi/test_cmd\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Tool for black-box testing command-line programs using STDIN, STDOUT and STDERR, with multiple CPUs",
    "version": "2.0.6",
    "project_urls": {
        "Download": "https://github.com/arjun-menon/test_cmd/archive/v2.0.6.tar.gz",
        "Homepage": "https://github.com/arjun-menon/test_cmd"
    },
    "split_keywords": [
        "command",
        "line",
        "terminal",
        "functional",
        "black",
        "box",
        "testing",
        "arguments",
        "stdin",
        "stdout",
        "stderr"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "274cc643cfdd744a742d47a7e9b17f917a44a31c751adfa7a03ba974133617a6",
                "md5": "20b1b922541a3818f9098ef01eced881",
                "sha256": "0c0615e53de9b18b5d926966cbf386194d70cf6ef86216166537b1ebfa10e2c0"
            },
            "downloads": -1,
            "filename": "test_cmd-2.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "20b1b922541a3818f9098ef01eced881",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10193,
            "upload_time": "2023-09-26T15:52:51",
            "upload_time_iso_8601": "2023-09-26T15:52:51.519640Z",
            "url": "https://files.pythonhosted.org/packages/27/4c/c643cfdd744a742d47a7e9b17f917a44a31c751adfa7a03ba974133617a6/test_cmd-2.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa7acefe5c04af32bd8b2f64fa5353b8ade65076b3262a9c82cd8d4a51c7697d",
                "md5": "15630bca248431e643ec9698a0df075f",
                "sha256": "04861d7a9e9defd8d2021abe6d96960b459cd105360f711bfb1362e2a8a5226c"
            },
            "downloads": -1,
            "filename": "test_cmd-2.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "15630bca248431e643ec9698a0df075f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9532,
            "upload_time": "2023-09-26T15:52:52",
            "upload_time_iso_8601": "2023-09-26T15:52:52.734386Z",
            "url": "https://files.pythonhosted.org/packages/aa/7a/cefe5c04af32bd8b2f64fa5353b8ade65076b3262a9c82cd8d4a51c7697d/test_cmd-2.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-26 15:52:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arjun-menon",
    "github_project": "test_cmd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "test-cmd"
}
        
Elapsed time: 0.12866s