{"id":19256456,"url":"https://github.com/odb/shunt","last_synced_at":"2025-04-21T15:30:50.767Z","repository":{"id":11034200,"uuid":"13367521","full_name":"odb/shunt","owner":"odb","description":"Simple Shell Unit Testing Framework","archived":false,"fork":false,"pushed_at":"2015-11-14T00:49:38.000Z","size":1118,"stargazers_count":21,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T14:12:57.987Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-06T19:08:51.000Z","updated_at":"2024-11-28T16:28:01.000Z","dependencies_parsed_at":"2022-08-28T15:00:32.722Z","dependency_job_id":null,"html_url":"https://github.com/odb/shunt","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odb%2Fshunt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odb%2Fshunt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odb%2Fshunt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odb%2Fshunt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odb","download_url":"https://codeload.github.com/odb/shunt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250080508,"owners_count":21371519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T19:05:48.021Z","updated_at":"2025-04-21T15:30:50.327Z","avatar_url":"https://github.com/odb.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [shunt](https://github.com/odb/shunt)\n\n##### Simple Shell Testing Pseudo-Framework\n\n[![shunt](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt.png)](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt.png)\n\n### What!? Why?\n\nFor a recent project, I wanted a very simple way to run some simple tests against my script output.\nI know there are a number of these kinds of things out there, but most of the ones I looked at were more complex then I wanted.\nTo start, I created a basic shell script to test my scripts, but as I began to add to it, and want more from it, I decided to take\na few minutes and build a pseudo-framework out of it.\n\nI call it a \"pseudo-framework\" because it's really more of a helper, which gives you a handfull of assertions to run against\nbash commands. Well, that and it doesn't really have a name.\n\n### How?\n\n##### Install\n\nNote, in shunt `latest` means latest stable version.\n\n    curl -L https://raw.githubusercontent.com/odb/shunt/master/install.sh | bash\n    # installs latest to ~/.bin/shunt\n\n    curl -L https://raw.githubusercontent.com/odb/shunt/master/install.sh | bash -s master\n    # installs master to ~/.bin/shunt\n\n    curl -L https://raw.githubusercontent.com/odb/shunt/master/install.sh | bash -s global\n    # installs latest to /usr/local/bin/shunt\n\n    curl -L https://raw.githubusercontent.com/odb/shunt/master/install.sh | bash -s master local\n    # installs master to ./shunt.sh\n\n##### Basic Usage\n\nA basic test file looks like this:\n\n    # file: tests.sh\n\n    function run_tests {\n    ####################################################\n    # Tests go here.\n    ####################################################\n      COMMAND=\"/path/to/your/command\"\n      assert_grep \"$COMMAND\" \"Usage\" \\\n        \"deplay usage without params\"\n      assert_grep \"$COMMAND --help\" \"Usage\" \\\n        \"deplay usage with help\"\n      assert_grep \"$COMMAND --arg2 foobar\" \"Usage\" \\\n        \"deplay usage without required arg\"\n      refute_grep \"$COMMAND --arg1 foobar\" \"Usage\" \\\n        \"work with required arg\"\n    ####################################################\n    }\n\nRun like this:\n\n    $ ./shunt.sh ./tests.sh\n\nUsage:\n``` bash\nUsage: ./shunt.sh \u003ctest files\u003e\n\nOptions:\n--plain    Disable colors and icons.\n--quiet    Do not print error messages.\n--verbose  Display success messages.\n--version  Display version information.\n--help     Display this message.\n```\n\n\u003e See `test/testOne.sh` for more examples.\n\n##### Before / After Hooks\n\nIn addition to assertion, shunt also supports before and after hooks. Simply define a `before` or `after` function.\n\n    function before {\n        ./some_setup_script.sh\n        echo \"Running before shunt assertions.\n    }\n\n    function after {\n        ./some_cleanup_script.sh\n        echo \"Running after shunt assertions.\n    }\n\n##### Assertions\n\nHere's a full list of assertions at the time of this writing:\n\n* `assert \"CMD\" \"FAIL MESSAGE\"`\n* `refute \"CMD\" \"FAIL MESSAGE\"`\n* `assert_equal \"FIRST\" \"SECOND\" \"FAIL MESSAGE\"`\n* `refute_equal \"FIRST\" \"SECOND\" \"FAIL MESSAGE\"`\n* `assert_numeq \"FIRST\" \"SECOND\" \"FAIL MESSAGE\"`\n* `refute_numeq \"FIRST\" \"SECOND\" \"FAIL MESSAGE\"`\n* `assert_grep \"CMD\" \"GREP\" \"FAIL MESSAGE\"`\n* `refute_grep \"CMD\" \"GREP\" \"FAIL MESSAGE\"`\n* `assert_file \"FILE\" \"FAIL MESSAGE\"`\n* `refute_file \"FILE\" \"FAIL MESSAGE\"`\n* `assert_dir \"DIR\" \"FAIL MESSAGE\"`\n* `refute_dir \"DIR\" \"FAIL MESSAGE\"`\n\n\n### Development\n\n* To run tests use: `make test`\n\n### Additional Screenshots\n\n[![shunt --verbose](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt_verbose.png)](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt_verbose.png)\n\n[![shunt --quiet](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt_quiet.png)](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt_quiet.png)\n\n[![shunt --plain](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt_plain.png)](https://raw.githubusercontent.com/odb/shunt/master/screenshots/shunt_plain.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodb%2Fshunt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodb%2Fshunt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodb%2Fshunt/lists"}