Commit 5e8030e
authored
chore(e2e-tests): force wait for initialization before writing input (#2600)
In the past, we've had a number of flaky tests that followed a pattern
similar to this:
1. Start a test shell
2. Run a command using `executeLine()`
3. Make assertions about the command's output
The internal logic of `executeLine()` determines that it has seen
the end of the command's output by looking for the subsequent prompt
(similar to how a human being in front of the shell would determine
that the command has finished).
However, in the above scheme, there is a race condition that can
develop as follows:
1. The test shell process starts and prints part of its initial output
2. The `executeLine()` command remembers the current output position
and sends the input to the process's stdin stream
3. The test shell prints its first prompt
4. The test reads the output from the shell and sees the prompt,
assumes that the comamnd has finished
5. The test shell finishes evaluating the input and writes the
corresponding output + a new prompt
6. The test ignores the remaining output and instead only treats
the text up to the first prompt as the command output
7. An assertion made about the output fails, as the output is not
coming from the command it was supposed to come from
In order to avoid the likelihood of introducing such race conditions,
this commit adds a guardrail to the input writing methods that
ensures that the shell has reached some form of known state that has
been awaited, such as seeing the first prompt or other specific output,
before it allows writing to the process's input.1 parent 7e28603 commit 5e8030e
File tree
4 files changed
+43
-18
lines changed- packages/e2e-tests/test
4 files changed
+43
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
926 | 927 | | |
927 | 928 | | |
928 | 929 | | |
| 930 | + | |
929 | 931 | | |
930 | 932 | | |
931 | 933 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
| 313 | + | |
314 | 314 | | |
315 | | - | |
316 | | - | |
| 315 | + | |
317 | 316 | | |
318 | 317 | | |
319 | 318 | | |
| |||
1155 | 1154 | | |
1156 | 1155 | | |
1157 | 1156 | | |
1158 | | - | |
| 1157 | + | |
1159 | 1158 | | |
1160 | | - | |
1161 | | - | |
| 1159 | + | |
1162 | 1160 | | |
1163 | 1161 | | |
1164 | 1162 | | |
| |||
2605 | 2603 | | |
2606 | 2604 | | |
2607 | 2605 | | |
2608 | | - | |
2609 | | - | |
2610 | | - | |
| 2606 | + | |
2611 | 2607 | | |
2612 | 2608 | | |
2613 | 2609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
| |||
152 | 162 | | |
153 | 163 | | |
154 | 164 | | |
| 165 | + | |
155 | 166 | | |
156 | 167 | | |
157 | 168 | | |
| |||
205 | 216 | | |
206 | 217 | | |
207 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
208 | 222 | | |
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
212 | | - | |
| 226 | + | |
213 | 227 | | |
214 | 228 | | |
215 | 229 | | |
| |||
247 | 261 | | |
248 | 262 | | |
249 | 263 | | |
| 264 | + | |
250 | 265 | | |
251 | 266 | | |
252 | | - | |
253 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
254 | 271 | | |
255 | 272 | | |
256 | 273 | | |
| |||
267 | 284 | | |
268 | 285 | | |
269 | 286 | | |
270 | | - | |
| 287 | + | |
271 | 288 | | |
272 | 289 | | |
273 | 290 | | |
| |||
283 | 300 | | |
284 | 301 | | |
285 | 302 | | |
286 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
287 | 312 | | |
288 | 313 | | |
289 | 314 | | |
290 | 315 | | |
291 | | - | |
292 | | - | |
| 316 | + | |
| 317 | + | |
293 | 318 | | |
294 | 319 | | |
295 | 320 | | |
296 | 321 | | |
297 | | - | |
| 322 | + | |
298 | 323 | | |
299 | 324 | | |
300 | | - | |
| 325 | + | |
301 | 326 | | |
302 | 327 | | |
303 | 328 | | |
| |||
0 commit comments