diff options
author | nodiscc <nodiscc@gmail.com> | 2020-01-19 13:18:29 +0100 |
---|---|---|
committer | nodiscc <nodiscc@gmail.com> | 2020-01-19 13:18:29 +0100 |
commit | 54ab5636e3a4f496ed96178470f50dec6c6196b2 (patch) | |
tree | e99612d755dbb48897910f46b24baf04880acf15 | |
parent | a8a38401f006fdaeb97896ed1c6429d0ab825eb8 (diff) | |
download | Shaarli-54ab5636e3a4f496ed96178470f50dec6c6196b2.tar.gz Shaarli-54ab5636e3a4f496ed96178470f50dec6c6196b2.tar.zst Shaarli-54ab5636e3a4f496ed96178470f50dec6c6196b2.zip |
doc: merge unit tests/docker unit tests pages, simplfy, reword
-rw-r--r-- | doc/md/Unit-tests-Docker.md | 56 | ||||
-rw-r--r-- | doc/md/Unit-tests.md | 53 | ||||
-rw-r--r-- | mkdocs.yml | 1 |
3 files changed, 48 insertions, 62 deletions
diff --git a/doc/md/Unit-tests-Docker.md b/doc/md/Unit-tests-Docker.md deleted file mode 100644 index 59bd5b45..00000000 --- a/doc/md/Unit-tests-Docker.md +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | ## Running tests inside Docker containers | ||
2 | |||
3 | Read first: | ||
4 | |||
5 | - [Docker 101](docker/docker-101.md) | ||
6 | - [Docker resources](docker/resources.md) | ||
7 | - [Unit tests](Unit-tests.md) | ||
8 | |||
9 | ### Docker test images | ||
10 | |||
11 | Test Dockerfiles are located under `tests/docker/<distribution>/Dockerfile`, | ||
12 | and can be used to build Docker images to run Shaarli test suites under common | ||
13 | Linux environments. | ||
14 | |||
15 | Dockerfiles are provided for the following environments: | ||
16 | |||
17 | - `alpine36` - [Alpine 3.6](https://www.alpinelinux.org/downloads/) | ||
18 | - `debian8` - [Debian 8 Jessie](https://www.debian.org/DebianJessie) (oldstable) | ||
19 | - `debian9` - [Debian 9 Stretch](https://wiki.debian.org/DebianStretch) (stable) | ||
20 | - `ubuntu16` - [Ubuntu 16.04 Xenial Xerus](http://releases.ubuntu.com/16.04/) (LTS) | ||
21 | |||
22 | What's behind the curtains: | ||
23 | |||
24 | - each image provides: | ||
25 | - a base Linux OS | ||
26 | - Shaarli PHP dependencies (OS packages) | ||
27 | - test PHP dependencies (OS packages) | ||
28 | - Composer | ||
29 | - the local workspace is mapped to the container's `/shaarli/` directory, | ||
30 | - the files are rsync'd so tests are run using a standard Linux user account | ||
31 | (running tests as `root` would bypass permission checks and may hide issues) | ||
32 | - the tests are run inside the container. | ||
33 | |||
34 | ### Building test images | ||
35 | |||
36 | ```bash | ||
37 | # build the Debian 9 Docker image | ||
38 | $ cd /path/to/shaarli | ||
39 | $ cd tests/docker/debian9 | ||
40 | $ docker build -t shaarli-test:debian9 . | ||
41 | ``` | ||
42 | |||
43 | ### Running tests | ||
44 | |||
45 | ```bash | ||
46 | $ cd /path/to/shaarli | ||
47 | |||
48 | # install/update 3rd-party test dependencies | ||
49 | $ composer install --prefer-dist | ||
50 | |||
51 | # run tests using the freshly built image | ||
52 | $ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_test | ||
53 | |||
54 | # run the full test campaign | ||
55 | $ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_all_tests | ||
56 | ``` | ||
diff --git a/doc/md/Unit-tests.md b/doc/md/Unit-tests.md index 651b546d..c45f957d 100644 --- a/doc/md/Unit-tests.md +++ b/doc/md/Unit-tests.md | |||
@@ -1,6 +1,6 @@ | |||
1 | ### Setup your environment for tests | 1 | The testing framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool. |
2 | 2 | ||
3 | The framework used is [PHPUnit](https://phpunit.de/); it can be installed with [Composer](https://getcomposer.org/), which is a dependency management tool. | 3 | ## Setup a testing environment |
4 | 4 | ||
5 | ### Install composer | 5 | ### Install composer |
6 | 6 | ||
@@ -10,7 +10,7 @@ You can either use: | |||
10 | - a local version, downloadable [here](https://getcomposer.org/download/). To update a local composer installation, run `php composer.phar self-update` | 10 | - a local version, downloadable [here](https://getcomposer.org/download/). To update a local composer installation, run `php composer.phar self-update` |
11 | 11 | ||
12 | 12 | ||
13 | #### Install Shaarli dev dependencies | 13 | ### Install Shaarli development dependencies |
14 | 14 | ||
15 | ```bash | 15 | ```bash |
16 | $ cd /path/to/shaarli | 16 | $ cd /path/to/shaarli |
@@ -18,7 +18,7 @@ $ composer install | |||
18 | $ composer update | 18 | $ composer update |
19 | ``` | 19 | ``` |
20 | 20 | ||
21 | #### Install Xdebug | 21 | ### Install Xdebug |
22 | 22 | ||
23 | Xdebug must be installed and enable for PHPUnit to generate coverage reports. See http://xdebug.org/docs/install. | 23 | Xdebug must be installed and enable for PHPUnit to generate coverage reports. See http://xdebug.org/docs/install. |
24 | 24 | ||
@@ -36,7 +36,7 @@ Then add the following line to `/etc/php/php.ini`: | |||
36 | zend_extension=xdebug.so | 36 | zend_extension=xdebug.so |
37 | ``` | 37 | ``` |
38 | 38 | ||
39 | #### Run unit tests | 39 | ## Run unit tests |
40 | 40 | ||
41 | Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly. | 41 | Run `make test` and ensure tests return `OK`. If tests return failures, refer to PHPUnit messages and fix your code/tests accordingly. |
42 | 42 | ||
@@ -75,3 +75,46 @@ To run all tests annotated with `@group WIP`: | |||
75 | ```bash | 75 | ```bash |
76 | $ vendor/bin/phpunit --group WIP tests/ | 76 | $ vendor/bin/phpunit --group WIP tests/ |
77 | ``` | 77 | ``` |
78 | |||
79 | ### Running tests inside Docker containers | ||
80 | |||
81 | Test Dockerfiles are located under `tests/docker/<distribution>/Dockerfile`, | ||
82 | and can be used to build Docker images to run Shaarli test suites under common | ||
83 | Linux environments. | ||
84 | |||
85 | Dockerfiles are provided for the following environments: | ||
86 | |||
87 | - `alpine36` - [Alpine 3.6](https://www.alpinelinux.org/downloads/) | ||
88 | - `debian8` - [Debian 8 Jessie](https://www.debian.org/DebianJessie) (oldstable) | ||
89 | - `debian9` - [Debian 9 Stretch](https://wiki.debian.org/DebianStretch) (stable) | ||
90 | - `ubuntu16` - [Ubuntu 16.04 Xenial Xerus](http://releases.ubuntu.com/16.04/) (LTS) | ||
91 | |||
92 | What's behind the curtains: | ||
93 | |||
94 | - each image provides: | ||
95 | - a base Linux OS | ||
96 | - Shaarli PHP dependencies (OS packages) | ||
97 | - test PHP dependencies (OS packages) | ||
98 | - Composer | ||
99 | - the local workspace is mapped to the container's `/shaarli/` directory, | ||
100 | - the files are rsync'd so tests are run using a standard Linux user account | ||
101 | (running tests as `root` would bypass permission checks and may hide issues) | ||
102 | - the tests are run inside the container. | ||
103 | |||
104 | To run tests inside a Docker container: | ||
105 | |||
106 | ```bash | ||
107 | # build the Debian 9 Docker image for unit tests | ||
108 | $ cd /path/to/shaarli | ||
109 | $ cd tests/docker/debian9 | ||
110 | $ docker build -t shaarli-test:debian9 . | ||
111 | |||
112 | # install/update 3rd-party test dependencies | ||
113 | $ composer install --prefer-dist | ||
114 | |||
115 | # run tests using the freshly built image | ||
116 | $ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_test | ||
117 | |||
118 | # run the full test campaign | ||
119 | $ docker run -v $PWD:/shaarli shaarli-test:debian9 docker_all_tests | ||
120 | ``` | ||
@@ -51,6 +51,5 @@ pages: | |||
51 | - Translations: Translations.md | 51 | - Translations: Translations.md |
52 | - Theming: Theming.md | 52 | - Theming: Theming.md |
53 | - Unit tests: Unit-tests.md | 53 | - Unit tests: Unit-tests.md |
54 | - Unit tests inside Docker: Unit-tests-Docker.md | ||
55 | - FAQ: FAQ.md | 54 | - FAQ: FAQ.md |
56 | - Troubleshooting: Troubleshooting.md | 55 | - Troubleshooting: Troubleshooting.md |