|
1 | 1 | # Docker image for Sublime Text UnitTesting |
2 | 2 |
|
| 3 | +## Recommended usage |
| 4 | + |
| 5 | +Use the launcher script: |
| 6 | + |
| 7 | +```sh |
| 8 | +# from UnitTesting repo root |
| 9 | +./docker/ut-run-tests /path/to/package |
| 10 | +./docker/ut-run-tests /path/to/package --file tests/test_example.py |
| 11 | +``` |
| 12 | + |
| 13 | +Or call it via absolute path from any package directory: |
| 14 | + |
| 15 | +```sh |
| 16 | +/path/to/UnitTesting/docker/ut-run-tests . |
| 17 | +``` |
| 18 | + |
| 19 | +If this directory is on your `PATH`, you can run `ut-run-tests` directly. |
| 20 | + |
| 21 | +The launcher calls `docker/run_tests.py`, builds/uses a local image, |
| 22 | +mounts the package at `/project`, runs tests headlessly, and keeps a cache |
| 23 | +volume for fast reruns. |
| 24 | + |
| 25 | +By default it: |
| 26 | + |
| 27 | +- builds `unittesting-local` image from `./docker` if missing |
| 28 | +- mounts your repo as `/project` |
| 29 | +- runs UnitTesting through the same CI shell entrypoints |
| 30 | +- stores Sublime install/cache in docker volume `unittesting-home` |
| 31 | +- synchronizes only changed files into `Packages/<Package>` using `rsync` |
| 32 | + |
| 33 | +## Manual docker usage |
3 | 34 |
|
4 | | -## From Docker Hub |
5 | 35 | ```sh |
6 | | -# cd to package |
7 | | -docker run --rm -it -e PACKAGE=$PACKAGE -v $PWD:/project sublimetext/unittesting |
| 36 | +# build from UnitTesting/docker |
| 37 | +docker build -t unittesting-local . |
| 38 | + |
| 39 | +# run from package root |
| 40 | +docker run --rm -it \ |
| 41 | + -e PACKAGE=$PACKAGE \ |
| 42 | + -v $PWD:/project \ |
| 43 | + -v unittesting-home:/root \ |
| 44 | + unittesting-local run_tests |
8 | 45 | ``` |
9 | 46 |
|
10 | | -## Build image from scratch |
| 47 | +## Fast reruns |
| 48 | + |
| 49 | +The container entrypoint writes a marker in `/root/.cache/unittesting`. |
| 50 | +With `-v unittesting-home:/root`, bootstrap/install runs once and later runs |
| 51 | +only refresh your package files and execute tests. |
| 52 | + |
| 53 | +## Refresh/update controls (without direct docker commands) |
| 54 | + |
| 55 | +Use launcher flags instead of calling `docker` manually: |
| 56 | + |
| 57 | +- `--refresh-cache`: recreate `unittesting-home` cache volume (forces fresh |
| 58 | + bootstrap, including Sublime Text/Package Control install path) |
| 59 | +- `--refresh-image`: rebuild local image (for Dockerfile/entrypoint changes) |
| 60 | +- `--refresh`: both `--refresh-cache` and `--refresh-image` |
| 61 | + |
| 62 | +Examples: |
| 63 | + |
| 64 | +```sh |
| 65 | +ut-run-tests . --refresh-image |
| 66 | +ut-run-tests . --refresh-cache |
| 67 | +ut-run-tests . --refresh |
| 68 | +``` |
| 69 | + |
| 70 | +## Dry run (metadata and schedule only) |
| 71 | + |
| 72 | +Use `--dry-run` to print runner metadata (including detected Sublime |
| 73 | +Text and Package Control versions) plus the generated schedule. |
| 74 | + |
| 75 | +```sh |
| 76 | +ut-run-tests . --dry-run |
| 77 | +``` |
| 78 | + |
| 79 | +## Colored output |
| 80 | + |
| 81 | +Use `--color` to control ANSI colors in test output: |
| 82 | + |
| 83 | +- `--color auto` (default): color only when stdout is a TTY |
| 84 | +- `--color always`: force color |
| 85 | +- `--color never`: disable color |
| 86 | + |
| 87 | +```sh |
| 88 | +ut-run-tests . --color always |
| 89 | +``` |
| 90 | + |
| 91 | +## Run a single test file |
| 92 | + |
11 | 93 | ```sh |
12 | | -# cd to UnitTesting/docker |
13 | | -docker build -t unittesting . |
14 | | -# cd to package |
15 | | -docker run --rm -it -e PACKAGE=$PACKAGE -v $PWD:/project unittesting |
| 94 | +docker run --rm -it \ |
| 95 | + -e PACKAGE=$PACKAGE \ |
| 96 | + -v $PWD:/project \ |
| 97 | + -v unittesting-home:/root \ |
| 98 | + unittesting-local run_tests --tests-dir tests --pattern test_example.py |
16 | 99 | ``` |
0 commit comments