Skip to content

Commit 95cb882

Browse files
authored
Merge pull request #296 from kaste/local-runner
Local runner - round 3
2 parents 1e968c5 + d76043c commit 95cb882

11 files changed

Lines changed: 809 additions & 138 deletions

File tree

‎README.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,20 @@ ut-run-tests .
132132

133133
This launcher calls `docker/run_tests.py`, which runs tests in a Docker
134134
container (headless), streams output to stdout/stderr and keeps a cache
135-
volume so repeated runs are fast.
135+
volume so repeated runs are fast. By default it runs Python unit tests,
136+
syntax tests and syntax compatibility checks.
137+
138+
`--file` chooses the runner from the selected file: Python files run as unit
139+
tests, `syntax_test*` files run as syntax tests, and `.sublime-syntax` files
140+
run compatibility checks.
136141

137142
Useful options:
138143

139144
- `--file tests/test_foo.py`
140145
- `--pattern test_foo.py --tests-dir tests/subdir`
146+
- `--no-unit-tests`
147+
- `--no-syntax-tests`
148+
- `--no-syntax-compatibility-checks`
141149
- `--coverage`
142150
- `--failfast`
143151
- `--reload-package-on-testing` (default: off)

‎docker/README.md‎

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,52 +26,63 @@ By default it:
2626

2727
- builds `unittesting-local` image from `./docker` if missing
2828
- mounts your repo as `/project`
29+
- runs Python unit tests, syntax tests and syntax compatibility checks
2930
- runs UnitTesting through the same CI shell entrypoints
3031
- stores Sublime install/cache in docker volume `unittesting-home`
3132
- synchronizes only changed files into `Packages/<Package>` using `rsync`
33+
- excludes files ignored by Git, including repository-local and global rules
3234

33-
## Manual docker usage
35+
A category with no matching resources is reported and succeeds. Disable
36+
categories that are not needed with:
3437

3538
```sh
36-
# build from UnitTesting/docker
37-
docker build -t unittesting-local .
39+
ut-run-tests . --no-unit-tests
40+
ut-run-tests . --no-syntax-tests
41+
ut-run-tests . --no-syntax-compatibility-checks
42+
```
3843

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
44+
`--file` selects its category automatically. Python files run as unit tests,
45+
files whose names start with `syntax_test` run as syntax tests, and
46+
`.sublime-syntax` files run compatibility checks:
47+
48+
```sh
49+
ut-run-tests . --file tests/test_example.py
50+
ut-run-tests . --file syntax_test_example
51+
ut-run-tests . --file Example.sublime-syntax
4552
```
4653

54+
`--pattern` and `--tests-dir` try every enabled category. Use the
55+
`--no-*` options to avoid running unrelated categories when desired.
56+
4757
## Fast reruns
4858

4959
The container entrypoint writes a marker in `/root/.cache/unittesting`.
5060
With `-v unittesting-home:/root`, bootstrap/install runs once and later runs
5161
only refresh your package files and execute tests.
5262

53-
## Serialized runs
63+
## Concurrent runs and races
5464

5565
The shared cache volume contains the Sublime data directory, including
56-
`Packages`, `Lib`, UnitTesting schedules and test output files. Concurrent
57-
runs against the same volume are serialized by default to avoid races while
66+
`Packages`, `Lib`, UnitTesting schedules and test output files. *Concurrent
67+
runs against the same volume are serialized by default* to avoid races while
5868
copying packages, writing schedules and syncing Package Control libraries.
69+
This is a speed-versus-space trade-off: tests are likely to run quickly,
70+
keeping wait times low, and a shared volume uses less disk space than
71+
multiple volumes.
5972

6073
Use `--lock-timeout SECONDS` to control how long a runner waits for the cache
6174
volume lock. Use `--no-lock` only if you know the selected cache volume is not
6275
shared by another runner.
6376

64-
## Concurrent runs
65-
66-
You can control concurrency by choosing how many cache volumes you use. The
67-
default single volume serializes all runs. A stable volume per package allows
68-
different packages to run concurrently while still keeping warm caches:
77+
You can increase concurrency by choosing how many cache volumes you use. For
78+
example, a stable volume per package allows different packages to run
79+
concurrently while still keeping warm caches:
6980

7081
```sh
7182
ut-run-tests . --cache-volume unittesting-home-gitsavvy
7283
```
7384

74-
To maximize concurrency, use a stable volume per checkout directory. For
85+
To *maximize* concurrency, use a stable volume per checkout directory. For
7586
example, in a POSIX shell:
7687

7788
```sh
@@ -120,7 +131,21 @@ Use `--color` to control ANSI colors in test output:
120131
ut-run-tests . --color always
121132
```
122133

123-
## Run a single test file
134+
## Manual docker usage
135+
136+
```sh
137+
# build from UnitTesting/docker
138+
docker build -t unittesting-local .
139+
140+
# run from package root
141+
docker run --rm -it \
142+
-e PACKAGE=$PACKAGE \
143+
-v $PWD:/project \
144+
-v unittesting-home:/root \
145+
unittesting-local run_tests
146+
```
147+
148+
Run a single test file
124149

125150
```sh
126151
docker run --rm -it \

‎docker/entrypoint.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ fi
9999
if [ -d "$UNITTESTING_SOURCE/sbin" ]; then
100100
# Ensure UnitTesting comes from the local checkout running this script,
101101
# so first runs do not depend on tagged upstream releases.
102-
(cd "$UNITTESTING_SOURCE" && PACKAGE=UnitTesting /docker.sh copy_tested_package overwrite)
102+
(
103+
cd "$UNITTESTING_SOURCE"
104+
PACKAGE=UnitTesting UNITTESTING_IGNORE_MANIFEST= \
105+
/docker.sh copy_tested_package overwrite
106+
)
103107

104108
# Normalize CRLF in shell scripts copied from Windows workspaces.
105109
if [ -d "$ST_PACKAGES_DIR/UnitTesting/sbin" ]; then

0 commit comments

Comments
 (0)