@@ -12,7 +12,7 @@ import { getCollectedTestplaneJsDependencies, getCollectedTestplanePngDependenci
1212import { getHashReader } from "./hash-reader" ;
1313import type { Config } from "../../../config" ;
1414import { MasterEvents } from "../../../events" ;
15- import { selectivityShouldRead , selectivityShouldWrite } from "./modes" ;
15+ import { selectivityShouldWrite } from "./modes" ;
1616import { debugSelectivity } from "./debug" ;
1717import { getUsedDumpsTracker } from "./used-dumps-tracker" ;
1818import { DebuggerEvents } from "../domains/debugger" ;
@@ -21,18 +21,22 @@ import { CDPSessionId } from "../types";
2121type StopSelectivityFn = ( test : Test , shouldWrite : boolean ) => Promise < void > ;
2222
2323/**
24- * Called at the end of successfull testplane run
24+ * Called at the end of testplane run
2525 * Not using "Promise.all" here because all hashes are already calculated and cached at the start
2626 */
27- export const updateSelectivityHashes = async ( config : Config ) : Promise < void > => {
27+ export const updateSelectivityHashes = async ( config : Config , isRunFailed : boolean ) : Promise < void > => {
2828 const browserIds = config . getBrowserIds ( ) ;
2929 const processedRoots = new Set ( ) ;
3030
3131 for ( const browserId of browserIds ) {
3232 const browserConfig = config . forBrowser ( browserId ) ;
33- const { enabled, testDependenciesPath, compression, disableSelectivityPatterns } = browserConfig . selectivity ;
34- const shouldReadExistingHashes = selectivityShouldRead ( enabled ) ;
35- const rootKey = `${ shouldReadExistingHashes } #${ testDependenciesPath } #${ compression } ` ;
33+ const { enabled, testDependenciesPath, compression, disableSelectivityPatterns, saveIncompleteDumpOnFail } =
34+ browserConfig . selectivity ;
35+ const rootKey = `${ testDependenciesPath } #${ compression } ` ;
36+
37+ if ( ( isRunFailed || browserConfig . lastFailed . only ) && ! saveIncompleteDumpOnFail ) {
38+ continue ;
39+ }
3640
3741 if ( ! selectivityShouldWrite ( enabled ) || processedRoots . has ( rootKey ) ) {
3842 continue ;
@@ -50,7 +54,7 @@ export const updateSelectivityHashes = async (config: Config): Promise<void> =>
5054 }
5155
5256 try {
53- await hashWriter . save ( shouldReadExistingHashes ) ;
57+ await hashWriter . save ( ) ;
5458 } catch ( cause ) {
5559 throw new Error ( "Selectivity: couldn't save test dependencies hash" , { cause } ) ;
5660 }
@@ -59,16 +63,21 @@ export const updateSelectivityHashes = async (config: Config): Promise<void> =>
5963 }
6064} ;
6165
62- export const clearUnusedSelectivityDumps = async ( config : Config ) : Promise < void > => {
66+ /**
67+ * Called at the end of testplane run
68+ */
69+ export const clearUnusedSelectivityDumps = async ( config : Config , isRunFailed : boolean ) : Promise < void > => {
6370 const usedDumpsTracker = getUsedDumpsTracker ( ) ;
6471 const browserIds = config . getBrowserIds ( ) ;
6572 const selectivityRoots : string [ ] = [ ] ;
6673
6774 for ( const browserId of browserIds ) {
6875 const browserConfig = config . forBrowser ( browserId ) ;
69- const { enabled, testDependenciesPath } = browserConfig . selectivity ;
76+ const { enabled, testDependenciesPath, saveIncompleteDumpOnFail } = browserConfig . selectivity ;
7077
71- if ( selectivityShouldWrite ( enabled ) && ! selectivityRoots . includes ( testDependenciesPath ) ) {
78+ if ( ( isRunFailed && ! saveIncompleteDumpOnFail ) || browserConfig . lastFailed . only ) {
79+ continue ;
80+ } else if ( selectivityShouldWrite ( enabled ) && ! selectivityRoots . includes ( testDependenciesPath ) ) {
7281 selectivityRoots . push ( testDependenciesPath ) ;
7382 }
7483 }
0 commit comments