2023-02-17 18:26:51 +08:00
|
|
|
const t = require('tap')
|
|
|
|
|
|
|
|
const realPlatform = process.platform
|
|
|
|
const fakePlatform = realPlatform === 'win32' ? 'posix' : 'win32'
|
|
|
|
|
|
|
|
t.test('posix', t => {
|
2024-06-18 15:34:22 +08:00
|
|
|
if (realPlatform === 'win32') {
|
2023-02-17 18:26:51 +08:00
|
|
|
process.env.TESTING_TAR_FAKE_PLATFORM = fakePlatform
|
2024-06-18 15:34:22 +08:00
|
|
|
} else {
|
2023-02-17 18:26:51 +08:00
|
|
|
delete process.env.TESTING_TAR_FAKE_PLATFORM
|
2024-06-18 15:34:22 +08:00
|
|
|
}
|
2023-02-17 18:26:51 +08:00
|
|
|
const normPath = t.mock('../lib/normalize-windows-path.js')
|
|
|
|
t.equal(normPath('/some/path/back\\slashes'), '/some/path/back\\slashes')
|
|
|
|
t.equal(normPath('c:\\foo\\bar'), 'c:\\foo\\bar')
|
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
|
|
|
t.test('win32', t => {
|
2024-06-18 15:34:22 +08:00
|
|
|
if (realPlatform !== 'win32') {
|
2023-02-17 18:26:51 +08:00
|
|
|
process.env.TESTING_TAR_FAKE_PLATFORM = fakePlatform
|
2024-06-18 15:34:22 +08:00
|
|
|
} else {
|
2023-02-17 18:26:51 +08:00
|
|
|
delete process.env.TESTING_TAR_FAKE_PLATFORM
|
2024-06-18 15:34:22 +08:00
|
|
|
}
|
2023-02-17 18:26:51 +08:00
|
|
|
const normPath = t.mock('../lib/normalize-windows-path.js')
|
|
|
|
t.equal(normPath('/some/path/back\\slashes'), '/some/path/back/slashes')
|
|
|
|
t.equal(normPath('c:\\foo\\bar'), 'c:/foo/bar')
|
|
|
|
t.end()
|
|
|
|
})
|