Skip to content

Commit

Permalink
Merge pull request #341 from France-ioi/randomize-tests-order
Browse files Browse the repository at this point in the history
Modify option to randomize all tests order (in case of success as of failure)
  • Loading branch information
SebastienTainon authored Aug 21, 2023
2 parents 1ef212f + fa67d9e commit 24149e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions frontend/common/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
12 changes: 9 additions & 3 deletions frontend/stepper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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}));
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface CodecastOptions {
viewTestDetails?: boolean,
logAttempts?: boolean,
allowExecutionOverBlocksLimit?: boolean,
showRandomFailedTest?: boolean,
randomizeTestsOrder?: boolean,
ioMode: IoMode,
}

Expand Down
1 change: 1 addition & 0 deletions frontend/task/fixtures/11_variable_08_sokoban/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default {
zoom: {
wheel: true,
},
// hiddenTests: true,
includeBlocks: {
groupByCategory: {
easy: false,
Expand Down

0 comments on commit 24149e2

Please sign in to comment.