2015-05-05 19:58:25 -04:00
|
|
|
Testing
|
|
|
|
=======
|
|
|
|
|
2018-03-27 20:56:55 -04:00
|
|
|
Dotbot testing code uses [Vagrant] to run all tests inside a virtual machine to
|
2021-05-27 11:13:43 -04:00
|
|
|
have tests be completely isolated from the host machine. Specifically, you
|
|
|
|
will need both:
|
2015-05-05 19:58:25 -04:00
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
- [VirtualBox]
|
|
|
|
- [Vagrant]
|
2017-05-31 16:19:57 -04:00
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
Install Dotbot dependencies
|
|
|
|
---------------------------
|
2017-05-31 16:19:57 -04:00
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
Ensure you have updated the `dotbot` submodule dependencies, on the host machine:
|
2017-05-31 16:19:57 -04:00
|
|
|
|
|
|
|
```bash
|
2021-05-27 11:13:43 -04:00
|
|
|
git submodule sync --quiet --recursive
|
|
|
|
git submodule update --init --recursive
|
2017-05-31 16:19:57 -04:00
|
|
|
```
|
2021-05-27 11:13:43 -04:00
|
|
|
Install Vagrant
|
|
|
|
---------------
|
2017-05-31 16:19:57 -04:00
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
### Debian-based distributions
|
2017-05-31 16:19:57 -04:00
|
|
|
|
|
|
|
```bash
|
2021-05-27 11:13:43 -04:00
|
|
|
sudo apt install vagrant virtualbox
|
2017-05-31 16:19:57 -04:00
|
|
|
```
|
|
|
|
|
2018-03-27 17:42:42 -04:00
|
|
|
### macOS
|
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
You can download those directly from the above URLs, or via some MacOS package managers.
|
|
|
|
e.g. using [HomeBrew](https://brew.sh/):
|
2018-03-27 17:42:42 -04:00
|
|
|
|
|
|
|
```bash
|
2021-05-27 11:13:43 -04:00
|
|
|
brew cask install virtualbox
|
|
|
|
brew cask install vagrant
|
|
|
|
# optional, adding menu-bar support:
|
|
|
|
brew cask install vagrant-manager
|
2018-03-27 17:42:42 -04:00
|
|
|
```
|
|
|
|
|
2015-05-05 19:58:25 -04:00
|
|
|
Running the Tests
|
|
|
|
-----------------
|
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
Before running the tests, you must start and `ssh` into the VM:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
vagrant up
|
|
|
|
vagrant ssh
|
|
|
|
```
|
|
|
|
|
|
|
|
All remaining commands are run inside the VM.
|
|
|
|
|
|
|
|
First, you must install a version of Python to test against, using:
|
|
|
|
|
|
|
|
pyenv install -s {version}
|
2020-01-03 15:20:00 -05:00
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
You can choose any version you like, e.g. `3.8.1`. It isn't particularly
|
|
|
|
important to test against all supported versions of Python in the VM, because
|
|
|
|
they will be tested by CI. Once you've installed a specific version of Python,
|
|
|
|
activate it with:
|
2020-01-03 15:20:00 -05:00
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
pyenv global {version}
|
|
|
|
|
|
|
|
The VM mounts your host's Dotbot directory in `/dotbot` as read-only, allowing
|
|
|
|
you to make edits on your host machine. Run the entire test suite by:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cd /dotbot/test
|
|
|
|
./test
|
|
|
|
```
|
|
|
|
|
|
|
|
Selected tests can be run by passing paths to the tests as arguments, e.g.:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
./test tests/create.bash tests/defaults.bash
|
|
|
|
```
|
2020-01-03 15:20:00 -05:00
|
|
|
|
2021-02-25 08:14:34 -05:00
|
|
|
To debug tests, you can run the test driver with the `--debug` (or `-d` short
|
|
|
|
form) flag, e.g. `./test --debug tests/link-if.bash`. This will enable printing
|
2020-01-03 15:20:00 -05:00
|
|
|
stdout/stderr.
|
2015-10-22 21:46:28 -04:00
|
|
|
|
2015-05-05 19:58:25 -04:00
|
|
|
When finished with testing, it is good to shut down the virtual machine by
|
|
|
|
running `vagrant halt`.
|
|
|
|
|
2021-05-27 11:13:43 -04:00
|
|
|
[VirtualBox]: https://www.virtualbox.org/
|
2018-03-27 20:56:55 -04:00
|
|
|
[Vagrant]: https://www.vagrantup.com/
|