1
0
Fork 0
mirror of synced 2024-11-22 00:05:34 -05:00
dotbot/test
Anish Athalye c5e709d433 Make error for empty config a little friendlier
In the setup guide in the README, we have people start out with an empty
file (created using `touch`). Before this patch, Dotbot gave the
following error:

    Configuration file must be a list of tasks

Instead, with this patch, Dotbot says:

    Configuration file is empty, no work to do

This change was prompted by
https://github.com/anishathalye/dotbot/pull/226.
2020-06-25 16:07:23 -04:00
..
tests Make error for empty config a little friendlier 2020-06-25 16:07:23 -04:00
.editorconfig Add tests for more Python versions 2017-03-06 15:20:27 -05:00
.gitignore Add testing framework and tests 2015-05-05 20:11:46 -04:00
driver-lib.bash Unify Vagrant and Travis-CI tests 2020-01-03 15:34:46 -05:00
README.md Unify Vagrant and Travis-CI tests 2020-01-03 15:34:46 -05:00
test Unify Vagrant and Travis-CI tests 2020-01-03 15:34:46 -05:00
test-lib.bash Unify Vagrant and Travis-CI tests 2020-01-03 15:34:46 -05:00
Vagrantfile Unify Vagrant and Travis-CI tests 2020-01-03 15:34:46 -05:00

Testing

Dotbot testing code uses Vagrant to run all tests inside a virtual machine to have tests be completely isolated from the host machine.

Installing the Test environnement

Debian-based distributions

  • Install the test requirements
sudo apt install vagrant virtualbox
  • Install Dotbot dependencies
git submodule update --init --recursive

macOS

git submodule update --init --recursive

Running the Tests

Before running the tests, you must SSH into the VM. Start it with vagrant up and SSH in with vagrant ssh. All following commands must be run inside the VM.

First, you must install a version of Python to test against, using pyenv install -s {version}. 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 pyenv global {version}.

The VM mounts the Dotbot directory in /dotbot as read-only (you can make edits on your host machine). You can run the test suite by cd /dotbot/test and then running ./test. Selected tests can be run by passing paths to the tests as arguments, e.g. ./test tests/create.bash tests/defaults.bash.

To debug tests, you can prepend the line DEBUG=true as the first line to any individual test (a .bash file inside test/tests). This will enable printing stdout/stderr.

When finished with testing, it is good to shut down the virtual machine by running vagrant halt.