|
| 1 | +# n-test |
| 2 | + |
| 3 | +Prototype and develop a set of automated tests for `n`. |
| 4 | + |
| 5 | +## Setup |
| 6 | + |
| 7 | +Optional proxy using mitmproxy: |
| 8 | + |
| 9 | + # using homebrew (Mac) to install mitmproxy |
| 10 | + brew install mitmproxy |
| 11 | + |
| 12 | + |
| 13 | +## Running Tests |
| 14 | + |
| 15 | +Run all the tests across a range of containers and on the host system: |
| 16 | + |
| 17 | + npm run test |
| 18 | + |
| 19 | +Run all the tests on a single system: |
| 20 | + |
| 21 | + cd test |
| 22 | + npx bats tests |
| 23 | + docker-compose run ubuntu-curl bats /mnt/tests |
| 24 | + |
| 25 | +Run single test on a single system:: |
| 26 | + |
| 27 | + cd test |
| 28 | + npx bats tests/install-contents.bats |
| 29 | + docker-compose run ubuntu-curl bats /mnt/tests/install-contents.bats |
| 30 | + |
| 31 | +## Proxy |
| 32 | + |
| 33 | +To speed up running tests multiple times, you can optionally run a caching proxy for the node downloads. The curl settings are modified |
| 34 | +to allow an insecure connection through the mitm proxy. |
| 35 | + |
| 36 | + cd test |
| 37 | + bin/proxy-build |
| 38 | + bin/proxy-run |
| 39 | + # follow the instructions for configuring environment variables for using proxy, then run tests |
| 40 | + |
| 41 | +`node` versions added to proxy cache (and used in tests): |
| 42 | + |
| 43 | +* v4.9.1 |
| 44 | +* lts |
| 45 | +* latest |
| 46 | + |
| 47 | +## Docker Tips |
| 48 | + |
| 49 | +Using `docker-compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers. |
| 50 | + |
| 51 | +`bats` is being mounted directly out of `node_modules` into the container as a manual install based on its own install script. This is a bit of a hack, but avoids needing to install `git` or `npm` for a full remote install of `bats`, and means everything on the same version of `bats`. |
| 52 | + |
| 53 | +The containers each have: |
| 54 | + |
| 55 | +* either curl or wget (or both) installed |
| 56 | + |
| 57 | +Using `docker-compose` to run the container adds: |
| 58 | + |
| 59 | +* specified `n` script mounted to `/usr/local/bin/n` |
| 60 | +* `test/tests` mounted to `/mnt/tests` |
| 61 | +* `node_modules/bats` provides `/usr/local/bin/bats` et al |
| 62 | +* `.curlrc` with `--insecure` to allow use of proxy |
| 63 | + |
| 64 | +So for example: |
| 65 | + |
| 66 | + cd test |
| 67 | + docker-compose run ubuntu-curl |
| 68 | + # in container |
| 69 | + n --version |
| 70 | + bats /mnt/tests |
0 commit comments