diff --git a/script/get-changes-since b/script/get-changes-since index e88505008c..c070616820 100755 --- a/script/get-changes-since +++ b/script/get-changes-since @@ -2,7 +2,7 @@ const { execFileSync } = require("child_process"); const { GITHUB_ACCESS_TOKEN } = process.env; -const PR_REGEX = /#\d+/ // Ex: matches on #4241 +const PR_REGEX = /#\d+/; // Ex: matches on #4241 const FIXES_REGEX = /(fixes|closes|completes) (.+[/#]\d+.*)$/im; main(); @@ -10,7 +10,7 @@ main(); async function main() { // Use form of: YYYY-MM-DD - 2023-01-09 const startDate = new Date(process.argv[2]); - const today = new Date() + const today = new Date(); console.log(`Changes from ${startDate} to ${today}\n`); @@ -32,32 +32,26 @@ async function main() { console.log("*", pullRequest.title); console.log(" PR URL: ", webURL); console.log(" Merged: ", pullRequest.merged_at); - console.log() + console.log(); } } - function getPullRequestNumbers(startDate, endDate) { const sinceDate = startDate.toISOString(); const untilDate = endDate.toISOString(); const pullRequestNumbers = execFileSync( "git", - [ - "log", - `--since=${sinceDate}`, - `--until=${untilDate}`, - "--oneline" - ], - { encoding: "utf8" } + ["log", `--since=${sinceDate}`, `--until=${untilDate}`, "--oneline"], + { encoding: "utf8" }, ) .split("\n") - .filter(line => line.length > 0) - .map(line => { + .filter((line) => line.length > 0) + .map((line) => { const match = line.match(/#(\d+)/); return match ? match[1] : null; }) - .filter(line => line); + .filter((line) => line); return pullRequestNumbers; } diff --git a/script/randomized-test-minimize b/script/randomized-test-minimize index df003cbf3e..efed3ee501 100755 --- a/script/randomized-test-minimize +++ b/script/randomized-test-minimize @@ -1,131 +1,135 @@ #!/usr/bin/env node --redirect-warnings=/dev/null -const fs = require('fs') -const path = require('path') -const {spawnSync} = require('child_process') +const fs = require("fs"); +const path = require("path"); +const { spawnSync } = require("child_process"); -const FAILING_SEED_REGEX = /failing seed: (\d+)/ig -const CARGO_TEST_ARGS = [ - '--release', - '--lib', - '--package', 'collab', -] +const FAILING_SEED_REGEX = /failing seed: (\d+)/gi; +const CARGO_TEST_ARGS = ["--release", "--lib", "--package", "collab"]; if (require.main === module) { if (process.argv.length < 4) { - process.stderr.write("usage: script/randomized-test-minimize [start-index]\n") - process.exit(1) + process.stderr.write( + "usage: script/randomized-test-minimize [start-index]\n", + ); + process.exit(1); } minimizeTestPlan( process.argv[2], process.argv[3], - parseInt(process.argv[4]) || 0 + parseInt(process.argv[4]) || 0, ); } -function minimizeTestPlan( - inputPlanPath, - outputPlanPath, - startIndex = 0 -) { - const tempPlanPath = inputPlanPath + '.try' +function minimizeTestPlan(inputPlanPath, outputPlanPath, startIndex = 0) { + const tempPlanPath = inputPlanPath + ".try"; - fs.copyFileSync(inputPlanPath, outputPlanPath) - let testPlan = JSON.parse(fs.readFileSync(outputPlanPath, 'utf8')) + fs.copyFileSync(inputPlanPath, outputPlanPath); + let testPlan = JSON.parse(fs.readFileSync(outputPlanPath, "utf8")); - process.stderr.write("minimizing failing test plan...\n") + process.stderr.write("minimizing failing test plan...\n"); for (let ix = startIndex; ix < testPlan.length; ix++) { // Skip 'MutateClients' entries, since they themselves are not single operations. if (testPlan[ix].MutateClients) { - continue + continue; } // Remove a row from the test plan - const newTestPlan = testPlan.slice() - newTestPlan.splice(ix, 1) - fs.writeFileSync(tempPlanPath, serializeTestPlan(newTestPlan), 'utf8'); + const newTestPlan = testPlan.slice(); + newTestPlan.splice(ix, 1); + fs.writeFileSync(tempPlanPath, serializeTestPlan(newTestPlan), "utf8"); - process.stderr.write(`${ix}/${testPlan.length}: ${JSON.stringify(testPlan[ix])}`) + process.stderr.write( + `${ix}/${testPlan.length}: ${JSON.stringify(testPlan[ix])}`, + ); const failingSeed = runTests({ - SEED: '0', + SEED: "0", LOAD_PLAN: tempPlanPath, SAVE_PLAN: tempPlanPath, - ITERATIONS: '500' - }) + ITERATIONS: "500", + }); // If the test failed, keep the test plan with the removed row. Reload the test // plan from the JSON file, since the test itself will remove any operations // which are no longer valid before saving the test plan. if (failingSeed != null) { - process.stderr.write(` - remove. failing seed: ${failingSeed}.\n`) - fs.copyFileSync(tempPlanPath, outputPlanPath) - testPlan = JSON.parse(fs.readFileSync(outputPlanPath, 'utf8')) - ix-- + process.stderr.write(` - remove. failing seed: ${failingSeed}.\n`); + fs.copyFileSync(tempPlanPath, outputPlanPath); + testPlan = JSON.parse(fs.readFileSync(outputPlanPath, "utf8")); + ix--; } else { - process.stderr.write(` - keep.\n`) + process.stderr.write(` - keep.\n`); } } - fs.unlinkSync(tempPlanPath) + fs.unlinkSync(tempPlanPath); // Re-run the final minimized plan to get the correct failing seed. // This is a workaround for the fact that the execution order can // slightly change when replaying a test plan after it has been // saved and loaded. const failingSeed = runTests({ - SEED: '0', - ITERATIONS: '5000', + SEED: "0", + ITERATIONS: "5000", LOAD_PLAN: outputPlanPath, - }) + }); - process.stderr.write(`final test plan: ${outputPlanPath}\n`) - process.stderr.write(`final seed: ${failingSeed}\n`) - return failingSeed + process.stderr.write(`final test plan: ${outputPlanPath}\n`); + process.stderr.write(`final seed: ${failingSeed}\n`); + return failingSeed; } function buildTests() { - const {status} = spawnSync('cargo', ['test', '--no-run', ...CARGO_TEST_ARGS], { - stdio: 'inherit', - encoding: 'utf8', - env: { - ...process.env, - } - }); + const { status } = spawnSync( + "cargo", + ["test", "--no-run", ...CARGO_TEST_ARGS], + { + stdio: "inherit", + encoding: "utf8", + env: { + ...process.env, + }, + }, + ); if (status !== 0) { - throw new Error('build failed') + throw new Error("build failed"); } } function runTests(env) { - const {status, stdout} = spawnSync('cargo', ['test', ...CARGO_TEST_ARGS, 'random_project_collaboration'], { - stdio: 'pipe', - encoding: 'utf8', - env: { - ...process.env, - ...env, - } - }); + const { status, stdout } = spawnSync( + "cargo", + ["test", ...CARGO_TEST_ARGS, "random_project_collaboration"], + { + stdio: "pipe", + encoding: "utf8", + env: { + ...process.env, + ...env, + }, + }, + ); if (status !== 0) { - FAILING_SEED_REGEX.lastIndex = 0 - const match = FAILING_SEED_REGEX.exec(stdout) + FAILING_SEED_REGEX.lastIndex = 0; + const match = FAILING_SEED_REGEX.exec(stdout); if (!match) { - process.stderr.write("test failed, but no failing seed found:\n") - process.stderr.write(stdout) - process.stderr.write('\n') - process.exit(1) + process.stderr.write("test failed, but no failing seed found:\n"); + process.stderr.write(stdout); + process.stderr.write("\n"); + process.exit(1); } - return match[1] + return match[1]; } else { - return null + return null; } } function serializeTestPlan(plan) { - return "[\n" + plan.map(row => JSON.stringify(row)).join(",\n") + "\n]\n" + return "[\n" + plan.map((row) => JSON.stringify(row)).join(",\n") + "\n]\n"; } -exports.buildTests = buildTests -exports.runTests = runTests -exports.minimizeTestPlan = minimizeTestPlan +exports.buildTests = buildTests; +exports.runTests = runTests; +exports.minimizeTestPlan = minimizeTestPlan;