Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intermittent failure in ANSIOutput test... #4518

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

softwarenerd
Copy link
Contributor

This PR addresses #2734.

The issue was traced down to the makeLines helper function. Previously, this function would generate a set of test lines varying in length between 0 characters and 1024 characters. Sometimes, randomly, this would result in the last test line being 0 characters long. When this happened, the last line would be ignored by ANSIOutput.processOutput (as expected), resulting in a test failure like this:

1) ANSIOutout
       Test ANSIOutput with 10,000 output lines separated by LF and CRLF:

      AssertionError [ERR_ASSERTION]: 9 == 10
      + expected - actual

      -9
      +10
      
      at testOutputLines (out/vs/base/test/common/ansiOutput.test.js:1553:20)
      at Context.<anonymous> (out/vs/base/test/common/ansiOutput.test.js:540:13)
      at process.processImmediate (node:internal/timers:478:21)

The fix was to ensure that the last line returned from the makeLines helper function is at least one character long so it won't get ignored by ANSIOutput.processOutput.

Additionally, I fixed the testOutputLines function to use its arguments and I added in a call to ensureNoDisposablesAreLeakedInTestSuite, as required now.

QA Notes

I was able to reproduce this issue locally by running thousands of iterations of the following test:

test('Test ANSIOutput with 10 lines separated by LF and CRLF', () => {
	for (let i = 0; i < 10000; i++) {
		testOutputLines(10, LF);
		testOutputLines(10, CRLF);
	}
});

Which would result in a failure nearly 100% of the time. You can test this locally by adding the for loop to this this.

@softwarenerd softwarenerd merged commit f2238e0 into main Aug 28, 2024
2 checks passed
@softwarenerd softwarenerd deleted the test/ANSIOutput-intermittent-failure branch August 28, 2024 22:23
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants