{"id":16589702,"url":"https://github.com/mickael-menu/tesh","last_synced_at":"2025-10-29T09:31:54.342Z","repository":{"id":40450890,"uuid":"442129625","full_name":"mickael-menu/tesh","owner":"mickael-menu","description":"End-to-end tests for shell commands","archived":false,"fork":false,"pushed_at":"2022-05-28T17:50:12.000Z","size":42,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-02T00:31:54.179Z","etag":null,"topics":["cli","shell","test"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mickael-menu.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-12-27T10:40:42.000Z","updated_at":"2025-01-11T07:24:17.000Z","dependencies_parsed_at":"2022-08-09T20:51:05.986Z","dependency_job_id":null,"html_url":"https://github.com/mickael-menu/tesh","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickael-menu%2Ftesh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickael-menu%2Ftesh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickael-menu%2Ftesh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mickael-menu%2Ftesh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mickael-menu","download_url":"https://codeload.github.com/mickael-menu/tesh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238803277,"owners_count":19533289,"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":["cli","shell","test"],"created_at":"2024-10-11T23:09:43.626Z","updated_at":"2025-10-29T09:31:53.971Z","avatar_url":"https://github.com/mickael-menu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tesh\n\n`tesh` is a CLI tool and Go library used to test the output of shell commands.\n\n:warning: This is a very crude early proof of concept, use with caution.\n\nA real life `tesh` test suite is used in the [`zk` repository](https://github.com/mickael-menu/zk/tree/main/tests).\n\n## Build\n\nYou need a working [Go installation](https://golang.org/) to build `tesh`.\n\n```sh\n$ git clone https://github.com/mickael-menu/tesh.git\n$ cd tesh\n$ go install tesh.go\n```\n\n## Usage\n\n```sh\n$ tesh \u003ctests-dir\u003e \u003cworking-dir\u003e\n```\n\nRun all the `.tesh` files found in the `tests-dir` directory, recursively. The tests are run from a copy of the given `working-dir`, which can contain test fixtures.\n\n```sh\n$ tesh -u \u003ctests-dir\u003e \u003cworking-dir\u003e\n```\n\nUpdate the `.tesh` files in place (`stdout` and `stderr` outputs) when encountering a failed test.\n\n```sh\n$ tesh -b \u003ctests-dir\u003e \u003cworking-dir\u003e\n```\n\nPrint raw bytes for the expected outputs, in case of failure. Useful for debugging whitespaces.\n\n## Syntax\n\nA `.tesh` file represents a single `tesh` test case, but can contain several commands. Here's a complete example of a `.tesh` file:\n\n```sh\n# Test output on stdout\n$ echo \"hello\\nworld\"\n\u003ehello\n\u003eworld\n\n# Test output on stderr\n1$ cat not-found\n2\u003ecat: not-found: No such file or directory\n\n# Test input from stdin\n$ cat -n\n\u003cTesting input\n\u003con several lines\n\u003e     1\tTesting input\n\u003e     2\ton several lines\n\n# Test exit code\n42$ exit 42\n```\n\n### Comments\n\nOnly single-line comments are supported, with `#`. End-of-line comments are not possible.\n\n### Commands\n\nEach command must start with `$`, followed by a shell statement. You can use pipes and shell variables, as the statement will be passed to `$SHELL -c`.\n\nAn exit code of `0` is expected, unless you prefix the `$` with a failure code, e.g. `1$ cat not-found`.\n\n#### `cd` command\n\nThe `cd` command is special with `tesh`, it needs to be on its own line and can't be combined with other commands (e.g. with `\u0026\u0026` or `|`).\n\n\n### Input streams (`stdin`)\n\nYou can provide input for a command by prefixing it with `\u003c`. Whitespaces after `\u003c` are significant, including the final newline.\n\n### Output streams (`stdout` on `stderr`)\n\nUse `\u003e` for the expected output on `stdout`, or `2\u003e` for the expected output on `stderr`. Whitespaces after `\u003e` are significant, including the final newline.\nIf the command doesn't output a final newline, you can use a trailing `\\` to match the output.\n\n### Templates\n\nCommands and streams can contain [Handlebars statements](https://handlebarsjs.com/). Some additional helpers are available\n\n#### `match` helper (Regexes)\n\nThe `match` helper is useful to check for dynamic content, as you can use a regular expression to verify the content of an output stream.\n\n```\n$ uname -rs\n\u003eDarwin {{match '[0-9\\.]+'}}\n```\n\n#### `sh` helper\n\nThe `sh` helper can be used to execute a shell command and expand its output in the template.\n\n```\n{{sh \"echo 'Hello, world!'\"}} -\u003e Hello, world!\n{{#sh \"tr '[a-z]' '[A-Z]'\"}}Hello, world!{{/sh}} -\u003e HELLO, WORLD!\n```\n\n### Character escaping\n\nSome characters are significant in the commands and streams. If you want to use them literally, you must escape them with `\\`:\n\n* `$`, for example when used with shell environment variables.\n* `{{`, as it is reserved for Handlebars templates.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickael-menu%2Ftesh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmickael-menu%2Ftesh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickael-menu%2Ftesh/lists"}