livery.extensions.pytest._slice¶
livery.extensions.pytest._slice ¶
One shard's share of the test files: listed, partitioned, recorded.
A sharded check leg runs the test step on every shard, each over a
share of the test files. share lists the test files of every suite
the run reaches (test_files), reads the durations and the head of
the leg's platform (livery.workshop.read_durations), packs the
files into the shard's slices with livery.workshop.partition, the
first slice starting at the head, takes this
shard's slice, and leaves what it partitioned in the shard's record
(livery.workshop.leave_shard) for the gate job's proof. The test
step runs twice on a leg whose coverage entry tops up the suites no
record can supply, so a second run on the same shard adds to the
record instead of replacing it (SETS_FILE).
Functions:
| Name | Description |
|---|---|
test_files |
The test files of suite this run runs, root-relative with forward slashes. |
share |
This shard's share of suites' test files, per suite path, and its record. |
Attributes:
| Name | Type | Description |
|---|---|---|
SETS_FILE |
|
test_files ¶
test_files(ctx: PhaseContext, suite: Package) -> tuple[str, ...]
The test files of suite this run runs, root-relative with forward slashes.
The files the run selects for the suite (ctx.tests) when it
names any; else every file pytest collects from the suite's test
directory, test_*.py and *_test.py under it, the workspace's
own tests directory included. Sorted. A suite without a test
directory has none.
Source code in packages/extensions/pytest/src/livery/extensions/pytest/_slice.py
share ¶
This shard's share of suites' test files, per suite path, and its record.
Every test file the workspace holds, each package's and the
workspace's own, is packed into the shard's count of slices by the
durations of the leg's platform, read from the rows stamped before
the checkout's committer time (livery.workshop.checkout_time),
the first slice starting at the rows' head, the test seconds the
steps only the first shard runs hold back, and of suites' test
files (test_files) the ones in this shard's
slice are returned, a suite's files sorted; a suite with no file in
the slice maps to an empty tuple. The packing is over the whole
workspace, never over the suites of one run, so a file has one
shard however many runs of the step reach it on a leg: the gate's,
and the coverage top-up's, which runs other suites and the
workspace's own tests again. The slice, the digest of the set, the
suites with a file in the set and the rows read are left in the
shard's record. A suite with no test file is not named among the
suites: it runs whole on the first shard, with every step that does
not read the shard, and the coverage leg expects its parts there.
Each line printed names step.
With no durations row before the bound, or a store that cannot be read, the reason prints, the first shard runs every file and every other shard runs none, and the record names no row, so the gate job's proof sees the leg ran unsharded. Outside CI no leg names a durations series, so every file weighs the same and the files are shared out by name.
Source code in packages/extensions/pytest/src/livery/extensions/pytest/_slice.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |