From fa67d9e3bca9b45c37ca095efe767578e09f9b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Tainon?= Date: Mon, 21 Aug 2023 11:31:19 +0200 Subject: [PATCH] Modify option to randomize all tests order (in case of success as of failure) --- frontend/common/options.ts | 6 +++--- frontend/stepper/index.ts | 12 +++++++++--- frontend/store.ts | 2 +- .../task/fixtures/11_variable_08_sokoban/index.ts | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/common/options.ts b/frontend/common/options.ts index 688de9c5..83c45c44 100644 --- a/frontend/common/options.ts +++ b/frontend/common/options.ts @@ -113,8 +113,8 @@ function loadOptionsFromQuery(options: CodecastOptions, query) { if ('allowExecutionOverBlocksLimit' in query) { options.allowExecutionOverBlocksLimit = true; } - if ('randomFailedTest' in query) { - options.showRandomFailedTest = true; + if ('randomizeTestsOrder' in query) { + options.randomizeTestsOrder = true; } if ('ioMode' in query && 'split' === query.ioMode) { options.ioMode = IoMode.Split; @@ -137,7 +137,7 @@ function appInitReducer(state: AppStore, {payload: {options, query}}) { if ('tralalere' === state.options.app) { state.options.logAttempts = true; state.options.allowExecutionOverBlocksLimit = true; - state.options.showRandomFailedTest = true; + state.options.randomizeTestsOrder = true; } loadOptionsFromQuery(options, query); diff --git a/frontend/stepper/index.ts b/frontend/stepper/index.ts index 3b191101..dae9b317 100644 --- a/frontend/stepper/index.ts +++ b/frontend/stepper/index.ts @@ -1147,11 +1147,12 @@ function* stepperRunBackgroundSaga(app: App, {payload: {callback}}) { const context = quickAlgoLibraries.getContext(null, 'main'); if (context && context.infos.hiddenTests) { preExecutionTests = [...tests.keys()]; - if (state.options.showRandomFailedTest) { + if (state.options.randomizeTestsOrder) { preExecutionTests = shuffleArray(preExecutionTests); } } + let firstBackgroundResult = null; let lastBackgroundResult = null; for (let preExecutionTestId of preExecutionTests) { const {success, exit} = yield* race({ @@ -1162,6 +1163,9 @@ function* stepperRunBackgroundSaga(app: App, {payload: {callback}}) { if (success) { log.getLogger('stepper').debug('run background result', success); lastBackgroundResult = success; + if (null === firstBackgroundResult) { + firstBackgroundResult = success; + } // @ts-ignore if (!success.result) { break; @@ -1174,7 +1178,9 @@ function* stepperRunBackgroundSaga(app: App, {payload: {callback}}) { } log.getLogger('stepper').debug('return result'); - callback(lastBackgroundResult); + + // If we succeed everything, return the first test, otherwise return the first failed test + callback(lastBackgroundResult && lastBackgroundResult.result ? firstBackgroundResult : lastBackgroundResult); } function* stepperCompileFromControlsSaga(app: App) { @@ -1194,7 +1200,7 @@ function* stepperCompileFromControlsSaga(app: App) { if (null !== backgroundRunData) { const context = quickAlgoLibraries.getContext(null, 'main'); const currentTestId = yield* appSelect(state => state.task.currentTestId); - if (context && context.infos.hiddenTests && !backgroundRunData.result && backgroundRunData.testId !== currentTestId) { + if (context && context.infos.hiddenTests && backgroundRunData.testId !== currentTestId) { log.getLogger('stepper').debug('change test', backgroundRunData.testId); yield* put(updateCurrentTestId({testId: backgroundRunData.testId})); } diff --git a/frontend/store.ts b/frontend/store.ts index 896218c7..eb72631b 100644 --- a/frontend/store.ts +++ b/frontend/store.ts @@ -86,7 +86,7 @@ export interface CodecastOptions { viewTestDetails?: boolean, logAttempts?: boolean, allowExecutionOverBlocksLimit?: boolean, - showRandomFailedTest?: boolean, + randomizeTestsOrder?: boolean, ioMode: IoMode, } diff --git a/frontend/task/fixtures/11_variable_08_sokoban/index.ts b/frontend/task/fixtures/11_variable_08_sokoban/index.ts index e0a8eadf..187a9c10 100644 --- a/frontend/task/fixtures/11_variable_08_sokoban/index.ts +++ b/frontend/task/fixtures/11_variable_08_sokoban/index.ts @@ -37,6 +37,7 @@ export default { zoom: { wheel: true, }, + // hiddenTests: true, includeBlocks: { groupByCategory: { easy: false,