Skip to content

Commit aecc83b

Browse files
Merge pull request #1272 from gemini-testing/TESTPLANE-1031.clear_dumps_opt_out
feat: add selectivity clear dumps opt-out feature
2 parents be47eec + 9a922c9 commit aecc83b

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/browser/cdp/selectivity/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ export const updateSelectivityHashes = async (config: Config, isRunFailed: boole
6767
* Called at the end of testplane run
6868
*/
6969
export const clearUnusedSelectivityDumps = async (config: Config, isRunFailed: boolean): Promise<void> => {
70+
if (process.env.TESTPLANE_SELECTIVITY_CLEAR_UNUSED_DUMPS === "false") {
71+
return;
72+
}
73+
7074
const usedDumpsTracker = getUsedDumpsTracker();
7175
const browserIds = config.getBrowserIds();
7276
const selectivityRoots: string[] = [];

test/src/browser/cdp/selectivity/index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,18 @@ describe("CDP/Selectivity", () => {
728728
};
729729

730730
beforeEach(() => {
731+
delete process.env.TESTPLANE_SELECTIVITY_CLEAR_UNUSED_DUMPS;
732+
731733
configMock = {
732734
getBrowserIds: sandbox.stub(),
733735
forBrowser: sandbox.stub(),
734736
};
735737
});
736738

739+
afterEach(() => {
740+
delete process.env.TESTPLANE_SELECTIVITY_CLEAR_UNUSED_DUMPS;
741+
});
742+
737743
it("should skip browsers with selectivity disabled", async () => {
738744
configMock.getBrowserIds.returns(["chrome", "firefox"]);
739745
configMock.forBrowser
@@ -1200,5 +1206,27 @@ describe("CDP/Selectivity", () => {
12001206
assert.notCalled(getSelectivityTestsPathStub);
12011207
assert.notCalled(fsStub.access);
12021208
});
1209+
1210+
it("should skip cleanup when TESTPLANE_SELECTIVITY_CLEAR_UNUSED_DUMPS env var is 'false'", async () => {
1211+
process.env.TESTPLANE_SELECTIVITY_CLEAR_UNUSED_DUMPS = "false";
1212+
1213+
configMock.getBrowserIds.returns(["chrome"]);
1214+
configMock.forBrowser.withArgs("chrome").returns({
1215+
lastFailed: { only: false },
1216+
selectivity: {
1217+
enabled: SelectivityMode.Enabled,
1218+
saveIncompleteDumpOnFail: false,
1219+
testDependenciesPath: "/test/deps",
1220+
},
1221+
});
1222+
1223+
await clearUnusedSelectivityDumps(configMock as any, false);
1224+
1225+
assert.notCalled(configMock.getBrowserIds);
1226+
assert.notCalled(usedDumpsTrackerMock.usedDumpsFor);
1227+
assert.notCalled(getSelectivityTestsPathStub);
1228+
assert.notCalled(fsStub.readdir);
1229+
assert.notCalled(fsStub.unlink);
1230+
});
12031231
});
12041232
});

0 commit comments

Comments
 (0)