Hello HN!<p>I've been looking at alternatives on how to test command line applications, specifically, for example, exit codes, output messages and whatnot. I've seen "bats" https://github.com/sstephenson/bats and Bazel for testing but I'm curious as what other tools people use in a day to day basis. UI testing is nice with tools like Cypress.io and maybe there's something out there that isn't as popular but it's useful.<p>Thoughts?
pytest-docker-pexpect: <a href="https://github.com/nvbn/pytest-docker-pexpect" rel="nofollow">https://github.com/nvbn/pytest-docker-pexpect</a><p>Pexpect: <a href="https://pexpect.readthedocs.io/en/stable/" rel="nofollow">https://pexpect.readthedocs.io/en/stable/</a><p>pytest with subprocess.popen (or Sarge) may be sufficient for checking return codes and checking stdout and stderr output streams. Pytest has tmp_path and tmpdir fixtures that provide less test isolation than Docker containers: <a href="http://doc.pytest.org/en/latest/tmpdir.html" rel="nofollow">http://doc.pytest.org/en/latest/tmpdir.html</a><p>sarge.Capture.expect() takes a regex and returns None if there's no match: <a href="https://sarge.readthedocs.io/en/latest/tutorial.html#looking-for-specific-patterns-in-child-process-output" rel="nofollow">https://sarge.readthedocs.io/en/latest/tutorial.html#looking...</a>
If you like Cucumber <a href="https://github.com/cucumber/aruba" rel="nofollow">https://github.com/cucumber/aruba</a>