From 203601893c53f452354e655359308c07b6460115 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 08:04:58 +0100 Subject: [PATCH 01/21] Require FindTests only when needed --- lib/elm-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 1127b77c..ada4252c 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -9,7 +9,6 @@ const packageInfo = require('../package.json'); const Compile = require('./Compile'); const { DependencyProvider } = require('./DependencyProvider.js'); const ElmJson = require('./ElmJson'); -const FindTests = require('./FindTests'); const Generate = require('./Generate'); const Install = require('./Install'); const Project = require('./Project'); @@ -224,6 +223,7 @@ function main() { const project = getProject('make'); const make = async () => { Generate.generateElmJson(dependencyProvider, project); + const FindTests = require('./FindTests'); await Compile.compileSources( FindTests.resolveGlobs( testFileGlobs.length === 0 ? [project.testsDir] : testFileGlobs, From 43d30cc2a469b586e0b4c7b69ac0eaac6a2b5884 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 08:08:53 +0100 Subject: [PATCH 02/21] Require Generate only when needed --- lib/elm-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index ada4252c..d16ee54f 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -9,7 +9,6 @@ const packageInfo = require('../package.json'); const Compile = require('./Compile'); const { DependencyProvider } = require('./DependencyProvider.js'); const ElmJson = require('./ElmJson'); -const Generate = require('./Generate'); const Install = require('./Install'); const Project = require('./Project'); const Report = require('./Report'); @@ -222,8 +221,9 @@ function main() { const pathToElmBinary = getPathToElmBinary(options.compiler); const project = getProject('make'); const make = async () => { - Generate.generateElmJson(dependencyProvider, project); + const Generate = require('./Generate'); const FindTests = require('./FindTests'); + Generate.generateElmJson(dependencyProvider, project); await Compile.compileSources( FindTests.resolveGlobs( testFileGlobs.length === 0 ? [project.testsDir] : testFileGlobs, From ac96cc61caa38b85dc22394b6fde9330b3455082 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 08:10:00 +0100 Subject: [PATCH 03/21] Require RunTests only when needed --- lib/elm-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index d16ee54f..1ba17633 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -12,7 +12,6 @@ const ElmJson = require('./ElmJson'); const Install = require('./Install'); const Project = require('./Project'); const Report = require('./Report'); -const RunTests = require('./RunTests'); void Report; @@ -252,6 +251,7 @@ function main() { const pathToElmBinary = getPathToElmBinary(options.compiler); const projectRootDir = getProjectRootDir('tests'); const processes = Math.max(1, os.cpus().length); + const RunTests = require('./RunTests'); RunTests.runTests( dependencyProvider, projectRootDir, From 37b38f6cf7b00ba6a3a3e515475f5f17eec067fa Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 08:10:50 +0100 Subject: [PATCH 04/21] Require Compile only when needed --- lib/elm-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 1ba17633..9d81ac99 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -6,7 +6,6 @@ const os = require('os'); const path = require('path'); const which = require('which'); const packageInfo = require('../package.json'); -const Compile = require('./Compile'); const { DependencyProvider } = require('./DependencyProvider.js'); const ElmJson = require('./ElmJson'); const Install = require('./Install'); @@ -222,6 +221,7 @@ function main() { const make = async () => { const Generate = require('./Generate'); const FindTests = require('./FindTests'); + const Compile = require('./Compile'); Generate.generateElmJson(dependencyProvider, project); await Compile.compileSources( FindTests.resolveGlobs( From 18a68d08ebb508e3d9d59170dc6c8115425f11f1 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 08:12:13 +0100 Subject: [PATCH 05/21] Compute dependency provider only when needed --- lib/elm-test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 9d81ac99..ecfd6d7d 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -6,7 +6,6 @@ const os = require('os'); const path = require('path'); const which = require('which'); const packageInfo = require('../package.json'); -const { DependencyProvider } = require('./DependencyProvider.js'); const ElmJson = require('./ElmJson'); const Install = require('./Install'); const Project = require('./Project'); @@ -95,8 +94,6 @@ elm-test "src/**/*Tests.elm" `.trim(); function main() { - const dependencyProvider = new DependencyProvider(); - process.title = 'elm-test'; program @@ -222,6 +219,9 @@ function main() { const Generate = require('./Generate'); const FindTests = require('./FindTests'); const Compile = require('./Compile'); + const { DependencyProvider } = require('./DependencyProvider.js'); + const dependencyProvider = new DependencyProvider(); + Generate.generateElmJson(dependencyProvider, project); await Compile.compileSources( FindTests.resolveGlobs( @@ -252,6 +252,8 @@ function main() { const projectRootDir = getProjectRootDir('tests'); const processes = Math.max(1, os.cpus().length); const RunTests = require('./RunTests'); + const { DependencyProvider } = require('./DependencyProvider.js'); + const dependencyProvider = new DependencyProvider(); RunTests.runTests( dependencyProvider, projectRootDir, From 4cb85939f0017f6085e7d002379507b7d5be531a Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 08:16:24 +0100 Subject: [PATCH 06/21] Require which only when needed --- lib/elm-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index ecfd6d7d..249d5f9a 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -4,7 +4,6 @@ const { InvalidOptionArgumentError, Option, program } = require('commander'); const fs = require('fs'); const os = require('os'); const path = require('path'); -const which = require('which'); const packageInfo = require('../package.json'); const ElmJson = require('./ElmJson'); const Install = require('./Install'); @@ -61,6 +60,7 @@ function getProject(subcommand /*: string */) /*: typeof Project.Project */ { function getPathToElmBinary(compiler /*: string | void */) /*: string */ { const name = compiler === undefined ? 'elm' : compiler; + const which = require('which'); try { return path.resolve(which.sync(name)); } catch (_error) { From e50afec12b57172f1b40b8fe9150b2cdb4f6f8be Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 08:17:46 +0100 Subject: [PATCH 07/21] Require Install only when needed --- lib/elm-test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 249d5f9a..13b866fb 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -6,7 +6,6 @@ const os = require('os'); const path = require('path'); const packageInfo = require('../package.json'); const ElmJson = require('./ElmJson'); -const Install = require('./Install'); const Project = require('./Project'); const Report = require('./Report'); @@ -165,6 +164,8 @@ function main() { `Install ${ElmJson.ELM_TEST_PACKAGE} and create tests/Example.elm` ) .action(() => { + const Install = require('./Install'); + const options = program.opts(); const pathToElmBinary = getPathToElmBinary(options.compiler); const project = getProject('init'); @@ -191,6 +192,8 @@ function main() { 'Like `elm install package`, except it installs to "test-dependencies" in your elm.json' ) .action((packageName) => { + const Install = require('./Install'); + const options = program.opts(); const pathToElmBinary = getPathToElmBinary(options.compiler); const project = getProject('install'); From edc095cdf935351bba76ab657018bbbe19d02d2f Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 12:27:40 +0100 Subject: [PATCH 08/21] Require Project only when needed --- lib/elm-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 13b866fb..c51be652 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -6,7 +6,6 @@ const os = require('os'); const path = require('path'); const packageInfo = require('../package.json'); const ElmJson = require('./ElmJson'); -const Project = require('./Project'); const Report = require('./Report'); void Report; @@ -48,7 +47,8 @@ function getProjectRootDir(subcommand /*: string */) /*: string */ { return path.dirname(elmJsonPath); } -function getProject(subcommand /*: string */) /*: typeof Project.Project */ { +function getProject(subcommand /*: string */) { + const Project = require('./Project'); try { return Project.init(getProjectRootDir(subcommand), packageInfo.version); } catch (error) { From 84bdcb55f6872b762d58e46a3f0f19d53a8b3009 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 13:05:46 +0100 Subject: [PATCH 09/21] Hardcode elm-explorations/test to import ElmJson only when necessary --- lib/elm-test.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index c51be652..6087f766 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -5,7 +5,6 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); const packageInfo = require('../package.json'); -const ElmJson = require('./ElmJson'); const Report = require('./Report'); void Report; @@ -26,6 +25,7 @@ const parsePositiveInteger = }; function findClosestElmJson(dir /*: string */) /*: string | void */ { + const ElmJson = require('./ElmJson'); const entry = ElmJson.getPath(dir); return fs.existsSync(entry) ? entry @@ -160,9 +160,7 @@ function main() { program .command('init') - .description( - `Install ${ElmJson.ELM_TEST_PACKAGE} and create tests/Example.elm` - ) + .description('Install elm-explorations/test and create tests/Example.elm') .action(() => { const Install = require('./Install'); @@ -170,7 +168,7 @@ function main() { const pathToElmBinary = getPathToElmBinary(options.compiler); const project = getProject('init'); try { - Install.install(project, pathToElmBinary, ElmJson.ELM_TEST_PACKAGE); + Install.install(project, pathToElmBinary, 'elm-explorations/test'); fs.mkdirSync(project.testsDir, { recursive: true }); fs.copyFileSync( path.join(__dirname, '..', 'templates', 'tests', 'Example.elm'), @@ -181,7 +179,7 @@ function main() { throw process.exit(1); } console.log( - `\nCheck out the documentation for getting started at https://package.elm-lang.org/packages/${ElmJson.ELM_TEST_PACKAGE}/latest` + '\nCheck out the documentation for getting started at https://package.elm-lang.org/packages/elm-explorations/test/latest' ); process.exit(0); }); From e8a23d844d24b2f37f0b2c6872a00522f751f3fd Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 13:06:42 +0100 Subject: [PATCH 10/21] Hardcode Report.all to import Report only when necessary --- lib/Report.js | 3 --- lib/elm-test.js | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/Report.js b/lib/Report.js index 09582148..122c2aa5 100644 --- a/lib/Report.js +++ b/lib/Report.js @@ -4,8 +4,6 @@ // https://github.com/prettier/prettier/issues/2597 const Report /*: 'console' | 'json' | 'junit' */ = 'console'; -const all = ['json', 'junit', 'console']; - function isMachineReadable(report /*: typeof Report */) /*: boolean */ { switch (report) { case 'json': @@ -18,6 +16,5 @@ function isMachineReadable(report /*: typeof Report */) /*: boolean */ { module.exports = { Report, - all, isMachineReadable, }; diff --git a/lib/elm-test.js b/lib/elm-test.js index 6087f766..53630e0f 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -5,9 +5,6 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); const packageInfo = require('../package.json'); -const Report = require('./Report'); - -void Report; const parsePositiveInteger = (minimum /*: number */) => @@ -125,7 +122,7 @@ function main() { 'Specify which format to use for reporting test results' ) .default('console') - .choices(Report.all) + .choices(['json', 'junit', 'console']) ) // `chalk.supportsColor` looks at `process.argv` for these flags. // We still need to define them so they appear in `--help` and aren’t From 2aa97079d7bc35b6c310509bc9da40711db7950b Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 13:21:03 +0100 Subject: [PATCH 11/21] Use loop in findClosestElmJson rather than recursion --- lib/elm-test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 53630e0f..2e9dab68 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -23,12 +23,12 @@ const parsePositiveInteger = function findClosestElmJson(dir /*: string */) /*: string | void */ { const ElmJson = require('./ElmJson'); - const entry = ElmJson.getPath(dir); - return fs.existsSync(entry) - ? entry - : dir === path.parse(dir).root - ? undefined - : findClosestElmJson(path.dirname(dir)); + do { + const entry = ElmJson.getPath(dir); + if (fs.existsSync(entry)) return entry; + dir = path.dirname(dir); + } while (dir !== path.parse(dir).root); + return undefined; } function getProjectRootDir(subcommand /*: string */) /*: string */ { From d642a4dfdf69366d437e9aa1a06bab2d665515d2 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 13:27:18 +0100 Subject: [PATCH 12/21] Require chokidar only when needed --- lib/RunTests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/RunTests.js b/lib/RunTests.js index 42e34320..010b9641 100644 --- a/lib/RunTests.js +++ b/lib/RunTests.js @@ -1,7 +1,6 @@ // @flow const chalk = require('chalk'); -const chokidar = require('chokidar'); const path = require('path'); const readline = require('readline'); const packageInfo = require('../package.json'); @@ -301,6 +300,7 @@ function runTests( } }; + const chokidar = require('chokidar'); watcher = chokidar.watch(alwaysWatched, { ignoreInitial: true, ignored: FindTests.ignoredDirsGlobs, From 0f1781c0b36e1f8878ee51b22ec1900b1366492e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 13:33:31 +0100 Subject: [PATCH 13/21] Compute whether to log only once --- lib/RunTests.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/RunTests.js b/lib/RunTests.js index 010b9641..3baa19b5 100644 --- a/lib/RunTests.js +++ b/lib/RunTests.js @@ -46,36 +46,37 @@ function makeProgressLogger( report /*: typeof Report.Report */, clearConsole /*: boolean */ ) { + const isHumanReadable = !Report.isMachineReadable(report); const items = []; return { log(message) { items.push(message); - if (!Report.isMachineReadable(report)) { + if (isHumanReadable) { process.stdout.write(`${items.join(' > ')}\r`); } }, newLine() { items.length = 0; - if (!Report.isMachineReadable(report)) { + if (isHumanReadable) { process.stdout.write('\n'); } }, overwrite(message) { items.length = 0; items.push(message); - if (!Report.isMachineReadable(report)) { + if (isHumanReadable) { process.stdout.write(`${message}\r`); } }, clearLine() { items.length = 0; - if (!Report.isMachineReadable(report)) { + if (isHumanReadable) { readline.clearLine(process.stdout, 0); } }, clearConsole() { items.length = 0; - if (!Report.isMachineReadable(report) && clearConsole) { + if (isHumanReadable && clearConsole) { process.stdout.write( process.platform === 'win32' ? '\x1B[2J\x1B[0f' From b19f8fa324f22c91b2c723a018802ff0d52662da Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 13:43:44 +0100 Subject: [PATCH 14/21] When output is machine readable, don't bother logging --- lib/RunTests.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/RunTests.js b/lib/RunTests.js index 3baa19b5..c2d45616 100644 --- a/lib/RunTests.js +++ b/lib/RunTests.js @@ -42,41 +42,29 @@ function getPipeFilename(runsExecuted /*: number */) /*: string */ { // `elm.json changed > Compiling-- NAMING ERROR - File.elm` // Also note that using too much `clearLine` or `clearConsole` causes flickering // on Windows, so it's nicer to cleverly overwrite old output when possible. -function makeProgressLogger( - report /*: typeof Report.Report */, - clearConsole /*: boolean */ -) { - const isHumanReadable = !Report.isMachineReadable(report); +function makeHumanReadableProgressLogger(clearConsole /*: boolean */) { const items = []; return { log(message) { items.push(message); - if (isHumanReadable) { - process.stdout.write(`${items.join(' > ')}\r`); - } + process.stdout.write(`${items.join(' > ')}\r`); }, newLine() { items.length = 0; - if (isHumanReadable) { - process.stdout.write('\n'); - } + process.stdout.write('\n'); }, overwrite(message) { items.length = 0; items.push(message); - if (isHumanReadable) { - process.stdout.write(`${message}\r`); - } + process.stdout.write(`${message}\r`); }, clearLine() { items.length = 0; - if (isHumanReadable) { - readline.clearLine(process.stdout, 0); - } + readline.clearLine(process.stdout, 0); }, clearConsole() { items.length = 0; - if (isHumanReadable && clearConsole) { + if (clearConsole) { process.stdout.write( process.platform === 'win32' ? '\x1B[2J\x1B[0f' @@ -87,6 +75,16 @@ function makeProgressLogger( }; } +function makeDummyProgressLogger() { + return { + log(message) {}, // eslint-disable-line no-unused-vars + newLine() {}, + overwrite(message) {}, // eslint-disable-line no-unused-vars + clearLine() {}, + clearConsole() {}, + }; +} + function diffArrays/*:: */( from /*: Array */, to /*: Array */ @@ -146,7 +144,9 @@ function runTests( let currentRun /*: Promise | void */ = undefined; let queue /*: typeof Queue */ = []; - const progressLogger = makeProgressLogger(report, clearConsole); + const progressLogger = Report.isMachineReadable(report) + ? makeDummyProgressLogger() + : makeHumanReadableProgressLogger(clearConsole); async function run() /*: Promise */ { try { From 2ad581bfdf13bcfba34fff4f851cb3ecb1ae939e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 14:02:15 +0100 Subject: [PATCH 15/21] Require readline only when needed --- lib/RunTests.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/RunTests.js b/lib/RunTests.js index c2d45616..90a7492d 100644 --- a/lib/RunTests.js +++ b/lib/RunTests.js @@ -2,7 +2,6 @@ const chalk = require('chalk'); const path = require('path'); -const readline = require('readline'); const packageInfo = require('../package.json'); const Compile = require('./Compile'); const { DependencyProvider } = require('./DependencyProvider.js'); @@ -43,7 +42,9 @@ function getPipeFilename(runsExecuted /*: number */) /*: string */ { // Also note that using too much `clearLine` or `clearConsole` causes flickering // on Windows, so it's nicer to cleverly overwrite old output when possible. function makeHumanReadableProgressLogger(clearConsole /*: boolean */) { + let readline; const items = []; + return { log(message) { items.push(message); @@ -60,6 +61,7 @@ function makeHumanReadableProgressLogger(clearConsole /*: boolean */) { }, clearLine() { items.length = 0; + readline = readline || require('readline'); readline.clearLine(process.stdout, 0); }, clearConsole() { From ce0af0876865e99cf161d418b85be8de5a4c7536 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 20 Feb 2026 13:37:52 +0100 Subject: [PATCH 16/21] Avoid computing watcherEventMessage when message will be hidden --- lib/RunTests.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/RunTests.js b/lib/RunTests.js index 90a7492d..9384d10b 100644 --- a/lib/RunTests.js +++ b/lib/RunTests.js @@ -109,7 +109,12 @@ const Queue /*: Array<{ }> */ = []; void Queue; -function watcherEventMessage(queue /*: typeof Queue */) /*: string */ { +function watcherEventMessage( + isHumanReadable /*: boolean */, + queue /*: typeof Queue */ +) /*: string */ { + if (!isHumanReadable) return ''; + const filePaths = Array.from(new Set(queue.map(({ filePath }) => filePath))); if (filePaths.length === 1) { const { event, filePath } = queue[0]; @@ -173,7 +178,7 @@ function runTests( // Re-print the message in case the queue has become longer while waiting. if (queue.length > queueLengthBeforeWaiting) { progressLogger.clearLine(); - progressLogger.log(watcherEventMessage(queue)); + progressLogger.log(watcherEventMessage(isHumanReadable, queue)); } } @@ -263,7 +268,7 @@ function runTests( const onRunFinish = () => { if (queue.length > 0) { progressLogger.clearConsole(); - progressLogger.log(watcherEventMessage(queue)); + progressLogger.log(watcherEventMessage(isHumanReadable, queue)); currentRun = run().then(onRunFinish); } else { if (!Report.isMachineReadable(report)) { @@ -297,7 +302,7 @@ function runTests( const separator = '='.repeat(message.length); console.log(chalk.blue(`\n\n\n${message}\n${separator}\n\n\n`)); } - progressLogger.log(watcherEventMessage(queue)); + progressLogger.log(watcherEventMessage(isHumanReadable, queue)); currentRun = run().then(onRunFinish); } } From 5d984ca0e8c633e7d0da839112af88701739d0bc Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 14:05:26 +0100 Subject: [PATCH 17/21] Pass package version as an argument --- lib/RunTests.js | 6 +++--- lib/elm-test.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/RunTests.js b/lib/RunTests.js index 9384d10b..713d9823 100644 --- a/lib/RunTests.js +++ b/lib/RunTests.js @@ -2,7 +2,6 @@ const chalk = require('chalk'); const path = require('path'); -const packageInfo = require('../package.json'); const Compile = require('./Compile'); const { DependencyProvider } = require('./DependencyProvider.js'); const ElmJson = require('./ElmJson'); @@ -128,6 +127,7 @@ function watcherEventMessage( function runTests( dependencyProvider /*: DependencyProvider */, projectRootDir /*: string */, + packageVersion /*: string */, pathToElmBinary /*: string */, testFileGlobs /*: Array */, processes /*: number */, @@ -191,7 +191,7 @@ function runTests( // Files may be changed, added or removed so always re-create project info // from disk to stay fresh. - const project = Project.init(projectRootDir, packageInfo.version); + const project = Project.init(projectRootDir, packageVersion); ElmJson.requireElmTestPackage(projectRootDir, project.elmJson); Project.validateTestsSourceDirs(project); @@ -248,7 +248,7 @@ function runTests( progressLogger.newLine(); return await Supervisor.run( - packageInfo.version, + packageVersion, pipeFilename, report, processes, diff --git a/lib/elm-test.js b/lib/elm-test.js index 2e9dab68..7c600703 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -255,6 +255,7 @@ function main() { RunTests.runTests( dependencyProvider, projectRootDir, + packageInfo.version, pathToElmBinary, testFileGlobs, processes, From 5c9ca78c7f962724c7c9183d6d7367bfbccc23af Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 19 Feb 2026 14:06:57 +0100 Subject: [PATCH 18/21] Compute Report.isMachineReadable only once --- lib/RunTests.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/RunTests.js b/lib/RunTests.js index 713d9823..a5c5fca7 100644 --- a/lib/RunTests.js +++ b/lib/RunTests.js @@ -151,9 +151,10 @@ function runTests( let currentRun /*: Promise | void */ = undefined; let queue /*: typeof Queue */ = []; - const progressLogger = Report.isMachineReadable(report) - ? makeDummyProgressLogger() - : makeHumanReadableProgressLogger(clearConsole); + const isHumanReadable = !Report.isMachineReadable(report); + const progressLogger = isHumanReadable + ? makeHumanReadableProgressLogger(clearConsole) + : makeDummyProgressLogger(); async function run() /*: Promise */ { try { @@ -271,7 +272,7 @@ function runTests( progressLogger.log(watcherEventMessage(isHumanReadable, queue)); currentRun = run().then(onRunFinish); } else { - if (!Report.isMachineReadable(report)) { + if (isHumanReadable) { console.log(chalk.blue('Watching for changes...')); } currentRun = undefined; From e572b841998f3d8303e1bd3be9d75e9d39737110 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 20 Feb 2026 13:19:11 +0100 Subject: [PATCH 19/21] Require os only when needed --- lib/elm-test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 7c600703..98589108 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -2,7 +2,6 @@ const { InvalidOptionArgumentError, Option, program } = require('commander'); const fs = require('fs'); -const os = require('os'); const path = require('path'); const packageInfo = require('../package.json'); @@ -245,12 +244,14 @@ function main() { // command and only run tests in `src/`, ignoring all files in `tests/`. .command('__elmTestCommand__ [globs...]', { hidden: true, isDefault: true }) .action((testFileGlobs) => { + const os = require('os'); + const RunTests = require('./RunTests'); + const { DependencyProvider } = require('./DependencyProvider.js'); + const options = program.opts(); const pathToElmBinary = getPathToElmBinary(options.compiler); const projectRootDir = getProjectRootDir('tests'); const processes = Math.max(1, os.cpus().length); - const RunTests = require('./RunTests'); - const { DependencyProvider } = require('./DependencyProvider.js'); const dependencyProvider = new DependencyProvider(); RunTests.runTests( dependencyProvider, From 82ff1445590c1defba9a32dc2ce785b4451086ad Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 20 Feb 2026 13:20:45 +0100 Subject: [PATCH 20/21] Require fs only when needed --- lib/elm-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/elm-test.js b/lib/elm-test.js index 98589108..028a0424 100644 --- a/lib/elm-test.js +++ b/lib/elm-test.js @@ -1,7 +1,6 @@ // @flow const { InvalidOptionArgumentError, Option, program } = require('commander'); -const fs = require('fs'); const path = require('path'); const packageInfo = require('../package.json'); @@ -21,6 +20,7 @@ const parsePositiveInteger = }; function findClosestElmJson(dir /*: string */) /*: string | void */ { + const fs = require('fs'); const ElmJson = require('./ElmJson'); do { const entry = ElmJson.getPath(dir); @@ -158,6 +158,7 @@ function main() { .command('init') .description('Install elm-explorations/test and create tests/Example.elm') .action(() => { + const fs = require('fs'); const Install = require('./Install'); const options = program.opts(); From f5a27eb0c97e784c7629255ec2ae7968d8733ac2 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 20 Feb 2026 13:43:48 +0100 Subject: [PATCH 21/21] Require crypto only when needed --- lib/Solve.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Solve.js b/lib/Solve.js index 21a7e397..221dbf7b 100644 --- a/lib/Solve.js +++ b/lib/Solve.js @@ -1,6 +1,5 @@ // @flow -const crypto = require('crypto'); const fs = require('fs'); const path = require('path'); const ElmJson = require('./ElmJson'); @@ -13,6 +12,7 @@ void Project; void DependencyProvider; function sha256(string) { + const crypto = require('crypto'); return crypto.createHash('sha256').update(string).digest('hex'); }