[
  {
    "path": ".gitattributes",
    "content": "* text=auto\n*.sh eol=lf\nlibexec/* eol=lf\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: c\nscript: bin/bats --tap test\nnotifications:\n  email:\n    on_success: never\n"
  },
  {
    "path": "CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, gender identity and expression, level of experience,\nnationality, personal appearance, race, religion, or sexual identity and\norientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment\ninclude:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or\nadvances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic\n  address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable\nbehavior and are expected to take appropriate and fair corrective action in\nresponse to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or\nreject comments, commits, code, wiki edits, issues, and other contributions\nthat are not aligned to this Code of Conduct, or to ban temporarily or\npermanently any contributor for other behaviors that they deem inappropriate,\nthreatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces\nwhen an individual is representing the project or its community. Examples of\nrepresenting a project or community include using an official project e-mail\naddress, posting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event. Representation of a project may be\nfurther defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported by contacting one of the project maintainers listed below. All\ncomplaints will be reviewed and investigated and will result in a response that\nis deemed necessary and appropriate to the circumstances. The project team is\nobligated to maintain confidentiality with regard to the reporter of an incident.\nFurther details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good\nfaith may face temporary or permanent repercussions as determined by other\nmembers of the project's leadership.\n\n## Project Maintainers\n\n* Sam Stephenson <<sstephenson@gmail.com>>\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,\navailable at [http://contributor-covenant.org/version/1/4][version]\n\n[homepage]: http://contributor-covenant.org\n[version]: http://contributor-covenant.org/version/1/4/\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2014 Sam Stephenson\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Bats: Bash Automated Testing System\n\nBats is a [TAP](http://testanything.org)-compliant testing framework\nfor Bash. It provides a simple way to verify that the UNIX programs\nyou write behave as expected.\n\nA Bats test file is a Bash script with special syntax for defining\ntest cases. Under the hood, each test case is just a function with a\ndescription.\n\n```bash\n#!/usr/bin/env bats\n\n@test \"addition using bc\" {\n  result=\"$(echo 2+2 | bc)\"\n  [ \"$result\" -eq 4 ]\n}\n\n@test \"addition using dc\" {\n  result=\"$(echo 2 2+p | dc)\"\n  [ \"$result\" -eq 4 ]\n}\n```\n\nBats is most useful when testing software written in Bash, but you can\nuse it to test any UNIX program.\n\nTest cases consist of standard shell commands. Bats makes use of\nBash's `errexit` (`set -e`) option when running test cases. If every\ncommand in the test case exits with a `0` status code (success), the\ntest passes. In this way, each line is an assertion of truth.\n\n\n## Running tests\n\nTo run your tests, invoke the `bats` interpreter with a path to a test\nfile. The file's test cases are run sequentially and in isolation. If\nall the test cases pass, `bats` exits with a `0` status code. If there\nare any failures, `bats` exits with a `1` status code.\n\nWhen you run Bats from a terminal, you'll see output as each test is\nperformed, with a check-mark next to the test's name if it passes or\nan \"X\" if it fails.\n\n    $ bats addition.bats\n     ✓ addition using bc\n     ✓ addition using dc\n\n    2 tests, 0 failures\n\nIf Bats is not connected to a terminal—in other words, if you\nrun it from a continuous integration system, or redirect its output to\na file—the results are displayed in human-readable, machine-parsable\n[TAP format](http://testanything.org).\n\nYou can force TAP output from a terminal by invoking Bats with the\n`--tap` option.\n\n    $ bats --tap addition.bats\n    1..2\n    ok 1 addition using bc\n    ok 2 addition using dc\n\n### Test suites\n\nYou can invoke the `bats` interpreter with multiple test file\narguments, or with a path to a directory containing multiple `.bats`\nfiles. Bats will run each test file individually and aggregate the\nresults. If any test case fails, `bats` exits with a `1` status code.\n\n\n## Writing tests\n\nEach Bats test file is evaluated _n+1_ times, where _n_ is the number of\ntest cases in the file. The first run counts the number of test cases,\nthen iterates over the test cases and executes each one in its own\nprocess.\n\nFor more details about how Bats evaluates test files, see \n[Bats Evaluation Process](https://github.com/sstephenson/bats/wiki/Bats-Evaluation-Process)\non the wiki.\n\n### `run`: Test other commands\n\nMany Bats tests need to run a command and then make assertions about\nits exit status and output. Bats includes a `run` helper that invokes\nits arguments as a command, saves the exit status and output into\nspecial global variables, and then returns with a `0` status code so\nyou can continue to make assertions in your test case.\n\nFor example, let's say you're testing that the `foo` command, when\npassed a nonexistent filename, exits with a `1` status code and prints\nan error message.\n\n```bash\n@test \"invoking foo with a nonexistent file prints an error\" {\n  run foo nonexistent_filename\n  [ \"$status\" -eq 1 ]\n  [ \"$output\" = \"foo: no such file 'nonexistent_filename'\" ]\n}\n```\n\nThe `$status` variable contains the status code of the command, and\nthe `$output` variable contains the combined contents of the command's\nstandard output and standard error streams.\n\nA third special variable, the `$lines` array, is available for easily\naccessing individual lines of output. For example, if you want to test\nthat invoking `foo` without any arguments prints usage information on\nthe first line:\n\n```bash\n@test \"invoking foo without arguments prints usage\" {\n  run foo\n  [ \"$status\" -eq 1 ]\n  [ \"${lines[0]}\" = \"usage: foo <filename>\" ]\n}\n```\n\n### `load`: Share common code\n\nYou may want to share common code across multiple test files. Bats\nincludes a convenient `load` command for sourcing a Bash source file\nrelative to the location of the current test file. For example, if you\nhave a Bats test in `test/foo.bats`, the command\n\n```bash\nload test_helper\n```\n\nwill source the script `test/test_helper.bash` in your test file. This\ncan be useful for sharing functions to set up your environment or load\nfixtures.\n\n### `skip`: Easily skip tests\n\nTests can be skipped by using the `skip` command at the point in a\ntest you wish to skip.\n\n```bash\n@test \"A test I don't want to execute for now\" {\n  skip\n  run foo\n  [ \"$status\" -eq 0 ]\n}\n```\n\nOptionally, you may include a reason for skipping:\n\n```bash\n@test \"A test I don't want to execute for now\" {\n  skip \"This command will return zero soon, but not now\"\n  run foo\n  [ \"$status\" -eq 0 ]\n}\n```\n\nOr you can skip conditionally:\n\n```bash\n@test \"A test which should run\" {\n  if [ foo != bar ]; then\n    skip \"foo isn't bar\"\n  fi\n\n  run foo\n  [ \"$status\" -eq 0 ]\n}\n```\n\n### `setup` and `teardown`: Pre- and post-test hooks\n\nYou can define special `setup` and `teardown` functions, which run\nbefore and after each test case, respectively. Use these to load\nfixtures, set up your environment, and clean up when you're done.\n\n### Code outside of test cases\n\nYou can include code in your test file outside of `@test` functions.\nFor example, this may be useful if you want to check for dependencies\nand fail immediately if they're not present. However, any output that\nyou print in code outside of `@test`, `setup` or `teardown` functions\nmust be redirected to `stderr` (`>&2`). Otherwise, the output may\ncause Bats to fail by polluting the TAP stream on `stdout`.\n\n### Special variables\n\nThere are several global variables you can use to introspect on Bats\ntests:\n\n* `$BATS_TEST_FILENAME` is the fully expanded path to the Bats test\nfile.\n* `$BATS_TEST_DIRNAME` is the directory in which the Bats test file is\nlocated.\n* `$BATS_TEST_NAMES` is an array of function names for each test case.\n* `$BATS_TEST_NAME` is the name of the function containing the current\ntest case.\n* `$BATS_TEST_DESCRIPTION` is the description of the current test\ncase.\n* `$BATS_TEST_NUMBER` is the (1-based) index of the current test case\nin the test file.\n* `$BATS_TMPDIR` is the location to a directory that may be used to\nstore temporary files.\n\n\n## Installing Bats from source\n\nCheck out a copy of the Bats repository. Then, either add the Bats\n`bin` directory to your `$PATH`, or run the provided `install.sh`\ncommand with the location to the prefix in which you want to install\nBats. For example, to install Bats into `/usr/local`,\n\n    $ git clone https://github.com/sstephenson/bats.git\n    $ cd bats\n    $ ./install.sh /usr/local\n\nNote that you may need to run `install.sh` with `sudo` if you do not\nhave permission to write to the installation prefix.\n\n\n## Support\n\nThe Bats source code repository is [hosted on\nGitHub](https://github.com/sstephenson/bats). There you can file bugs\non the issue tracker or submit tested pull requests for review.\n\nFor real-world examples from open-source projects using Bats, see\n[Projects Using Bats](https://github.com/sstephenson/bats/wiki/Projects-Using-Bats)\non the wiki.\n\nTo learn how to set up your editor for Bats syntax highlighting, see\n[Syntax Highlighting](https://github.com/sstephenson/bats/wiki/Syntax-Highlighting)\non the wiki.\n\n\n## Version history\n\n*0.4.0* (August 13, 2014)\n\n* Improved the display of failing test cases. Bats now shows the\n  source code of failing test lines, along with full stack traces\n  including function names, filenames, and line numbers.\n* Improved the display of the pretty-printed test summary line to\n  include the number of skipped tests, if any.\n* Improved the speed of the preprocessor, dramatically shortening test\n  and suite startup times.\n* Added support for absolute pathnames to the `load` helper.\n* Added support for single-line `@test` definitions.\n* Added bats(1) and bats(7) manual pages.\n* Modified the `bats` command to default to TAP output when the `$CI`\n  variable is set, to better support environments such as Travis CI.\n\n*0.3.1* (October 28, 2013)\n\n* Fixed an incompatibility with the pretty formatter in certain\n  environments such as tmux.\n* Fixed a bug where the pretty formatter would crash if the first line\n  of a test file's output was invalid TAP.\n\n*0.3.0* (October 21, 2013)\n\n* Improved formatting for tests run from a terminal. Failing tests\n  are now colored in red, and the total number of failing tests is\n  displayed at the end of the test run. When Bats is not connected to\n  a terminal (e.g. in CI runs), or when invoked with the `--tap` flag,\n  output is displayed in standard TAP format.\n* Added the ability to skip tests using the `skip` command.\n* Added a message to failing test case output indicating the file and\n  line number of the statement that caused the test to fail.\n* Added \"ad-hoc\" test suite support. You can now invoke `bats` with\n  multiple filename or directory arguments to run all the specified\n  tests in aggregate.\n* Added support for test files with Windows line endings.\n* Fixed regular expression warnings from certain versions of Bash.\n* Fixed a bug running tests containing lines that begin with `-e`.\n\n*0.2.0* (November 16, 2012)\n\n* Added test suite support. The `bats` command accepts a directory\n  name containing multiple test files to be run in aggregate.\n* Added the ability to count the number of test cases in a file or\n  suite by passing the `-c` flag to `bats`.\n* Preprocessed sources are cached between test case runs in the same\n  file for better performance.\n\n*0.1.0* (December 30, 2011)\n\n* Initial public release.\n\n---\n\n© 2014 Sam Stephenson. Bats is released under an MIT-style license;\nsee `LICENSE` for details.\n"
  },
  {
    "path": "install.sh",
    "content": "#!/usr/bin/env bash\nset -e\n\nresolve_link() {\n  $(type -p greadlink readlink | head -1) \"$1\"\n}\n\nabs_dirname() {\n  local cwd=\"$(pwd)\"\n  local path=\"$1\"\n\n  while [ -n \"$path\" ]; do\n    cd \"${path%/*}\"\n    local name=\"${path##*/}\"\n    path=\"$(resolve_link \"$name\" || true)\"\n  done\n\n  pwd\n  cd \"$cwd\"\n}\n\nPREFIX=\"$1\"\nif [ -z \"$1\" ]; then\n  { echo \"usage: $0 <prefix>\"\n    echo \"  e.g. $0 /usr/local\"\n  } >&2\n  exit 1\nfi\n\nBATS_ROOT=\"$(abs_dirname \"$0\")\"\nmkdir -p \"$PREFIX\"/{bin,libexec,share/man/man{1,7}}\ncp -R \"$BATS_ROOT\"/bin/* \"$PREFIX\"/bin\ncp -R \"$BATS_ROOT\"/libexec/* \"$PREFIX\"/libexec\ncp \"$BATS_ROOT\"/man/bats.1 \"$PREFIX\"/share/man/man1\ncp \"$BATS_ROOT\"/man/bats.7 \"$PREFIX\"/share/man/man7\n\necho \"Installed Bats to $PREFIX/bin/bats\"\n"
  },
  {
    "path": "libexec/bats",
    "content": "#!/usr/bin/env bash\nset -e\n\nversion() {\n  echo \"Bats 0.4.0\"\n}\n\nusage() {\n  version\n  echo \"Usage: bats [-c] [-p | -t] <test> [<test> ...]\"\n}\n\nhelp() {\n  usage\n  echo\n  echo \"  <test> is the path to a Bats test file, or the path to a directory\"\n  echo \"  containing Bats test files.\"\n  echo\n  echo \"  -c, --count    Count the number of test cases without running any tests\"\n  echo \"  -h, --help     Display this help message\"\n  echo \"  -p, --pretty   Show results in pretty format (default for terminals)\"\n  echo \"  -t, --tap      Show results in TAP format\"\n  echo \"  -v, --version  Display the version number\"\n  echo\n  echo \"  For more information, see https://github.com/sstephenson/bats\"\n  echo\n}\n\nresolve_link() {\n  $(type -p greadlink readlink | head -1) \"$1\"\n}\n\nabs_dirname() {\n  local cwd=\"$(pwd)\"\n  local path=\"$1\"\n\n  while [ -n \"$path\" ]; do\n    cd \"${path%/*}\"\n    local name=\"${path##*/}\"\n    path=\"$(resolve_link \"$name\" || true)\"\n  done\n\n  pwd\n  cd \"$cwd\"\n}\n\nexpand_path() {\n  { cd \"$(dirname \"$1\")\" 2>/dev/null\n    local dirname=\"$PWD\"\n    cd \"$OLDPWD\"\n    echo \"$dirname/$(basename \"$1\")\"\n  } || echo \"$1\"\n}\n\nBATS_LIBEXEC=\"$(abs_dirname \"$0\")\"\nexport BATS_PREFIX=\"$(abs_dirname \"$BATS_LIBEXEC\")\"\nexport BATS_CWD=\"$(abs_dirname .)\"\nexport PATH=\"$BATS_LIBEXEC:$PATH\"\n\noptions=()\narguments=()\nfor arg in \"$@\"; do\n  if [ \"${arg:0:1}\" = \"-\" ]; then\n    if [ \"${arg:1:1}\" = \"-\" ]; then\n      options[${#options[*]}]=\"${arg:2}\"\n    else\n      index=1\n      while option=\"${arg:$index:1}\"; do\n        [ -n \"$option\" ] || break\n        options[${#options[*]}]=\"$option\"\n        let index+=1\n      done\n    fi\n  else\n    arguments[${#arguments[*]}]=\"$arg\"\n  fi\ndone\n\nunset count_flag pretty\n[ -t 0 ] && [ -t 1 ] && pretty=\"1\"\n[ -n \"$CI\" ] && pretty=\"\"\n\nfor option in \"${options[@]}\"; do\n  case \"$option\" in\n  \"h\" | \"help\" )\n    help\n    exit 0\n    ;;\n  \"v\" | \"version\" )\n    version\n    exit 0\n    ;;\n  \"c\" | \"count\" )\n    count_flag=\"-c\"\n    ;;\n  \"t\" | \"tap\" )\n    pretty=\"\"\n    ;;\n  \"p\" | \"pretty\" )\n    pretty=\"1\"\n    ;;\n  * )\n    usage >&2\n    exit 1\n    ;;\n  esac\ndone\n\nif [ \"${#arguments[@]}\" -eq 0 ]; then\n  usage >&2\n  exit 1\nfi\n\nfilenames=()\nfor filename in \"${arguments[@]}\"; do\n  if [ -d \"$filename\" ]; then\n    shopt -s nullglob\n    for suite_filename in \"$(expand_path \"$filename\")\"/*.bats; do\n      filenames[\"${#filenames[@]}\"]=\"$suite_filename\"\n    done\n    shopt -u nullglob\n  else\n    filenames[\"${#filenames[@]}\"]=\"$(expand_path \"$filename\")\"\n  fi\ndone\n\nif [ \"${#filenames[@]}\" -eq 1 ]; then\n  command=\"bats-exec-test\"\nelse\n  command=\"bats-exec-suite\"\nfi\n\nif [ -n \"$pretty\" ]; then\n  extended_syntax_flag=\"-x\"\n  formatter=\"bats-format-tap-stream\"\nelse\n  extended_syntax_flag=\"\"\n  formatter=\"cat\"\nfi\n\nset -o pipefail execfail\nexec \"$command\" $count_flag $extended_syntax_flag \"${filenames[@]}\" | \"$formatter\"\n"
  },
  {
    "path": "libexec/bats-exec-suite",
    "content": "#!/usr/bin/env bash\nset -e\n\ncount_only_flag=\"\"\nif [ \"$1\" = \"-c\" ]; then\n  count_only_flag=1\n  shift\nfi\n\nextended_syntax_flag=\"\"\nif [ \"$1\" = \"-x\" ]; then\n  extended_syntax_flag=\"-x\"\n  shift\nfi\n\ntrap \"kill 0; exit 1\" int\n\ncount=0\nfor filename in \"$@\"; do\n  let count+=\"$(bats-exec-test -c \"$filename\")\"\ndone\n\nif [ -n \"$count_only_flag\" ]; then\n  echo \"$count\"\n  exit\nfi\n\necho \"1..$count\"\nstatus=0\noffset=0\nfor filename in \"$@\"; do\n  index=0\n  {\n    IFS= read -r # 1..n\n    while IFS= read -r line; do\n      case \"$line\" in\n      \"begin \"* )\n        let index+=1\n        echo \"${line/ $index / $(($offset + $index)) }\"\n        ;;\n      \"ok \"* | \"not ok \"* )\n        [ -n \"$extended_syntax_flag\" ] || let index+=1\n        echo \"${line/ $index / $(($offset + $index)) }\"\n        [ \"${line:0:6}\" != \"not ok\" ] || status=1\n        ;;\n      * )\n        echo \"$line\"\n        ;;\n      esac\n    done\n  } < <( bats-exec-test $extended_syntax_flag \"$filename\" )\n  offset=$(($offset + $index))\ndone\n\nexit \"$status\"\n"
  },
  {
    "path": "libexec/bats-exec-test",
    "content": "#!/usr/bin/env bash\nset -e\nset -E\nset -T\n\nBATS_COUNT_ONLY=\"\"\nif [ \"$1\" = \"-c\" ]; then\n  BATS_COUNT_ONLY=1\n  shift\nfi\n\nBATS_EXTENDED_SYNTAX=\"\"\nif [ \"$1\" = \"-x\" ]; then\n  BATS_EXTENDED_SYNTAX=\"$1\"\n  shift\nfi\n\nBATS_TEST_FILENAME=\"$1\"\nif [ -z \"$BATS_TEST_FILENAME\" ]; then\n  echo \"usage: bats-exec <filename>\" >&2\n  exit 1\nelif [ ! -f \"$BATS_TEST_FILENAME\" ]; then\n  echo \"bats: $BATS_TEST_FILENAME does not exist\" >&2\n  exit 1\nelse\n  shift\nfi\n\nBATS_TEST_DIRNAME=\"$(dirname \"$BATS_TEST_FILENAME\")\"\nBATS_TEST_NAMES=()\n\nload() {\n  local name=\"$1\"\n  local filename\n\n  if [ \"${name:0:1}\" = \"/\" ]; then\n    filename=\"${name}\"\n  else\n    filename=\"$BATS_TEST_DIRNAME/${name}.bash\"\n  fi\n\n  [ -f \"$filename\" ] || {\n    echo \"bats: $filename does not exist\" >&2\n    exit 1\n  }\n\n  source \"${filename}\"\n}\n\nrun() {\n  local e E T oldIFS\n  [[ ! \"$-\" =~ e ]] || e=1\n  [[ ! \"$-\" =~ E ]] || E=1\n  [[ ! \"$-\" =~ T ]] || T=1\n  set +e\n  set +E\n  set +T\n  output=\"$(\"$@\" 2>&1)\"\n  status=\"$?\"\n  oldIFS=$IFS\n  IFS=$'\\n' lines=($output)\n  [ -z \"$e\" ] || set -e\n  [ -z \"$E\" ] || set -E\n  [ -z \"$T\" ] || set -T\n  IFS=$oldIFS\n}\n\nsetup() {\n  true\n}\n\nteardown() {\n  true\n}\n\nskip() {\n  BATS_TEST_SKIPPED=${1:-1}\n  BATS_TEST_COMPLETED=1\n  exit 0\n}\n\nbats_test_begin() {\n  BATS_TEST_DESCRIPTION=\"$1\"\n  if [ -n \"$BATS_EXTENDED_SYNTAX\" ]; then\n    echo \"begin $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION\" >&3\n  fi\n  setup\n}\n\nbats_test_function() {\n  local test_name=\"$1\"\n  BATS_TEST_NAMES[\"${#BATS_TEST_NAMES[@]}\"]=\"$test_name\"\n}\n\nbats_capture_stack_trace() {\n  BATS_PREVIOUS_STACK_TRACE=( \"${BATS_CURRENT_STACK_TRACE[@]}\" )\n  BATS_CURRENT_STACK_TRACE=()\n\n  local test_pattern=\" $BATS_TEST_NAME $BATS_TEST_SOURCE\"\n  local setup_pattern=\" setup $BATS_TEST_SOURCE\"\n  local teardown_pattern=\" teardown $BATS_TEST_SOURCE\"\n\n  local frame\n  local index=1\n\n  while frame=\"$(caller \"$index\")\"; do\n    BATS_CURRENT_STACK_TRACE[\"${#BATS_CURRENT_STACK_TRACE[@]}\"]=\"$frame\"\n    if [[ \"$frame\" = *\"$test_pattern\"     || \\\n          \"$frame\" = *\"$setup_pattern\"    || \\\n          \"$frame\" = *\"$teardown_pattern\" ]]; then\n      break\n    else\n      let index+=1\n    fi\n  done\n\n  BATS_SOURCE=\"$(bats_frame_filename \"${BATS_CURRENT_STACK_TRACE[0]}\")\"\n  BATS_LINENO=\"$(bats_frame_lineno \"${BATS_CURRENT_STACK_TRACE[0]}\")\"\n}\n\nbats_print_stack_trace() {\n  local frame\n  local index=1\n  local count=\"${#@}\"\n\n  for frame in \"$@\"; do\n    local filename=\"$(bats_trim_filename \"$(bats_frame_filename \"$frame\")\")\"\n    local lineno=\"$(bats_frame_lineno \"$frame\")\"\n\n    if [ $index -eq 1 ]; then\n      echo -n \"# (\"\n    else\n      echo -n \"#  \"\n    fi\n\n    local fn=\"$(bats_frame_function \"$frame\")\"\n    if [ \"$fn\" != \"$BATS_TEST_NAME\" ]; then\n      echo -n \"from function \\`$fn' \"\n    fi\n\n    if [ $index -eq $count ]; then\n      echo \"in test file $filename, line $lineno)\"\n    else\n      echo \"in file $filename, line $lineno,\"\n    fi\n\n    let index+=1\n  done\n}\n\nbats_print_failed_command() {\n  local frame=\"$1\"\n  local status=\"$2\"\n  local filename=\"$(bats_frame_filename \"$frame\")\"\n  local lineno=\"$(bats_frame_lineno \"$frame\")\"\n\n  local failed_line=\"$(bats_extract_line \"$filename\" \"$lineno\")\"\n  local failed_command=\"$(bats_strip_string \"$failed_line\")\"\n  echo -n \"#   \\`${failed_command}' \"\n\n  if [ $status -eq 1 ]; then\n    echo \"failed\"\n  else\n    echo \"failed with status $status\"\n  fi\n}\n\nbats_frame_lineno() {\n  local frame=\"$1\"\n  local lineno=\"${frame%% *}\"\n  echo \"$lineno\"\n}\n\nbats_frame_function() {\n  local frame=\"$1\"\n  local rest=\"${frame#* }\"\n  local fn=\"${rest%% *}\"\n  echo \"$fn\"\n}\n\nbats_frame_filename() {\n  local frame=\"$1\"\n  local rest=\"${frame#* }\"\n  local filename=\"${rest#* }\"\n\n  if [ \"$filename\" = \"$BATS_TEST_SOURCE\" ]; then\n    echo \"$BATS_TEST_FILENAME\"\n  else\n    echo \"$filename\"\n  fi\n}\n\nbats_extract_line() {\n  local filename=\"$1\"\n  local lineno=\"$2\"\n  sed -n \"${lineno}p\" \"$filename\"\n}\n\nbats_strip_string() {\n  local string=\"$1\"\n  printf \"%s\" \"$string\" | sed -e \"s/^[ \"$'\\t'\"]*//\" -e \"s/[ \"$'\\t'\"]*$//\"\n}\n\nbats_trim_filename() {\n  local filename=\"$1\"\n  local length=\"${#BATS_CWD}\"\n\n  if [ \"${filename:0:length+1}\" = \"${BATS_CWD}/\" ]; then\n    echo \"${filename:length+1}\"\n  else\n    echo \"$filename\"\n  fi\n}\n\nbats_debug_trap() {\n  if [ \"$BASH_SOURCE\" != \"$1\" ]; then\n    bats_capture_stack_trace\n  fi\n}\n\nbats_error_trap() {\n  BATS_ERROR_STATUS=\"$?\"\n  BATS_ERROR_STACK_TRACE=( \"${BATS_PREVIOUS_STACK_TRACE[@]}\" )\n  trap - debug\n}\n\nbats_teardown_trap() {\n  trap \"bats_exit_trap\" exit\n  local status=0\n  teardown >>\"$BATS_OUT\" 2>&1 || status=\"$?\"\n\n  if [ $status -eq 0 ]; then\n    BATS_TEARDOWN_COMPLETED=1\n  elif [ -n \"$BATS_TEST_COMPLETED\" ]; then\n    BATS_ERROR_STATUS=\"$status\"\n    BATS_ERROR_STACK_TRACE=( \"${BATS_CURRENT_STACK_TRACE[@]}\" )\n  fi\n\n  bats_exit_trap\n}\n\nbats_exit_trap() {\n  local status\n  local skipped\n  trap - err exit\n\n  skipped=\"\"\n  if [ -n \"$BATS_TEST_SKIPPED\" ]; then\n    skipped=\" # skip\"\n    if [ \"1\" != \"$BATS_TEST_SKIPPED\" ]; then\n      skipped+=\" ($BATS_TEST_SKIPPED)\"\n    fi\n  fi\n\n  if [ -z \"$BATS_TEST_COMPLETED\" ] || [ -z \"$BATS_TEARDOWN_COMPLETED\" ]; then\n    echo \"not ok $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION\" >&3\n    bats_print_stack_trace \"${BATS_ERROR_STACK_TRACE[@]}\" >&3\n    bats_print_failed_command \"${BATS_ERROR_STACK_TRACE[${#BATS_ERROR_STACK_TRACE[@]}-1]}\" \"$BATS_ERROR_STATUS\" >&3\n    sed -e \"s/^/# /\" < \"$BATS_OUT\" >&3\n    status=1\n  else\n    echo \"ok ${BATS_TEST_NUMBER}${skipped} ${BATS_TEST_DESCRIPTION}\" >&3\n    status=0\n  fi\n\n  rm -f \"$BATS_OUT\"\n  exit \"$status\"\n}\n\nbats_perform_tests() {\n  echo \"1..$#\"\n  test_number=1\n  status=0\n  for test_name in \"$@\"; do\n    \"$0\" $BATS_EXTENDED_SYNTAX \"$BATS_TEST_FILENAME\" \"$test_name\" \"$test_number\" || status=1\n    let test_number+=1\n  done\n  exit \"$status\"\n}\n\nbats_perform_test() {\n  BATS_TEST_NAME=\"$1\"\n  if [ \"$(type -t \"$BATS_TEST_NAME\" || true)\" = \"function\" ]; then\n    BATS_TEST_NUMBER=\"$2\"\n    if [ -z \"$BATS_TEST_NUMBER\" ]; then\n      echo \"1..1\"\n      BATS_TEST_NUMBER=\"1\"\n    fi\n\n    BATS_TEST_COMPLETED=\"\"\n    BATS_TEARDOWN_COMPLETED=\"\"\n    trap \"bats_debug_trap \\\"\\$BASH_SOURCE\\\"\" debug\n    trap \"bats_error_trap\" err\n    trap \"bats_teardown_trap\" exit\n    \"$BATS_TEST_NAME\" >>\"$BATS_OUT\" 2>&1\n    BATS_TEST_COMPLETED=1\n\n  else\n    echo \"bats: unknown test name \\`$BATS_TEST_NAME'\" >&2\n    exit 1\n  fi\n}\n\nif [ -z \"$TMPDIR\" ]; then\n  BATS_TMPDIR=\"/tmp\"\nelse\n  BATS_TMPDIR=\"${TMPDIR%/}\"\nfi\n\nBATS_TMPNAME=\"$BATS_TMPDIR/bats.$$\"\nBATS_PARENT_TMPNAME=\"$BATS_TMPDIR/bats.$PPID\"\nBATS_OUT=\"${BATS_TMPNAME}.out\"\n\nbats_preprocess_source() {\n  BATS_TEST_SOURCE=\"${BATS_TMPNAME}.src\"\n  { tr -d '\\r' < \"$BATS_TEST_FILENAME\"; echo; } | bats-preprocess > \"$BATS_TEST_SOURCE\"\n  trap \"bats_cleanup_preprocessed_source\" err exit\n  trap \"bats_cleanup_preprocessed_source; exit 1\" int\n}\n\nbats_cleanup_preprocessed_source() {\n  rm -f \"$BATS_TEST_SOURCE\"\n}\n\nbats_evaluate_preprocessed_source() {\n  if [ -z \"$BATS_TEST_SOURCE\" ]; then\n    BATS_TEST_SOURCE=\"${BATS_PARENT_TMPNAME}.src\"\n  fi\n  source \"$BATS_TEST_SOURCE\"\n}\n\nexec 3<&1\n\nif [ \"$#\" -eq 0 ]; then\n  bats_preprocess_source\n  bats_evaluate_preprocessed_source\n\n  if [ -n \"$BATS_COUNT_ONLY\" ]; then\n    echo \"${#BATS_TEST_NAMES[@]}\"\n  else\n    bats_perform_tests \"${BATS_TEST_NAMES[@]}\"\n  fi\nelse\n  bats_evaluate_preprocessed_source\n  bats_perform_test \"$@\"\nfi\n"
  },
  {
    "path": "libexec/bats-format-tap-stream",
    "content": "#!/usr/bin/env bash\nset -e\n\n# Just stream the TAP output (sans extended syntax) if tput is missing\ncommand -v tput >/dev/null || exec grep -v \"^begin \"\n\nheader_pattern='[0-9]+\\.\\.[0-9]+'\nIFS= read -r header\n\nif [[ \"$header\" =~ $header_pattern ]]; then\n  count=\"${header:3}\"\n  index=0\n  failures=0\n  skipped=0\n  name=\"\"\n  count_column_width=$(( ${#count} * 2 + 2 ))\nelse\n  # If the first line isn't a TAP plan, print it and pass the rest through\n  printf \"%s\\n\" \"$header\"\n  exec cat\nfi\n\nupdate_screen_width() {\n  screen_width=\"$(tput cols)\"\n  count_column_left=$(( $screen_width - $count_column_width ))\n}\n\ntrap update_screen_width WINCH\nupdate_screen_width\n\nbegin() {\n  go_to_column 0\n  printf_with_truncation $(( $count_column_left - 1 )) \"   %s\" \"$name\"\n  clear_to_end_of_line\n  go_to_column $count_column_left\n  printf \"%${#count}s/${count}\" \"$index\"\n  go_to_column 1\n}\n\npass() {\n  go_to_column 0\n  printf \" ✓ %s\" \"$name\"\n  advance\n}\n\nskip() {\n  local reason=\"$1\"\n  [ -z \"$reason\" ] || reason=\": $reason\"\n  go_to_column 0\n  printf \" - %s (skipped%s)\" \"$name\" \"$reason\"\n  advance\n}\n\nfail() {\n  go_to_column 0\n  set_color 1 bold\n  printf \" ✗ %s\" \"$name\"\n  advance\n}\n\nlog() {\n  set_color 1\n  printf \"   %s\\n\" \"$1\"\n  clear_color\n}\n\nsummary() {\n  printf \"\\n%d test%s\" \"$count\" \"$(plural \"$count\")\"\n\n  printf \", %d failure%s\" \"$failures\" \"$(plural \"$failures\")\"\n\n  if [ \"$skipped\" -gt 0 ]; then\n    printf \", %d skipped\" \"$skipped\"\n  fi\n\n  printf \"\\n\"\n}\n\nprintf_with_truncation() {\n  local width=\"$1\"\n  shift\n  local string=\"$(printf \"$@\")\"\n\n  if [ \"${#string}\" -gt \"$width\" ]; then\n    printf \"%s...\" \"${string:0:$(( $width - 4 ))}\"\n  else\n    printf \"%s\" \"$string\"\n  fi\n}\n\ngo_to_column() {\n  local column=\"$1\"\n  printf \"\\x1B[%dG\" $(( $column + 1 ))\n}\n\nclear_to_end_of_line() {\n  printf \"\\x1B[K\"\n}\n\nadvance() {\n  clear_to_end_of_line\n  echo\n  clear_color\n}\n\nset_color() {\n  local color=\"$1\"\n  local weight=\"$2\"\n  printf \"\\x1B[%d;%dm\" $(( 30 + $color )) \"$( [ \"$weight\" = \"bold\" ] && echo 1 || echo 22 )\"\n}\n\nclear_color() {\n  printf \"\\x1B[0m\"\n}\n\nplural() {\n  [ \"$1\" -eq 1 ] || echo \"s\"\n}\n\n_buffer=\"\"\n\nbuffer() {\n  _buffer=\"${_buffer}$(\"$@\")\"\n}\n\nflush() {\n  printf \"%s\" \"$_buffer\"\n  _buffer=\"\"\n}\n\nfinish() {\n  flush\n  printf \"\\n\"\n}\n\ntrap finish EXIT\n\nwhile IFS= read -r line; do\n  case \"$line\" in\n  \"begin \"* )\n    let index+=1\n    name=\"${line#* $index }\"\n    buffer begin\n    flush\n    ;;\n  \"ok \"* )\n    skip_expr=\"ok $index # skip (\\(([^)]*)\\))?\"\n    if [[ \"$line\" =~ $skip_expr ]]; then\n      let skipped+=1\n      buffer skip \"${BASH_REMATCH[2]}\"\n    else\n      buffer pass\n    fi\n    ;;\n  \"not ok \"* )\n    let failures+=1\n    buffer fail\n    ;;\n  \"# \"* )\n    buffer log \"${line:2}\"\n    ;;\n  esac\ndone\n\nbuffer summary\n"
  },
  {
    "path": "libexec/bats-preprocess",
    "content": "#!/usr/bin/env bash\nset -e\n\nencode_name() {\n  local name=\"$1\"\n  local result=\"test_\"\n\n  if [[ ! \"$name\" =~ [^[:alnum:]\\ _-] ]]; then\n    name=\"${name//_/-5f}\"\n    name=\"${name//-/-2d}\"\n    name=\"${name// /_}\"\n    result+=\"$name\"\n  else\n    local length=\"${#name}\"\n    local char i\n\n    for ((i=0; i<length; i++)); do\n      char=\"${name:$i:1}\"\n      if [ \"$char\" = \" \" ]; then\n        result+=\"_\"\n      elif [[ \"$char\" =~ [[:alnum:]] ]]; then\n        result+=\"$char\"\n      else\n        result+=\"$(printf -- \"-%02x\" \\'\"$char\")\"\n      fi\n    done\n  fi\n\n  echo \"$result\"\n}\n\ntests=()\nindex=0\npattern='^ *@test  *([^ ].*)  *\\{ *(.*)$'\n\nwhile IFS= read -r line; do\n  let index+=1\n  if [[ \"$line\" =~ $pattern ]]; then\n    quoted_name=\"${BASH_REMATCH[1]}\"\n    body=\"${BASH_REMATCH[2]}\"\n    name=\"$(eval echo \"$quoted_name\")\"\n    encoded_name=\"$(encode_name \"$name\")\"\n    tests[\"${#tests[@]}\"]=\"$encoded_name\"\n    echo \"${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}\"\n  else\n    printf \"%s\\n\" \"$line\"\n  fi\ndone\n\nfor test_name in \"${tests[@]}\"; do\n  echo \"bats_test_function ${test_name}\"\ndone\n"
  },
  {
    "path": "man/Makefile",
    "content": "RONN := ronn\nPAGES := bats.1 bats.7\n\nall: $(PAGES)\n\nbats.1: bats.1.ronn\n\t$(RONN) -r $<\n\nbats.7: bats.7.ronn\n\t$(RONN) -r $<\n"
  },
  {
    "path": "man/README.md",
    "content": "Bats man pages are generated with [Ronn](http://rtomayko.github.io/ronn/).\n\nAfter making changes to `bats.1.ronn` or `bats.7.ronn`, run `make` in\nthis directory to generate `bats.1` and `bats.7`. **Do not edit the\n`bats.1` or `bats.7` files directly.**\n"
  },
  {
    "path": "man/bats.1",
    "content": ".\\\" generated with Ronn/v0.7.3\n.\\\" http://github.com/rtomayko/ronn/tree/0.7.3\n.\n.TH \"BATS\" \"1\" \"August 2014\" \"\" \"\"\n.\n.SH \"NAME\"\n\\fBbats\\fR \\- Bash Automated Testing System\n.\n.SH \"SYNOPSIS\"\nbats [\\-c] [\\-p | \\-t] \\fItest\\fR [\\fItest\\fR \\.\\.\\.]\n.\n.P\n\\fItest\\fR is the path to a Bats test file, or the path to a directory containing Bats test files\\.\n.\n.SH \"DESCRIPTION\"\nBats is a TAP\\-compliant testing framework for Bash\\. It provides a simple way to verify that the UNIX programs you write behave as expected\\.\n.\n.P\nA Bats test file is a Bash script with special syntax for defining test cases\\. Under the hood, each test case is just a function with a description\\.\n.\n.P\nTest cases consist of standard shell commands\\. Bats makes use of Bash\\'s \\fBerrexit\\fR (\\fBset \\-e\\fR) option when running test cases\\. If every command in the test case exits with a \\fB0\\fR status code (success), the test passes\\. In this way, each line is an assertion of truth\\.\n.\n.P\nSee \\fBbats\\fR(7) for more information on writing Bats tests\\.\n.\n.SH \"RUNNING TESTS\"\nTo run your tests, invoke the \\fBbats\\fR interpreter with a path to a test file\\. The file\\'s test cases are run sequentially and in isolation\\. If all the test cases pass, \\fBbats\\fR exits with a \\fB0\\fR status code\\. If there are any failures, \\fBbats\\fR exits with a \\fB1\\fR status code\\.\n.\n.P\nYou can invoke the \\fBbats\\fR interpreter with multiple test file arguments, or with a path to a directory containing multiple \\fB\\.bats\\fR files\\. Bats will run each test file individually and aggregate the results\\. If any test case fails, \\fBbats\\fR exits with a \\fB1\\fR status code\\.\n.\n.SH \"OPTIONS\"\n.\n.TP\n\\fB\\-c\\fR, \\fB\\-\\-count\\fR\nCount the number of test cases without running any tests\n.\n.TP\n\\fB\\-h\\fR, \\fB\\-\\-help\\fR\nDisplay help message\n.\n.TP\n\\fB\\-p\\fR, \\fB\\-\\-pretty\\fR\nShow results in pretty format (default for terminals)\n.\n.TP\n\\fB\\-t\\fR, \\fB\\-\\-tap\\fR\nShow results in TAP format\n.\n.TP\n\\fB\\-v\\fR, \\fB\\-\\-version\\fR\nDisplay the version number\n.\n.SH \"OUTPUT\"\nWhen you run Bats from a terminal, you\\'ll see output as each test is performed, with a check\\-mark next to the test\\'s name if it passes or an \"X\" if it fails\\.\n.\n.IP \"\" 4\n.\n.nf\n\n$ bats addition\\.bats\n ✓ addition using bc\n ✓ addition using dc\n\n2 tests, 0 failures\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nIf Bats is not connected to a terminal\\-\\-in other words, if you run it from a continuous integration system or redirect its output to a file\\-\\-the results are displayed in human\\-readable, machine\\-parsable TAP format\\. You can force TAP output from a terminal by invoking Bats with the \\fB\\-\\-tap\\fR option\\.\n.\n.IP \"\" 4\n.\n.nf\n\n$ bats \\-\\-tap addition\\.bats\n1\\.\\.2\nok 1 addition using bc\nok 2 addition using dc\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"EXIT STATUS\"\nThe \\fBbats\\fR interpreter exits with a value of \\fB0\\fR if all test cases pass, or \\fB1\\fR if one or more test cases fail\\.\n.\n.SH \"SEE ALSO\"\nBats wiki: \\fIhttps://github\\.com/sstephenson/bats/wiki/\\fR\n.\n.P\n\\fBbash\\fR(1), \\fBbats\\fR(7)\n.\n.SH \"COPYRIGHT\"\n(c) 2014 Sam Stephenson\n.\n.P\nBats is released under the terms of an MIT\\-style license\\.\n"
  },
  {
    "path": "man/bats.1.ronn",
    "content": "bats(1) -- Bash Automated Testing System\n========================================\n\n\nSYNOPSIS\n--------\n\nbats [-c] [-p | -t] <test> [<test> ...]\n\n<test> is the path to a Bats test file, or the path to a directory\ncontaining Bats test files.\n\n\nDESCRIPTION\n-----------\n\nBats is a TAP-compliant testing framework for Bash. It provides a simple\nway to verify that the UNIX programs you write behave as expected.\n\nA Bats test file is a Bash script with special syntax for defining\ntest cases. Under the hood, each test case is just a function with a\ndescription.\n\nTest cases consist of standard shell commands. Bats makes use of\nBash's `errexit` (`set -e`) option when running test cases. If every\ncommand in the test case exits with a `0` status code (success), the\ntest passes. In this way, each line is an assertion of truth.\n\nSee `bats`(7) for more information on writing Bats tests.\n\n\nRUNNING TESTS\n-------------\n\nTo run your tests, invoke the `bats` interpreter with a path to a test\nfile. The file's test cases are run sequentially and in isolation. If\nall the test cases pass, `bats` exits with a `0` status code. If there\nare any failures, `bats` exits with a `1` status code.\n\nYou can invoke the `bats` interpreter with multiple test file arguments,\nor with a path to a directory containing multiple `.bats` files. Bats\nwill run each test file individually and aggregate the results. If any\ntest case fails, `bats` exits with a `1` status code.\n\n\nOPTIONS\n-------\n\n  * `-c`, `--count`:\n    Count the number of test cases without running any tests\n  * `-h`, `--help`:\n    Display help message\n  * `-p`, `--pretty`:\n    Show results in pretty format (default for terminals)\n  * `-t`, `--tap`:\n    Show results in TAP format\n  * `-v`, `--version`:\n    Display the version number\n\n\nOUTPUT\n------\n\nWhen you run Bats from a terminal, you'll see output as each test is\nperformed, with a check-mark next to the test's name if it passes or\nan \"X\" if it fails.\n\n    $ bats addition.bats\n     ✓ addition using bc\n     ✓ addition using dc\n\n    2 tests, 0 failures\n\nIf Bats is not connected to a terminal--in other words, if you run it\nfrom a continuous integration system or redirect its output to a\nfile--the results are displayed in human-readable, machine-parsable\nTAP format. You can force TAP output from a terminal by invoking Bats\nwith the `--tap` option.\n\n    $ bats --tap addition.bats\n    1..2\n    ok 1 addition using bc\n    ok 2 addition using dc\n\n\nEXIT STATUS\n-----------\n\nThe `bats` interpreter exits with a value of `0` if all test cases pass,\nor `1` if one or more test cases fail.\n\n\nSEE ALSO\n--------\n\nBats wiki: _https://github.com/sstephenson/bats/wiki/_\n\n`bash`(1), `bats`(7)\n\n\nCOPYRIGHT\n---------\n\n(c) 2014 Sam Stephenson\n\nBats is released under the terms of an MIT-style license.\n\n\n\n"
  },
  {
    "path": "man/bats.7",
    "content": ".\\\" generated with Ronn/v0.7.3\n.\\\" http://github.com/rtomayko/ronn/tree/0.7.3\n.\n.TH \"BATS\" \"7\" \"November 2013\" \"\" \"\"\n.\n.SH \"NAME\"\n\\fBbats\\fR \\- Bats test file format\n.\n.SH \"DESCRIPTION\"\nA Bats test file is a Bash script with special syntax for defining test cases\\. Under the hood, each test case is just a function with a description\\.\n.\n.IP \"\" 4\n.\n.nf\n\n#!/usr/bin/env bats\n\n@test \"addition using bc\" {\n  result=\"$(echo 2+2 | bc)\"\n  [ \"$result\" \\-eq 4 ]\n}\n\n@test \"addition using dc\" {\n  result=\"$(echo 2 2+p | dc)\"\n  [ \"$result\" \\-eq 4 ]\n}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nEach Bats test file is evaluated n+1 times, where \\fIn\\fR is the number of test cases in the file\\. The first run counts the number of test cases, then iterates over the test cases and executes each one in its own process\\.\n.\n.SH \"THE RUN HELPER\"\nMany Bats tests need to run a command and then make assertions about its exit status and output\\. Bats includes a \\fBrun\\fR helper that invokes its arguments as a command, saves the exit status and output into special global variables, and then returns with a \\fB0\\fR status code so you can continue to make assertions in your test case\\.\n.\n.P\nFor example, let\\'s say you\\'re testing that the \\fBfoo\\fR command, when passed a nonexistent filename, exits with a \\fB1\\fR status code and prints an error message\\.\n.\n.IP \"\" 4\n.\n.nf\n\n@test \"invoking foo with a nonexistent file prints an error\" {\n  run foo nonexistent_filename\n  [ \"$status\" \\-eq 1 ]\n  [ \"$output\" = \"foo: no such file \\'nonexistent_filename\\'\" ]\n}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nThe \\fB$status\\fR variable contains the status code of the command, and the \\fB$output\\fR variable contains the combined contents of the command\\'s standard output and standard error streams\\.\n.\n.P\nA third special variable, the \\fB$lines\\fR array, is available for easily accessing individual lines of output\\. For example, if you want to test that invoking \\fBfoo\\fR without any arguments prints usage information on the first line:\n.\n.IP \"\" 4\n.\n.nf\n\n@test \"invoking foo without arguments prints usage\" {\n  run foo\n  [ \"$status\" \\-eq 1 ]\n  [ \"${lines[0]}\" = \"usage: foo <filename>\" ]\n}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"THE LOAD COMMAND\"\nYou may want to share common code across multiple test files\\. Bats includes a convenient \\fBload\\fR command for sourcing a Bash source file relative to the location of the current test file\\. For example, if you have a Bats test in \\fBtest/foo\\.bats\\fR, the command\n.\n.IP \"\" 4\n.\n.nf\n\nload test_helper\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nwill source the script \\fBtest/test_helper\\.bash\\fR in your test file\\. This can be useful for sharing functions to set up your environment or load fixtures\\.\n.\n.SH \"THE SKIP COMMAND\"\nTests can be skipped by using the \\fBskip\\fR command at the point in a test you wish to skip\\.\n.\n.IP \"\" 4\n.\n.nf\n\n@test \"A test I don\\'t want to execute for now\" {\n  skip\n  run foo\n  [ \"$status\" \\-eq 0 ]\n}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nOptionally, you may include a reason for skipping:\n.\n.IP \"\" 4\n.\n.nf\n\n@test \"A test I don\\'t want to execute for now\" {\n  skip \"This command will return zero soon, but not now\"\n  run foo\n  [ \"$status\" \\-eq 0 ]\n}\n.\n.fi\n.\n.IP \"\" 0\n.\n.P\nOr you can skip conditionally:\n.\n.IP \"\" 4\n.\n.nf\n\n@test \"A test which should run\" {\n  if [ foo != bar ]; then\n    skip \"foo isn\\'t bar\"\n  fi\n\n  run foo\n  [ \"$status\" \\-eq 0 ]\n}\n.\n.fi\n.\n.IP \"\" 0\n.\n.SH \"SETUP AND TEARDOWN FUNCTIONS\"\nYou can define special \\fBsetup\\fR and \\fBteardown\\fR functions which run before and after each test case, respectively\\. Use these to load fixtures, set up your environment, and clean up when you\\'re done\\.\n.\n.SH \"CODE OUTSIDE OF TEST CASES\"\nYou can include code in your test file outside of \\fB@test\\fR functions\\. For example, this may be useful if you want to check for dependencies and fail immediately if they\\'re not present\\. However, any output that you print in code outside of \\fB@test\\fR, \\fBsetup\\fR or \\fBteardown\\fR functions must be redirected to \\fBstderr\\fR (\\fB>&2\\fR)\\. Otherwise, the output may cause Bats to fail by polluting the TAP stream on \\fBstdout\\fR\\.\n.\n.SH \"SPECIAL VARIABLES\"\nThere are several global variables you can use to introspect on Bats tests:\n.\n.IP \"\\(bu\" 4\n\\fB$BATS_TEST_FILENAME\\fR is the fully expanded path to the Bats test file\\.\n.\n.IP \"\\(bu\" 4\n\\fB$BATS_TEST_DIRNAME\\fR is the directory in which the Bats test file is located\\.\n.\n.IP \"\\(bu\" 4\n\\fB$BATS_TEST_NAMES\\fR is an array of function names for each test case\\.\n.\n.IP \"\\(bu\" 4\n\\fB$BATS_TEST_NAME\\fR is the name of the function containing the current test case\\.\n.\n.IP \"\\(bu\" 4\n\\fB$BATS_TEST_DESCRIPTION\\fR is the description of the current test case\\.\n.\n.IP \"\\(bu\" 4\n\\fB$BATS_TEST_NUMBER\\fR is the (1\\-based) index of the current test case in the test file\\.\n.\n.IP \"\\(bu\" 4\n\\fB$BATS_TMPDIR\\fR is the location to a directory that may be used to store temporary files\\.\n.\n.IP \"\" 0\n.\n.SH \"SEE ALSO\"\n\\fBbash\\fR(1), \\fBbats\\fR(1)\n"
  },
  {
    "path": "man/bats.7.ronn",
    "content": "bats(7) -- Bats test file format\n================================\n\n\nDESCRIPTION\n-----------\n\nA Bats test file is a Bash script with special syntax for defining\ntest cases. Under the hood, each test case is just a function with a\ndescription.\n\n    #!/usr/bin/env bats\n\n    @test \"addition using bc\" {\n      result=\"$(echo 2+2 | bc)\"\n      [ \"$result\" -eq 4 ]\n    }\n\n    @test \"addition using dc\" {\n      result=\"$(echo 2 2+p | dc)\"\n      [ \"$result\" -eq 4 ]\n    }\n\n\nEach Bats test file is evaluated n+1 times, where _n_ is the number of\ntest cases in the file. The first run counts the number of test cases,\nthen iterates over the test cases and executes each one in its own\nprocess.\n\n\nTHE RUN HELPER\n--------------\n\nMany Bats tests need to run a command and then make assertions about\nits exit status and output. Bats includes a `run` helper that invokes\nits arguments as a command, saves the exit status and output into\nspecial global variables, and then returns with a `0` status code so\nyou can continue to make assertions in your test case.\n\nFor example, let's say you're testing that the `foo` command, when\npassed a nonexistent filename, exits with a `1` status code and prints\nan error message.\n\n    @test \"invoking foo with a nonexistent file prints an error\" {\n      run foo nonexistent_filename\n      [ \"$status\" -eq 1 ]\n      [ \"$output\" = \"foo: no such file 'nonexistent_filename'\" ]\n    }\n\nThe `$status` variable contains the status code of the command, and\nthe `$output` variable contains the combined contents of the command's\nstandard output and standard error streams.\n\nA third special variable, the `$lines` array, is available for easily\naccessing individual lines of output. For example, if you want to test\nthat invoking `foo` without any arguments prints usage information on\nthe first line:\n\n    @test \"invoking foo without arguments prints usage\" {\n      run foo\n      [ \"$status\" -eq 1 ]\n      [ \"${lines[0]}\" = \"usage: foo <filename>\" ]\n    }\n\n\nTHE LOAD COMMAND\n----------------\n\nYou may want to share common code across multiple test files. Bats\nincludes a convenient `load` command for sourcing a Bash source file\nrelative to the location of the current test file. For example, if you\nhave a Bats test in `test/foo.bats`, the command\n\n    load test_helper\n\nwill source the script `test/test_helper.bash` in your test file. This\ncan be useful for sharing functions to set up your environment or load\nfixtures.\n\n\nTHE SKIP COMMAND\n----------------\n\nTests can be skipped by using the `skip` command at the point in a\ntest you wish to skip.\n\n    @test \"A test I don't want to execute for now\" {\n      skip\n      run foo\n      [ \"$status\" -eq 0 ]\n    }\n\nOptionally, you may include a reason for skipping:\n\n    @test \"A test I don't want to execute for now\" {\n      skip \"This command will return zero soon, but not now\"\n      run foo\n      [ \"$status\" -eq 0 ]\n    }\n\nOr you can skip conditionally:\n\n    @test \"A test which should run\" {\n      if [ foo != bar ]; then\n        skip \"foo isn't bar\"\n      fi\n\n      run foo\n      [ \"$status\" -eq 0 ]\n    }\n\n\nSETUP AND TEARDOWN FUNCTIONS\n----------------------------\n\nYou can define special `setup` and `teardown` functions which run\nbefore and after each test case, respectively. Use these to load\nfixtures, set up your environment, and clean up when you're done.\n\n\nCODE OUTSIDE OF TEST CASES\n--------------------------\n\nYou can include code in your test file outside of `@test` functions.\nFor example, this may be useful if you want to check for dependencies\nand fail immediately if they're not present. However, any output that\nyou print in code outside of `@test`, `setup` or `teardown` functions\nmust be redirected to `stderr` (`>&2`). Otherwise, the output may\ncause Bats to fail by polluting the TAP stream on `stdout`.\n\n\nSPECIAL VARIABLES\n-----------------\n\nThere are several global variables you can use to introspect on Bats\ntests:\n\n* `$BATS_TEST_FILENAME` is the fully expanded path to the Bats test\nfile.\n* `$BATS_TEST_DIRNAME` is the directory in which the Bats test file is\nlocated.\n* `$BATS_TEST_NAMES` is an array of function names for each test case.\n* `$BATS_TEST_NAME` is the name of the function containing the current\ntest case.\n* `$BATS_TEST_DESCRIPTION` is the description of the current test\ncase.\n* `$BATS_TEST_NUMBER` is the (1-based) index of the current test case\nin the test file.\n* `$BATS_TMPDIR` is the location to a directory that may be used to\nstore temporary files.\n\n\nSEE ALSO\n--------\n\n`bash`(1), `bats`(1)\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"bats\",\n  \"version\": \"v0.4.0\",\n  \"description\": \"Bash Automated Testing System\",\n  \"install\": \"./install.sh ${PREFIX:-/usr/local}\",\n  \"scripts\": [ \"libexec/bats\", \"libexec/bats-exec-suite\", \"libexec/bats-exec-test\", \"libexec/bats-format-tap-stream\", \"libexec/bats-preprocess\", \"bin/bats\" ]\n}\n\n"
  },
  {
    "path": "test/bats.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\nfixtures bats\n\n@test \"no arguments prints usage instructions\" {\n  run bats\n  [ $status -eq 1 ]\n  [ $(expr \"${lines[1]}\" : \"Usage:\") -ne 0 ]\n}\n\n@test \"-v and --version print version number\" {\n  run bats -v\n  [ $status -eq 0 ]\n  [ $(expr \"$output\" : \"Bats [0-9][0-9.]*\") -ne 0 ]\n}\n\n@test \"-h and --help print help\" {\n  run bats -h\n  [ $status -eq 0 ]\n  [ \"${#lines[@]}\" -gt 3 ]\n}\n\n@test \"invalid filename prints an error\" {\n  run bats nonexistent\n  [ $status -eq 1 ]\n  [ $(expr \"$output\" : \".*does not exist\") -ne 0 ]\n}\n\n@test \"empty test file runs zero tests\" {\n  run bats \"$FIXTURE_ROOT/empty.bats\"\n  [ $status -eq 0 ]\n  [ \"$output\" = \"1..0\" ]\n}\n\n@test \"one passing test\" {\n  run bats \"$FIXTURE_ROOT/passing.bats\"\n  [ $status -eq 0 ]\n  [ \"${lines[0]}\" = \"1..1\" ]\n  [ \"${lines[1]}\" = \"ok 1 a passing test\" ]\n}\n\n@test \"summary passing tests\" {\n  run filter_control_sequences bats -p $FIXTURE_ROOT/passing.bats\n  [ $status -eq 0 ]\n  [ \"${lines[1]}\" = \"1 test, 0 failures\" ]\n}\n\n@test \"summary passing and skipping tests\" {\n  run filter_control_sequences bats -p $FIXTURE_ROOT/passing_and_skipping.bats\n  [ $status -eq 0 ]\n  [ \"${lines[2]}\" = \"2 tests, 0 failures, 1 skipped\" ]\n}\n\n@test \"summary passing and failing tests\" {\n  run filter_control_sequences bats -p $FIXTURE_ROOT/failing_and_passing.bats\n  [ $status -eq 0 ]\n  [ \"${lines[4]}\" = \"2 tests, 1 failure\" ]\n}\n\n@test \"summary passing, failing and skipping tests\" {\n  run filter_control_sequences bats -p $FIXTURE_ROOT/passing_failing_and_skipping.bats\n  [ $status -eq 0 ]\n  [ \"${lines[5]}\" = \"3 tests, 1 failure, 1 skipped\" ]\n}\n\n@test \"one failing test\" {\n  run bats \"$FIXTURE_ROOT/failing.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" = '1..1' ]\n  [ \"${lines[1]}\" = 'not ok 1 a failing test' ]\n  [ \"${lines[2]}\" = \"# (in test file $RELATIVE_FIXTURE_ROOT/failing.bats, line 4)\" ]\n  [ \"${lines[3]}\" = \"#   \\`eval \\\"( exit \\${STATUS:-1} )\\\"' failed\" ]\n}\n\n@test \"one failing and one passing test\" {\n  run bats \"$FIXTURE_ROOT/failing_and_passing.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" = '1..2' ]\n  [ \"${lines[1]}\" = 'not ok 1 a failing test' ]\n  [ \"${lines[2]}\" = \"# (in test file $RELATIVE_FIXTURE_ROOT/failing_and_passing.bats, line 2)\" ]\n  [ \"${lines[3]}\" = \"#   \\`false' failed\" ]\n  [ \"${lines[4]}\" = 'ok 2 a passing test' ]\n}\n\n@test \"failing test with significant status\" {\n  STATUS=2 run bats \"$FIXTURE_ROOT/failing.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[3]}\" = \"#   \\`eval \\\"( exit \\${STATUS:-1} )\\\"' failed with status 2\" ]\n}\n\n@test \"failing helper function logs the test case's line number\" {\n  run bats \"$FIXTURE_ROOT/failing_helper.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[1]}\" = 'not ok 1 failing helper function' ]\n  [ \"${lines[2]}\" = \"# (from function \\`failing_helper' in file $RELATIVE_FIXTURE_ROOT/test_helper.bash, line 6,\" ]\n  [ \"${lines[3]}\" = \"#  in test file $RELATIVE_FIXTURE_ROOT/failing_helper.bats, line 5)\" ]\n  [ \"${lines[4]}\" = \"#   \\`failing_helper' failed\" ]\n}\n\n@test \"test environments are isolated\" {\n  run bats \"$FIXTURE_ROOT/environment.bats\"\n  [ $status -eq 0 ]\n}\n\n@test \"setup is run once before each test\" {\n  rm -f \"$TMP/setup.log\"\n  run bats \"$FIXTURE_ROOT/setup.bats\"\n  [ $status -eq 0 ]\n  run cat \"$TMP/setup.log\"\n  [ ${#lines[@]} -eq 3 ]\n}\n\n@test \"teardown is run once after each test, even if it fails\" {\n  rm -f \"$TMP/teardown.log\"\n  run bats \"$FIXTURE_ROOT/teardown.bats\"\n  [ $status -eq 1 ]\n  run cat \"$TMP/teardown.log\"\n  [ ${#lines[@]} -eq 3 ]\n}\n\n@test \"setup failure\" {\n  run bats \"$FIXTURE_ROOT/failing_setup.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[1]}\" = 'not ok 1 truth' ]\n  [ \"${lines[2]}\" = \"# (from function \\`setup' in test file $RELATIVE_FIXTURE_ROOT/failing_setup.bats, line 2)\" ]\n  [ \"${lines[3]}\" = \"#   \\`false' failed\" ]\n}\n\n@test \"passing test with teardown failure\" {\n  PASS=1 run bats \"$FIXTURE_ROOT/failing_teardown.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[1]}\" = 'not ok 1 truth' ]\n  [ \"${lines[2]}\" = \"# (from function \\`teardown' in test file $RELATIVE_FIXTURE_ROOT/failing_teardown.bats, line 2)\" ]\n  [ \"${lines[3]}\" = \"#   \\`eval \\\"( exit \\${STATUS:-1} )\\\"' failed\" ]\n}\n\n@test \"failing test with teardown failure\" {\n  PASS=0 run bats \"$FIXTURE_ROOT/failing_teardown.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[1]}\" =  'not ok 1 truth' ]\n  [ \"${lines[2]}\" =  \"# (in test file $RELATIVE_FIXTURE_ROOT/failing_teardown.bats, line 6)\" ]\n  [ \"${lines[3]}\" = $'#   `[ \"$PASS\" = \"1\" ]\\' failed' ]\n}\n\n@test \"teardown failure with significant status\" {\n  PASS=1 STATUS=2 run bats \"$FIXTURE_ROOT/failing_teardown.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[3]}\" = \"#   \\`eval \\\"( exit \\${STATUS:-1} )\\\"' failed with status 2\" ]\n}\n\n@test \"failing test file outside of BATS_CWD\" {\n  cd \"$TMP\"\n  run bats \"$FIXTURE_ROOT/failing.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[2]}\" = \"# (in test file $FIXTURE_ROOT/failing.bats, line 4)\" ]\n}\n\n@test \"load sources scripts relative to the current test file\" {\n  run bats \"$FIXTURE_ROOT/load.bats\"\n  [ $status -eq 0 ]\n}\n\n@test \"load aborts if the specified script does not exist\" {\n  HELPER_NAME=\"nonexistent\" run bats \"$FIXTURE_ROOT/load.bats\"\n  [ $status -eq 1 ]\n}\n\n@test \"load sources scripts by absolute path\" {\n  HELPER_NAME=\"${FIXTURE_ROOT}/test_helper.bash\" run bats \"$FIXTURE_ROOT/load.bats\"\n  [ $status -eq 0 ]\n}\n\n@test \"load aborts if the script, specified by an absolute path, does not exist\" {\n  HELPER_NAME=\"${FIXTURE_ROOT}/nonexistent\" run bats \"$FIXTURE_ROOT/load.bats\"\n  [ $status -eq 1 ]\n}\n\n@test \"output is discarded for passing tests and printed for failing tests\" {\n  run bats \"$FIXTURE_ROOT/output.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[6]}\"  = '# failure stdout 1' ]\n  [ \"${lines[7]}\"  = '# failure stdout 2' ]\n  [ \"${lines[11]}\" = '# failure stderr' ]\n}\n\n@test \"-c prints the number of tests\" {\n  run bats -c \"$FIXTURE_ROOT/empty.bats\"\n  [ $status -eq 0 ]\n  [ \"$output\" = \"0\" ]\n\n  run bats -c \"$FIXTURE_ROOT/output.bats\"\n  [ $status -eq 0 ]\n  [ \"$output\" = \"4\" ]\n}\n\n@test \"dash-e is not mangled on beginning of line\" {\n  run bats \"$FIXTURE_ROOT/intact.bats\"\n  [ $status -eq 0 ]\n  [ \"${lines[1]}\" = \"ok 1 dash-e on beginning of line\" ]\n}\n\n@test \"dos line endings are stripped before testing\" {\n  run bats \"$FIXTURE_ROOT/dos_line.bats\"\n  [ $status -eq 0 ]\n}\n\n@test \"test file without trailing newline\" {\n  run bats \"$FIXTURE_ROOT/without_trailing_newline.bats\"\n  [ $status -eq 0 ]\n  [ \"${lines[1]}\" = \"ok 1 truth\" ]\n}\n\n@test \"skipped tests\" {\n  run bats \"$FIXTURE_ROOT/skipped.bats\"\n  [ $status -eq 0 ]\n  [ \"${lines[1]}\" = \"ok 1 # skip a skipped test\" ]\n  [ \"${lines[2]}\" = \"ok 2 # skip (a reason) a skipped test with a reason\" ]\n}\n\n@test \"extended syntax\" {\n  run bats-exec-test -x \"$FIXTURE_ROOT/failing_and_passing.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[1]}\" = 'begin 1 a failing test' ]\n  [ \"${lines[2]}\" = 'not ok 1 a failing test' ]\n  [ \"${lines[5]}\" = 'begin 2 a passing test' ]\n  [ \"${lines[6]}\" = 'ok 2 a passing test' ]\n}\n\n@test \"pretty and tap formats\" {\n  run bats --tap \"$FIXTURE_ROOT/passing.bats\"\n  tap_output=\"$output\"\n  [ $status -eq 0 ]\n\n  run bats --pretty \"$FIXTURE_ROOT/passing.bats\"\n  pretty_output=\"$output\"\n  [ $status -eq 0 ]\n\n  [ \"$tap_output\" != \"$pretty_output\" ]\n}\n\n@test \"pretty formatter bails on invalid tap\" {\n  run bats --tap \"$FIXTURE_ROOT/invalid_tap.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" = \"This isn't TAP!\" ]\n  [ \"${lines[1]}\" = \"Good day to you\" ]\n}\n\n@test \"single-line tests\" {\n  run bats \"$FIXTURE_ROOT/single_line.bats\"\n  [ $status -eq 1 ]\n  [ \"${lines[1]}\" =  'ok 1 empty' ]\n  [ \"${lines[2]}\" =  'ok 2 passing' ]\n  [ \"${lines[3]}\" =  'ok 3 input redirection' ]\n  [ \"${lines[4]}\" =  'not ok 4 failing' ]\n  [ \"${lines[5]}\" =  \"# (in test file $RELATIVE_FIXTURE_ROOT/single_line.bats, line 9)\" ]\n  [ \"${lines[6]}\" = $'#   `@test \"failing\" { false; }\\' failed' ]\n}\n\n@test \"testing IFS not modified by run\" {\n  run bats \"$FIXTURE_ROOT/loop_keep_IFS.bats\"\n  [ $status -eq 0 ]\n  [ \"${lines[1]}\" = \"ok 1 loop_func\" ]\n}\n"
  },
  {
    "path": "test/fixtures/bats/dos_line.bats",
    "content": "@test \"foo\" {\r\r\n  echo \"foo\"\r\r\n}\r\r\n"
  },
  {
    "path": "test/fixtures/bats/empty.bats",
    "content": ""
  },
  {
    "path": "test/fixtures/bats/environment.bats",
    "content": "@test \"setting a variable\" {\n  variable=1\n  [ $variable -eq 1 ]\n}\n\n@test \"variables do not persist across tests\" {\n  [ -z \"$variable\" ]\n}\n"
  },
  {
    "path": "test/fixtures/bats/failing.bats",
    "content": "@test \"a failing test\" {\n  true\n  true\n  eval \"( exit ${STATUS:-1} )\"\n}\n"
  },
  {
    "path": "test/fixtures/bats/failing_and_passing.bats",
    "content": "@test \"a failing test\" {\n  false\n}\n\n@test \"a passing test\" {\n  true\n}\n"
  },
  {
    "path": "test/fixtures/bats/failing_helper.bats",
    "content": "load \"test_helper\"\n\n@test \"failing helper function\" {\n  true\n  failing_helper\n}\n"
  },
  {
    "path": "test/fixtures/bats/failing_setup.bats",
    "content": "setup() {\n  false\n}\n\n@test \"truth\" {\n  true\n}\n"
  },
  {
    "path": "test/fixtures/bats/failing_teardown.bats",
    "content": "teardown() {\n  eval \"( exit ${STATUS:-1} )\"\n}\n\n@test \"truth\" {\n  [ \"$PASS\" = \"1\" ]\n}\n"
  },
  {
    "path": "test/fixtures/bats/intact.bats",
    "content": "@test \"dash-e on beginning of line\" {\n  run cat - <<INPUT\n-e\nINPUT\n  test \"$output\" = \"-e\"\n}\n"
  },
  {
    "path": "test/fixtures/bats/invalid_tap.bats",
    "content": "echo \"This isn't TAP!\"\necho \"Good day to you\"\nexit 1\n\n@test \"truth\" {\n  true\n}\n"
  },
  {
    "path": "test/fixtures/bats/load.bats",
    "content": "[ -n \"$HELPER_NAME\" ] || HELPER_NAME=\"test_helper\"\nload \"$HELPER_NAME\"\n\n@test \"calling a loaded helper\" {\n  help_me\n}\n"
  },
  {
    "path": "test/fixtures/bats/loop_keep_IFS.bats",
    "content": "# see issue #89\nloop_func() {\n  local search=\"none one two tree\"\n  local d\n\n  for d in $search ; do\n    echo $d\n  done\n}\n\n@test \"loop_func\" {\n  run loop_func\n  [[ \"${lines[3]}\" == 'tree' ]]\n  run loop_func\n  [[ \"${lines[2]}\" == 'two' ]]\n}\n"
  },
  {
    "path": "test/fixtures/bats/output.bats",
    "content": "@test \"success writing to stdout\" {\n  echo \"success stdout 1\"\n  echo \"success stdout 2\"\n}\n\n@test \"success writing to stderr\" {\n  echo \"success stderr\" >&2\n}\n\n@test \"failure writing to stdout\" {\n  echo \"failure stdout 1\"\n  echo \"failure stdout 2\"\n  false\n}\n\n@test \"failure writing to stderr\" {\n  echo \"failure stderr\" >&2\n  false\n}\n"
  },
  {
    "path": "test/fixtures/bats/passing.bats",
    "content": "@test \"a passing test\" {\n  true\n}\n"
  },
  {
    "path": "test/fixtures/bats/passing_and_failing.bats",
    "content": "@test \"a passing test\" {\n  true\n}\n\n@test \"a failing test\" {\n  false\n}\n"
  },
  {
    "path": "test/fixtures/bats/passing_and_skipping.bats",
    "content": "@test \"a passing test\" {\n  true\n}\n\n@test \"a skipping test\" {\n  skip\n}\n"
  },
  {
    "path": "test/fixtures/bats/passing_failing_and_skipping.bats",
    "content": "@test \"a passing test\" {\n  true\n}\n\n@test \"a skipping test\" {\n  skip\n}\n\n@test \"a failing test\" {\n  false\n}\n"
  },
  {
    "path": "test/fixtures/bats/setup.bats",
    "content": "LOG=\"$TMP/setup.log\"\n\nsetup() {\n  echo \"$BATS_TEST_NAME\" >> \"$LOG\"\n}\n\n@test \"one\" {\n  [ \"$(tail -n 1 \"$LOG\")\" = \"test_one\" ]\n}\n\n@test \"two\" {\n  [ \"$(tail -n 1 \"$LOG\")\" = \"test_two\" ]\n}\n\n@test \"three\" {\n  [ \"$(tail -n 1 \"$LOG\")\" = \"test_three\" ]\n}\n"
  },
  {
    "path": "test/fixtures/bats/single_line.bats",
    "content": "@test \"empty\" { }\n\n@test \"passing\" { true; }\n\n@test \"input redirection\" { diff - <( echo hello ); } <<EOS\nhello\nEOS\n\n@test \"failing\" { false; }\n"
  },
  {
    "path": "test/fixtures/bats/skipped.bats",
    "content": "@test \"a skipped test\" {\n  skip\n}\n\n@test \"a skipped test with a reason\" {\n  skip \"a reason\"\n}\n"
  },
  {
    "path": "test/fixtures/bats/teardown.bats",
    "content": "LOG=\"$TMP/teardown.log\"\n\nteardown() {\n  echo \"$BATS_TEST_NAME\" >> \"$LOG\"\n}\n\n@test \"one\" {\n  true\n}\n\n@test \"two\" {\n  false\n}\n\n@test \"three\" {\n  true\n}\n"
  },
  {
    "path": "test/fixtures/bats/test_helper.bash",
    "content": "help_me() {\n  true\n}\n\nfailing_helper() {\n  false\n}\n"
  },
  {
    "path": "test/fixtures/bats/without_trailing_newline.bats",
    "content": "@test \"truth\" {\n  true\n}"
  },
  {
    "path": "test/fixtures/suite/empty/.gitkeep",
    "content": ""
  },
  {
    "path": "test/fixtures/suite/multiple/a.bats",
    "content": "@test \"truth\" {\n  true\n}\n"
  },
  {
    "path": "test/fixtures/suite/multiple/b.bats",
    "content": "@test \"more truth\" {\n  true\n}\n\n@test \"quasi-truth\" {\n  [ -z \"$FLUNK\" ]\n}\n"
  },
  {
    "path": "test/fixtures/suite/single/test.bats",
    "content": "@test \"a passing test\" {\n  true\n}\n"
  },
  {
    "path": "test/suite.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\nfixtures suite\n\n@test \"running a suite with no test files\" {\n  run bats \"$FIXTURE_ROOT/empty\"\n  [ $status -eq 0 ]\n  [ \"$output\" = \"1..0\" ]\n}\n\n@test \"running a suite with one test file\" {\n  run bats \"$FIXTURE_ROOT/single\"\n  [ $status -eq 0 ]\n  [ \"${lines[0]}\" = \"1..1\" ]\n  [ \"${lines[1]}\" = \"ok 1 a passing test\" ]\n}\n\n@test \"counting tests in a suite\" {\n  run bats -c \"$FIXTURE_ROOT/single\"\n  [ $status -eq 0 ]\n  [ \"$output\" -eq 1 ]\n\n  run bats -c \"$FIXTURE_ROOT/multiple\"\n  [ $status -eq 0 ]\n  [ \"$output\" -eq 3 ]\n}\n\n@test \"aggregated output of multiple tests in a suite\" {\n  run bats \"$FIXTURE_ROOT/multiple\"\n  [ $status -eq 0 ]\n  [ \"${lines[0]}\" = \"1..3\" ]\n  echo \"$output\" | grep \"^ok . truth\"\n  echo \"$output\" | grep \"^ok . more truth\"\n  echo \"$output\" | grep \"^ok . quasi-truth\"\n}\n\n@test \"a failing test in a suite results in an error exit code\" {\n  FLUNK=1 run bats \"$FIXTURE_ROOT/multiple\"\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" = \"1..3\" ]\n  echo \"$output\" | grep \"^not ok . quasi-truth\"\n}\n\n@test \"running an ad-hoc suite by specifying multiple test files\" {\n  run bats \"$FIXTURE_ROOT/multiple/a.bats\" \"$FIXTURE_ROOT/multiple/b.bats\"\n  [ $status -eq 0 ]\n  [ \"${lines[0]}\" = \"1..3\" ]\n  echo \"$output\" | grep \"^ok . truth\"\n  echo \"$output\" | grep \"^ok . more truth\"\n  echo \"$output\" | grep \"^ok . quasi-truth\"\n}\n\n@test \"extended syntax in suite\" {\n  FLUNK=1 run bats-exec-suite -x \"$FIXTURE_ROOT/multiple/\"*.bats\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" = \"1..3\" ]\n  [ \"${lines[1]}\" = \"begin 1 truth\" ]\n  [ \"${lines[2]}\" = \"ok 1 truth\" ]\n  [ \"${lines[3]}\" = \"begin 2 more truth\" ]\n  [ \"${lines[4]}\" = \"ok 2 more truth\" ]\n  [ \"${lines[5]}\" = \"begin 3 quasi-truth\" ]\n  [ \"${lines[6]}\" = \"not ok 3 quasi-truth\" ]\n}\n"
  },
  {
    "path": "test/test_helper.bash",
    "content": "fixtures() {\n  FIXTURE_ROOT=\"$BATS_TEST_DIRNAME/fixtures/$1\"\n  RELATIVE_FIXTURE_ROOT=\"$(bats_trim_filename \"$FIXTURE_ROOT\")\"\n}\n\nsetup() {\n  export TMP=\"$BATS_TEST_DIRNAME/tmp\"\n}\n\nfilter_control_sequences() {\n  \"$@\" | sed $'s,\\x1b\\\\[[0-9;]*[a-zA-Z],,g'\n}\n\nteardown() {\n  [ -d \"$TMP\" ] && rm -f \"$TMP\"/*\n}\n"
  }
]