Skip to content

Commit bc33fe1

Browse files
committed
skip tilde test on systems that lack tilde expansion
1 parent 59bf9ca commit bc33fe1

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

test/progra-tilde.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
import t from 'tap'
33

44
import { globSync } from '../dist/esm/index.js'
5-
6-
if (process.platform !== 'win32') {
7-
t.pass('no need to test this except on windows')
8-
process.exit(0)
9-
}
5+
import { statSync } from 'node:fs'
106

117
const dir = t.testdir({
128
'program files': {
@@ -16,6 +12,25 @@ const dir = t.testdir({
1612
},
1713
})
1814

15+
// gut check that we're on a system that does tilde expansion
16+
// this can be disabled on some Windows systems for security,
17+
// which of course breaks this test.
18+
try {
19+
const programFiles = statSync(`${dir}/program files`)
20+
const prograTilde = statSync(`${dir}/progra~1`)
21+
if (
22+
!programFiles.isDirectory() ||
23+
!prograTilde.isDirectory() ||
24+
programFiles.dev !== prograTilde.dev ||
25+
programFiles.ino !== prograTilde.ino
26+
) {
27+
throw 'nope'
28+
}
29+
} catch {
30+
t.pass('n/a', { skip: 'this system does not do tilde expansion' })
31+
process.exit(0)
32+
}
33+
1934
t.strictSame(
2035
globSync('progra~1\\*', { cwd: dir, windowsPathsNoEscape: true }).sort(
2136
(a, b) => a.localeCompare(b, 'en'),

0 commit comments

Comments
 (0)