{"id":22473129,"url":"https://github.com/bas080/spat","last_synced_at":"2025-06-30T13:34:45.232Z","repository":{"id":213104877,"uuid":"733038626","full_name":"bas080/spat","owner":"bas080","description":"Simple cli tool for writing quick tests for tools with stdout and stderr output","archived":false,"fork":false,"pushed_at":"2023-12-20T00:00:33.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T20:12:18.794Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","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/bas080.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-18T12:28:42.000Z","updated_at":"2023-12-18T14:36:17.000Z","dependencies_parsed_at":"2023-12-18T13:39:56.727Z","dependency_job_id":"60ceff65-c05d-4d8e-b7d8-34eeb17e6cf4","html_url":"https://github.com/bas080/spat","commit_stats":null,"previous_names":["bas080/spat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fspat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fspat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fspat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fspat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bas080","download_url":"https://codeload.github.com/bas080/spat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245880980,"owners_count":20687648,"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-12-06T12:19:17.199Z","updated_at":"2025-03-27T16:26:17.305Z","avatar_url":"https://github.com/bas080.png","language":"Perl","readme":"# 💦 Spat\n\nTool for testing CLI tools and their outputs.\n\n## Usage\n\n```bash\nspat spat.t\n\necho -e '\\n# Or make test.sh executable and add the spat shebang.\\n'\n\n./spat.t\n```\n```\nspat: sh spat.t \u003e spat.t.new 2\u003e\u00261\nspat: All tests passed.\n\n# Or make test.sh executable and add the spat shebang.\n\nspat: sh ./spat.t \u003e ./spat.t.new 2\u003e\u00261\nspat: All tests passed.\n```\n\n\u003e You can change the shell with the `SPAT_SHELL` environment variable. If none is\n\u003e defined it will use `sh`.\n\n## Snapshot\n\nThe snapshot file (`\u003cscript\u003e.out`) is created by running the spat command while the output file\nis not yet defined. You can re-create the snapshot file by removing the\nsnapshot and running the spat test again. You can also manually edit the\nsnapshot file while keeping your regular expressions.\n\nThe snapshot is a file that can be edited to account for\nvariable output. An example would be the current date.\n\n```bash\nhead -n 7 spat.t\n```\n```\n#!/usr/bin/env spat\n\nset -x\n\n# A variable line where we use a regex.\ndate -I\n\n```\n\nOn every run the date can vary and the test can therefore fail for\nthe wrong reasons. This can be solved by replacing the line with a regex.\n\n```bash\nhead -n 3 spat.t.out\n```\n```\n  + date -I\n\\d{4}-[\\d{2}]{2}\n  + tmp=/tmp/spat.test.sh\n```\n\nNotice that we removed the 2 spaces and placed a regex accounts for the\nvariation while still checking if the output looks date like.\n\n## Tips \u0026 Tricks\n\n- Turn on `set -x` when writing your commands in a `sh` or `bash` script. This\n  prints the command before it starts running it. This helps with debugging and\n  writting more expressive pattern files.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbas080%2Fspat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbas080%2Fspat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbas080%2Fspat/lists"}