Skip to content

Commit

Permalink
address dev review: move retries to variable remove try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
seaona committed May 21, 2024
1 parent 65b3467 commit df8d21e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions development/lib/retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ async function retry(
console.error('error caught in retry():', error);
}

if (attempts < retries) {
console.log('Ready to retry() again');
if (retryUntilFailure) {
throw new Error('Test failed. No more retries will be performed');
}

if (retryUntilFailure) {
return null;
if (attempts < retries) {
console.log('Ready to retry() again');
}
} finally {
attempts += 1;
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fetch-changed-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function fetchChangedE2eFiles() {
return filesChanged;
} catch (error) {
console.error('Error making request:', error);
throw error;
return '';
}
}

Expand Down
13 changes: 5 additions & 8 deletions test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,9 @@ async function main() {

console.log('My test list:', myTestList);

let changedOrNewTests = '';
try {
changedOrNewTests = await fetchChangedE2eFiles();
} catch (error) {
console.error('Error fetching changed e2e files:', error);
}
const changedOrNewTests = await fetchChangedE2eFiles();
const retriesForChangedOrNewTests = 5;

console.log('Spec files that will be re-run:', changedOrNewTests);

// spawn `run-e2e-test.js` for each test in myTestList
Expand All @@ -228,14 +225,14 @@ async function main() {
console.log(`\nExecuting testPath: ${testPath}\n`);

const testFileName = testPath.split('/').pop();
const isTestChangedOrNew = changedOrNewTests.includes(testFileName);
const isTestChangedOrNew = changedOrNewTests?.includes(testFileName);
const retryIndex = args.indexOf('--retries');
if (retryIndex !== -1) {
args.splice(retryIndex, 2);
}

const extraArgs = isTestChangedOrNew
? ['--retry-until-failure', '--retries=5']
? ['--retry-until-failure', `--retries=${retriesForChangedOrNewTests}`]
: [];
await runInShell('node', [...args, ...extraArgs, testPath]);
}
Expand Down

0 comments on commit df8d21e

Please sign in to comment.