Skip to content

Commit 4ad504f

Browse files
Reset stateful regex log waits between matches (#1352)
1 parent a1b87ed commit 4ad504f

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ It captures practical rules that prevent avoidable CI and PR churn.
2828
- In docs Markdown, keep `<!--codeinclude-->` blocks tight with no blank lines between the markers and the include line, or the rendered snippet will contain blank lines between code lines.
2929
- Tests should verify observable behavior changes, not only internal/config state.
3030
- Example: for a security option, assert a real secure/insecure behavior difference.
31+
- When adding a regression test for a bug fix, follow a red-green-refactor workflow.
32+
- Run the focused test against the pre-fix implementation and confirm it fails for the expected reason.
33+
- Apply the implementation change, rerun the same test, and confirm it passes.
34+
- Report the red-green evidence in the PR verification summary.
3135
- Test-only helper files under `src` (for example `*-test-utils.ts`) must be explicitly excluded from package `tsconfig.build.json` so they are not emitted into `build` and accidentally published.
3236
- For substantial changes to GitHub Actions, runner images, Node/npm versions, or release/publish automation, consider running the manual `Node.js Package` workflow as a dry-run publish sanity check.
3337
- Select the PR branch as the workflow ref to test publish workflow changes before merging.

packages/testcontainers/src/wait-strategies/log-wait-strategy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("LogWaitStrategy", { timeout: 180_000 }, () => {
2626
const start = new Date();
2727
await using container = await new GenericContainer("cristianrgreco/testcontainer:1.1.14")
2828
.withCommand(["/bin/sh", "-c", 'sleep 2; echo "Ready"'])
29-
.withWaitStrategy(Wait.forLogMessage("Ready"))
29+
.withWaitStrategy(Wait.forLogMessage(/Ready/g))
3030
.start();
3131

3232
expect(new Date().getTime() - start.getTime()).toBeGreaterThanOrEqual(2_000);

packages/testcontainers/src/wait-strategies/log-wait-strategy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class LogWaitStrategy extends AbstractWaitStrategy {
2828

2929
const comparisonFn: (line: string) => boolean = (line: string) => {
3030
if (this.message instanceof RegExp) {
31+
if (this.message.global || this.message.sticky) {
32+
this.message.lastIndex = 0;
33+
}
3134
return this.message.test(line);
3235
} else {
3336
return line.includes(this.message);

0 commit comments

Comments
 (0)