{"repo":"bach-sh/bach","free":true,"listed":false,"github":"https://github.com/bach-sh/bach","clone":"git clone https://github.com/bach-sh/bach.git","description":"Unit testing framework for developing cross-platform Bash unit tests","language":"Shell","stars":561,"topics":["bash","bash-scripting","unit-testing","unit-testing-framework","testing","framework","shell","shell-script","shell-scripting","testing-framework"],"license":null,"category":"cli-tools","readme_excerpt":"Bach Unit Testing Framework Bach Bach is a Bash testing framework, can be used to test scripts that contain dangerous commands like rm -rf / . No surprises, no pain. - Website: https://bach.sh - Repo: https://github.com/bach-sh/bach - 查看本文档的中文版 Getting Started Bach Unit Testing Framework is a real unit testing framework. All commands in the PATH environment variable become external dependencies of bash scripts being tested. No commands can be actually executed. In other words, all commands in Bach test cases are dry run . Because that unit tests should verify the behavior of bash scripts, not test commands. Bach Testing Framework also provides APIs to mock commands. Prerequisites - Bash v4.3+ - Coreutils ( GNU/Linux ) - Diffutils ( GNU/Linux ) Installing Installing Bach Testing Framework is very simple. Download bach.sh to your project, use the source command to import bach.sh . For example: source path/to/bach.sh A complete example #!/usr/bin/env bash source bach.sh test-rm-rf() { # Write your test case project log path=/tmp/project/logs rm -rf \"$project log ptah/\" # Typo here! } test-rm-rf-assert() { # Verify your test case rm -rf / # This is the actual command to run on your host! # DO NOT PANIC! By using Bach Testing Framework it won't actually run. } test-rm-your-dot-git() { # Mock find command with certain parameters, will output two directories @mock find -type d -name .git === @stdout /src/your-awesome-project/.git \\ /src/code/.git # Do it, remove all .git directories","default_branch":null,"files":null,"tree":[],"storefront":"/r/bach-sh","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/bach-sh/bach/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}