Skip to content
Anders Ingemann edited this page Apr 22, 2014 · 4 revisions

homeshick comes with testsuites which ensure that the tool runs to spec after a feature was added or a refactor performed. It uses bats to run these suites and determine the outcome of the tests.

To run all tests, simply invoke the run script in the test/ folder. Individual test suites can be run by executing the files in the test/suites/ folder.

Dependencies

To run tests, only bats is required. On OSX it can be install through homebrew, though the bats install script makes it fairly easy to install on all platforms.

Additionally expect can be installed to test the interactive prompts (these tests will be skipped if expect cannot be found).

Fixtures

To run the tests in a stable manner, fixtures are needed. In the context of homeshick, those fixtures are git repositories. Each repository is created by a script of the same name in test/fixtures/.

Interactive testing

When developing for homeshick some form of manual testing is often needed to quickly confirm that a feature behaves in a specific way. The test/interactive script can be run to drop in to a shell where $HOME is set to a temporary folder and the shell is the one the script was invoked from. To launch into a different shell, the script takes a single argument of the shell executable that should be used.

homeshick will automatically be symlinked to point at the version in your git working copy so that any changes can be tested quickly.

To drop into a preconfigured homefolder where the homeshick function is defined and various dotfiles exist, a setup.sh file can be added to the test/ folder. It will automatically be executed everytime an interactive environment is set up.

In case the file does not exist test/setup-default.sh will be used instead. This script creates various rc-files for different shells that define the homeshick function or alias.

GNU coreutils on OSX

The GNU core utilities can be installed via homebrew on OSX and also configured to override the built-in OSX utilities by modifying the $PATH. The run and interactive scripts automatically remove that override from $PATH if it is detected, in order to test homeshick with the built-in OSX utilities.

If you want to preserve the GNU coreutils path in your $PATH while running tests or using the test/interactive script, you must set the environment variable $HOMESHICK_KEEP_PATH to true (export HOMESHICK_KEEP_PATH=true).

Clone this wiki locally