{"id":20441511,"url":"https://github.com/moritetu/baut","last_synced_at":"2026-05-01T23:37:03.032Z","repository":{"id":85122483,"uuid":"104740701","full_name":"moritetu/baut","owner":"moritetu","description":"A testing tool run on Bash","archived":false,"fork":false,"pushed_at":"2020-02-26T15:38:17.000Z","size":126,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-05T02:49:35.482Z","etag":null,"topics":["bash","baut","shellscript","testing-framework"],"latest_commit_sha":null,"homepage":"http://baut.readthedocs.io/en/latest/","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/moritetu.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-25T11:19:09.000Z","updated_at":"2025-01-28T02:59:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"c9453a0a-e389-4636-8d5b-a91c8f028c5c","html_url":"https://github.com/moritetu/baut","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/moritetu/baut","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritetu%2Fbaut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritetu%2Fbaut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritetu%2Fbaut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritetu%2Fbaut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moritetu","download_url":"https://codeload.github.com/moritetu/baut/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moritetu%2Fbaut/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283459954,"owners_count":26839469,"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","status":"online","status_checked_at":"2025-11-09T02:00:05.828Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bash","baut","shellscript","testing-framework"],"created_at":"2024-11-15T09:33:20.405Z","updated_at":"2025-11-09T05:04:32.507Z","avatar_url":"https://github.com/moritetu.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Baut (Bash Unit Test Tool)\n\n[![Build Status](https://travis-ci.org/moritetu/baut.svg?branch=master)](https://travis-ci.org/moritetu/baut)\n\nBaut is a unit testing tool runs on Bash. With baut, you can verify that the programs on Unix/Linux\nbehave as expected.\n\nA test file is just a Bash script, so you can write test codes using your favorite editor as always. Do not need special editors\nor editor modes.\n\nThis is a short example of a Baut test script.\n\n``` shell\n# test_sample.sh\n\n#: @BeforeEach\nfunction setup() {\n  echo \"==\u003e $(self)\"\n  export PATH=/usr/local/bin:\"$PATH\"\n}\n\n#: @Test(The usage should be displayed when command line options are invalid)\nfunction parse_cli_options() {\n  run echo \"usage: baut\"\n  [[ \"$result\" =~ usage: ]]\n}\n\n#: @Test\n#: @Ignore\nfunction this_test_is_ignored() {\n  echo \"This test is ignored\"\n}\n\n#: @AfterEach\nfunction teardown() {\n  echo \"==\u003e $(self)\"\n}\n```\n\n## Installation\n\nBaut runs on Bash 4 or higher.\n\n``` shell\n$ git clone https://github.com/moritoru81/baut.git\n$ cd baut\n$ source install.sh\n$ baut run test\n```\n\n`source install.sh` is a optional step, it adds the directory path of `baut` to `PATH`.\n\n\n## Running tests\n\nYou can run tests with `run` command. `run` command takes test files or directories which include test files.\n\n``` shell\n$ baut run test_sample.sh\n1 file, 1 test\n#1 /Users/guest/test_sample.sh\no The usage should be displayed when command line options are invalid\n  ==\u003e setup\n  ==\u003e teardown\n#$ 1 test, 1 ok, 0 failed, 0 skipped\n\n🎉  1 file, 1 test, 1 ok, 0 failed, 0 skipped\nTime: 0 hour, 0 minute, 0 second\n```\n\n## Quick Start\n\nYou can make a test project with `init` command. There are some project templates under template directory. Without options, the default template is selected.\n\n``` shell\n$ baut init test\n$ ./test/run-test.sh\n1 file, 4 tests\n#1 /Users/guest/baut/test/test_sample.sh\nx test_ng_sample\n  Not implemented\n  # Error(1) detected at the following:\n  #       13\t#: @Test\n  #       14\ttest_ng_sample() {\n  #=\u003e     15\t  fail \"Not implemented\"\n  #       16\t}\n  #       17\nx test_ng_sample2\n  exit status should not be 0, but '0'\n  result: bar\n  # Error(1) detected at the following:\n  #       19\ttest_ng_sample2() {\n  #       20\t  run echo \"bar\"\n  #=\u003e     21\t  [ $status -ne 0 ] || fail \"exit status should not be 0, but '$status'\" \"result: $result\"\n  #       22\t}\n  #       23\no test_ok_sample\n~ test_skip_sample # SKIP Good bye!\n#$ 4 tests, 1 ok, 2 failed, 1 skipped\n\n💥  1 file, 4 tests, 1 ok, 2 failed, 1 skipped\nTime: 0 hour, 0 minute, 0 second\n```\n\n## Test Using Diff\n\nThis example shows test comparing expected results with actual results like PostgreSQL regression test. Expected results are put under `expected` directory, and actual results are written under `results` directory.\n\n``` shell\n$ tree\n.\n├── expected\n│   ├── test_count.out\n│   ├── test_from_file.out\n│   ├── test_limit.out\n│   ├── test_offset.out\n│   └── test_where.out\n├── results\n├── sql\n│   └── test.sql\n└── test_sample.sh\n```\n\n``` shell\n#!/usr/bin/env bash\n# test_sample.sh\n\nload \"diff-helper.sh\"\n\nSQLDIR=\"$(__DIR__)/sql\"\n\n#: @BeforeAll\nsetup_all() {\n  export PGDATABASE=sample\n  dropdb --if-exists sample\n  createdb --encoding=utf8 sample\n  psql -c \"create table users (id int primary key, name varchar(128) not null);\"\n  psql -c \"insert into users select i , 'name-' || i from generate_series(1, 100) as i;\"\n}\n\ntest_where() {\n  run_diffx psql -c \"select id, name from users where id = 1;\"\n}\n\ntest_count() {\n  run_diffx psql -c \"select count(*) from users;\"\n}\n\ntest_limit() {\n  run_diffx psql -c \"select id, name from users order by id limit 10;\"\n}\n\ntest_offset() {\n  run_diffx psql -c \"select id, name from users order by id limit 10 offset 50;\"\n}\n\ntest_from_file() {\n  run_diffx psql -f \"$SQLDIR\"/test.sql\n}\n\n#: @AfterAll\nafter_all() {\n  dropdb sample\n}\n```\n\n``` shell\n$ cat expected/test_count.out\n count\n-------\n   100\n(1 row)\n\n```\n\nThe execution result is as follows.\n\n``` shell\n$ baut run test_sample.sh\n1 file, 5 tests\n#1 /Users/guest/workspace/baut/postgres/test_sample.sh\nNOTICE:  database \"sample\" does not exist, skipping\nCREATE TABLE\nINSERT 0 100\no test_where\no test_count\no test_limit\no test_offset\no test_from_file\n#$ 5 tests, 5 ok, 0 failed, 0 skipped\n\n🎉  1 file, 5 tests, 5 ok, 0 failed, 0 skipped\nTime: 0 hour, 0 minute, 0 second\n```\n\n## For more detail\n\nSee [Baut Document](http://baut.readthedocs.io/en/latest/)\n\n## License\n\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoritetu%2Fbaut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoritetu%2Fbaut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoritetu%2Fbaut/lists"}