Skip to content

feat(selectivity): implement 'selectivity-merge-dumps' command#1220

Merged
KuznetsovRoman merged 1 commit intomasterfrom
TESTPLANE-931.merge_selectivity
Mar 18, 2026
Merged

feat(selectivity): implement 'selectivity-merge-dumps' command#1220
KuznetsovRoman merged 1 commit intomasterfrom
TESTPLANE-931.merge_selectivity

Conversation

@KuznetsovRoman
Copy link
Member

No description provided.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/testplane@1220

commit: 70fd3ba

@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-931.merge_selectivity branch from 667707c to 9472064 Compare March 13, 2026 04:15
);
});

it("should throw if same file key has different hashes across sources", async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next 3 tests are similar - its easier to read them like this instead of array-generated 3 tests

}),
);

await mergeHashes(destAbsolutePath, srcAbsolutePaths, preferredCompression);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not running "mergeHashes" and "mergeTests" in parallel because "mergeHashes" checks for chunks compatibility

const depType = dependencyType as keyof NormalizedDependencies;
const depSet = new Set(result[browserId][dependencyScope][depType]);

result[browserId][dependencyScope][depType] = Array.from(depSet).sort((a, b) => a.localeCompare(b));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting object properties as well as array values to ensure consistency

allSrcTests.forEach(fileBase => {
const fileProviders = srcTestPaths.filter((_, idx) => srcTests[idx].has(fileBase));

if (fileProviders.length === 1) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only one chunk has test dependencies, we can skip decompressing/reading/compressing/writing it and just copy the file

@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-931.merge_selectivity branch 2 times, most recently from 03d9ba3 to b0998e9 Compare March 13, 2026 06:15
@KuznetsovRoman
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0998e93f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-931.merge_selectivity branch from b0998e9 to 1440ea6 Compare March 13, 2026 13:05
await Promise.all(
srcAbsolutePaths.map(srcAbsolutePath => {
return fs.promises.access(srcAbsolutePath, fs.constants.R_OK).catch(cause => {
throw new Error(`Couldn't get read access to source directory "${srcAbsolutePath}"`, { cause });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not actionable error. what should I do with this error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will handle "access" errors in next PR in order to make it universal

throw new Error(
[
`Can't merge reports: no suitable source file was found by "${sourceBasePath}" base`,
`It can happen if it was compressed with unsupported compression type`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should I do to fix it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to:

`Can't merge reports: no suitable source file was found by "${sourceBasePath}" base`,
`It can happen if it was compressed with unsupported compression type, or if the file was removed during command run`,
"If selectivity dump was created with node.js v22+, ensure you are currently is using it too",

Does not seem like there could be other reasons


for (const dependencyType in testContent[browserId][dependencyScope]) {
const depType = dependencyType as keyof NormalizedDependencies;
for (const dependency of testContent[browserId][dependencyScope][depType]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm... x5 for...we should go deeper :)

}));
readJsonWithCompressionStub = sandbox.stub().resolves({});
stripCompressionSuffixStub = sandbox.stub().callsFake((file: string) => {
for (const suffix of [".gz", ".br", ".zstd"]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this logic here. it should be tested in the separate utils test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not tested here.
Its just a stub, which makes it easier to write other tests, without necessity of stubbing it manually in each unit test

});
writeJsonWithCompressionStub = sandbox.stub().resolves();

mergeTests = proxyquire("src/browser/cdp/selectivity/merge-dumps/merge-tests", {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like integration tests would be better here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. Still, unit tests are fast and stable.
If needed, intergration tests can be written too, but units are still useful here: they prevent from next changes breaking existing functionality

@KuznetsovRoman KuznetsovRoman force-pushed the TESTPLANE-931.merge_selectivity branch from 1440ea6 to 70fd3ba Compare March 18, 2026 15:05
@KuznetsovRoman KuznetsovRoman merged commit cc8940e into master Mar 18, 2026
5 of 7 checks passed
@KuznetsovRoman KuznetsovRoman deleted the TESTPLANE-931.merge_selectivity branch March 18, 2026 15:22
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.

2 participants