From 49a0ad0f7ed83750ae71e6fb0b322eba874d0ccd Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Sat, 5 Nov 2022 16:41:12 +0100 Subject: [PATCH] Fix pull diagnostics --- benchmark/run.js | 23 ++++++++++++++--------- crates/rome_cli/src/traversal.rs | 7 ++++++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/benchmark/run.js b/benchmark/run.js index 35b7bc1141ff..c0f9944df812 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -8,7 +8,7 @@ const TMP_DIRECTORY = path.resolve("./target"); function buildRome() { console.log("Build Rome..."); - child_process.execSync("cargo build --bin rome --release"); + child_process.execSync("cargo build --bin rome --release", { stdio: "inherit" }); return path.resolve("../target/release/rome"); } @@ -79,7 +79,7 @@ function benchmarkFormatter(rome) { const romeSingleCoreCommand = withEnvVariable( "RAYON_NUM_THREADS", - "1", + "3", romeCommand, ); @@ -107,12 +107,10 @@ function benchmarkLinter(rome) { for (const [name, configuration] of Object.entries(BENCHMARKS.linter)) { console.log(`[${name}]`); - let projectDirectory = cloneProject(name, configuration.repository); - let eslintIgnore = path.join(projectDirectory, ".eslintignore"); + const projectDirectory = cloneProject(name, configuration.repository); - if (fs.existsSync(eslintIgnore)) { - fs.rmSync(eslintIgnore); - } + deleteFile(path.join(projectDirectory, ".eslintignore")); + deleteFile(path.join(projectDirectory, "eslint.config.js")); // Override eslint config const eslintConfig = fs.readFileSync("./bench.eslint.js"); @@ -131,11 +129,12 @@ function benchmarkLinter(rome) { .map((directory) => `'${directory}'`) .join(" "); - const romeCommand = `${rome} check ${romePaths}`; + // Don't compute the code frames for pulled diagnostics. ESLint doesn't do so as well. + const romeCommand = `${rome} check --max-diagnostics=0 ${romePaths}`; const romeSingleCoreCommand = withEnvVariable( "RAYON_NUM_THREADS", - "1", + "3", romeCommand, ); @@ -185,6 +184,12 @@ function withDirectory(cwd) { }; } +function deleteFile(path) { + if (fs.existsSync(path)) { + fs.rmSync(path); + } +} + function cloneProject(name, repository) { let projectDirectory = path.join(TMP_DIRECTORY, name); diff --git a/crates/rome_cli/src/traversal.rs b/crates/rome_cli/src/traversal.rs index dabdc4f2d5af..867e3cf9b48d 100644 --- a/crates/rome_cli/src/traversal.rs +++ b/crates/rome_cli/src/traversal.rs @@ -78,7 +78,12 @@ pub(crate) fn traverse(execution: Execution, mut session: CliSession) -> Result< let console = &mut *session.app.console; let mut has_errors = None; - let remaining_diagnostics = Arc::new(AtomicU64::new(u64::MAX)); + let remaining_diagnostics = Arc::new(AtomicU64::new( + execution + .get_max_diagnostics() + .map(u64::from) + .unwrap_or(u64::MAX), + )); let mut duration = None; let mut report = None;