From bd501419d951b66dcb269949cb1741edc100a7e8 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 13 Nov 2024 09:47:11 -0500 Subject: [PATCH] Switch from --sort in tests to preserving glob@8 sorting --- lib/cli/lookup-files.js | 13 +++++++++---- test/integration/options/parallel.spec.js | 2 -- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/cli/lookup-files.js b/lib/cli/lookup-files.js index 7b3cdd1e65..ad7c9c1f8c 100644 --- a/lib/cli/lookup-files.js +++ b/lib/cli/lookup-files.js @@ -87,10 +87,15 @@ module.exports = function lookupFiles( debug('looking for files using glob pattern: %s', pattern); } files.push( - ...glob.sync(pattern, { - nodir: true, - windowsPathsNoEscape: true - }) + ...glob + .sync(pattern, { + nodir: true, + windowsPathsNoEscape: true + }) + // glob@8 and earlier sorted results in en; glob@9 depends on OS sorting. + // This preserves the older glob behavior. + // https://github.com/mochajs/mocha/pull/5250 + .sort((a, b) => a.localeCompare(b, 'en')) ); if (!files.length) { throw createNoFilesMatchPatternError( diff --git a/test/integration/options/parallel.spec.js b/test/integration/options/parallel.spec.js index 68f65440af..1cde3e602d 100644 --- a/test/integration/options/parallel.spec.js +++ b/test/integration/options/parallel.spec.js @@ -92,7 +92,6 @@ describe('--parallel', function () { it('should have the same result as with --no-parallel', async function () { const expected = await runMochaAsync('options/parallel/test-*', [ '--no-parallel', - '--sort' ]); return expect( runMochaAsync('options/parallel/test-*', ['--parallel']), @@ -303,7 +302,6 @@ describe('--parallel', function () { '--reporter', reporter, '--no-parallel', - '--sort' ]); return expect( runMochaAsync('options/parallel/test-*', [