Skip to content

fix(python): de-flake test_invoke_script_with_line_flush - #2

Closed
omarqureshi wants to merge 4 commits into
mainfrom
fix/de-flake-python-invoke-script-with-line-flush
Closed

fix(python): de-flake test_invoke_script_with_line_flush#2
omarqureshi wants to merge 4 commits into
mainfrom
fix/de-flake-python-invoke-script-with-line-flush

Conversation

@omarqureshi

@omarqureshi omarqureshi commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

Managed to get this test to fail whilst working on ruby language bindings.

test_invoke_script_with_line_flush asserted exact rounded inter-line delays (== 0 / == 1), which is brittle on loaded machines: startup jitter or a slow 1s sleep can round a measured delay to an unexpected value and fail the test spuriously.

This splits the assertion into the two properties the test actually exists to verify:

  • the output lines match exactly (unchanged in strictness)
  • each line printed after a delay(1000) arrived >= 1s after the previous line

The streaming/no-buffering guarantee is preserved: if stdout were block-buffered, all lines would arrive in one burst at process exit and every inter-line delay from index 3 onward would be ~0, failing the new assertion.

The script that this test counts relies on reads as follows:

  console.info('Hello World!');                          // line 1
  ...
  console.info(`  arguments: ${args.join(', ')}`);       // line 2
  if (args.includes('delay')) {
    for (let i = 1; i <= 5; i++) {
      console.log(`sleeping 1s ${i}`);                   // line 3 (i=1) — printed BEFORE the sleep
      await delay(1000);                                 // then sleeps
    }
  }

as such the expected output is:

idx line gap why
0 Hello World! 0 by construction — last_dt is initialized on the first line
1 arguments: arg1, delay ~0 printed in the same burst
2 sleeping 1s 1 ~0 printed before the first await delay(1000)
3 sleeping 1s 2 ~1s arrives after the first sleep
4–6 sleeping 1s 3..5 ~1s each one sleep between each

🤖 Generated with Claude Code

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Omar Qureshi and others added 4 commits June 6, 2026 18:27
The test asserted exact rounded inter-line delays (== 0 / == 1), which
is brittle on loaded machines where startup jitter or a slow 1s sleep
rounds the measured delay to an unexpected value.

Split the assertion into the two properties that matter:
- the output lines match exactly
- each line printed after a sleep arrived >= 1s after the previous one
  (all delays would be ~0 if output were buffered to process exit)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds support for jsii-rosetta 6.0 following the process in CONTRIBUTING.md.

This upgrades jsii and jsii-rosetta to 6.0 across all packages and updates TypeScript to 6.x. The jsii-pacmak peer dependency now supports `>=5.9.0` to cover both 5.9 and 6.0.

The TypeScript 6.0 upgrade required fixing deprecated compiler options in `tsconfig-base.json`: `esModuleInterop` is now `true` and `moduleResolution` is `Node16`. These changes cascaded into import fixes across the codebase — `import * as X` for default-exported modules needed to become `import X`. The `jsii-config` package was converted to ESM (`"type": "module"`) because `@inquirer/prompts` v8 is ESM-only, using `rewriteRelativeImportExtensions` to keep `.ts` extensions in source.

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Ran npm-check-updates and yarn up to keep the `yarn.lock` file up-to-date.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants