From 3aa1abd025b2dd29cdc4cf92a9f64ef28c962af9 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 25 Feb 2023 14:45:49 -0800 Subject: [PATCH] more windows test affordances --- test/match-base.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/test/match-base.ts b/test/match-base.ts index 3cdfabb9..80995d9a 100644 --- a/test/match-base.ts +++ b/test/match-base.ts @@ -2,6 +2,9 @@ import t from 'tap' import glob from '../' import { resolve } from 'path' +import { sep } from 'path' +const alphasort = (a:string, b:string) => a.localeCompare(b, 'en') +const j = (a: string[]) => a.map(s => s.split('/').join(sep)).sort(alphasort) const fixtureDir = resolve(__dirname, 'fixtures') @@ -12,18 +15,14 @@ if (process.platform !== 'win32') { expect.push('a/symlink/a', 'a/symlink/a/b/c/a') } -const alphasort = (a: string, b: string) => a.localeCompare(b, 'en') - -expect.sort(alphasort) - t.test('chdir', async t => { const origCwd = process.cwd() process.chdir(fixtureDir) t.teardown(() => process.chdir(origCwd)) - t.same(glob.sync(pattern, { matchBase: true }).sort(alphasort), expect) + t.same(glob.sync(pattern, { matchBase: true }).sort(alphasort), j(expect)) t.same( (await glob(pattern, { matchBase: true })).sort(alphasort), - expect + j(expect) ) }) @@ -32,13 +31,13 @@ t.test('cwd', async t => { glob .sync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - expect + j(expect) ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( alphasort ), - expect + j(expect) ) }) @@ -55,13 +54,13 @@ t.test('pattern includes /', async t => { glob .sync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - expect + j(expect) ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( alphasort ), - expect + j(expect) ) }) @@ -72,13 +71,13 @@ t.test('one brace section of pattern includes /', async t => { glob .sync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - exp + j(exp) ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( alphasort ), - exp + j(exp) ) }) @@ -89,12 +88,12 @@ t.test('one array member of pattern includes /', async t => { glob .sync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - exp + j(exp) ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( alphasort ), - exp + j(exp) ) })