Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from mrmlnc/FG-277_smoke_tests_for_root_case
ISSUE-277: smoke tests for patterns that starts with the leading slash
- Loading branch information
Showing
5 changed files
with
74 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import * as entry from './utils/entry'; | ||
import * as errno from './utils/errno'; | ||
import * as pattern from './utils/pattern'; | ||
import * as platform from './utils/platform'; | ||
import * as task from './utils/task'; | ||
|
||
export { | ||
entry, | ||
errno, | ||
pattern, | ||
platform, | ||
task | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as path from 'path'; | ||
|
||
import * as smoke from './smoke'; | ||
import * as utils from '..'; | ||
|
||
const CWD = process.cwd().replace(/\\/g, '/'); | ||
const ROOT = path.parse(CWD).root; | ||
|
||
smoke.suite('Smoke → Root', [ | ||
{ | ||
pattern: '/*', | ||
condition: () => !utils.platform.isWindows() | ||
}, | ||
{ | ||
pattern: '/tmp/*', | ||
condition: () => !utils.platform.isWindows() | ||
}, | ||
{ | ||
pattern: '/*', | ||
condition: () => utils.platform.isSupportReaddirWithFileTypes() && utils.platform.isWindows(), | ||
correct: true, | ||
reason: 'The `node-glob` packages returns items with resolve path for the current disk letter' | ||
}, | ||
// UNC pattern without dynamic sections in the base section | ||
{ | ||
pattern: `//?/${ROOT}*`, | ||
condition: () => utils.platform.isSupportReaddirWithFileTypes() && utils.platform.isWindows(), | ||
correct: true, | ||
reason: 'The `node-glob` package does not allow to use UNC in patterns' | ||
} | ||
]); | ||
|
||
smoke.suite('Smoke → Root (cwd)', [ | ||
{ | ||
pattern: '*', | ||
cwd: ROOT, | ||
condition: () => !utils.platform.isWindows() || utils.platform.isSupportReaddirWithFileTypes() | ||
}, | ||
// UNC on Windows | ||
{ | ||
pattern: '*', | ||
cwd: `//?/${ROOT}`, | ||
condition: () => utils.platform.isSupportReaddirWithFileTypes() && utils.platform.isWindows() | ||
} | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as os from 'os'; | ||
|
||
const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); | ||
|
||
const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); | ||
const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); | ||
|
||
const SUPPORTED_MAJOR_VERSION = 10; | ||
const SUPPORTED_MINOR_VERSION = 10; | ||
|
||
const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION; | ||
const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION; | ||
|
||
/** | ||
* IS `true` for Node.js 10.10 and greater. | ||
*/ | ||
export const IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR; | ||
|
||
export function isWindows(): boolean { | ||
return os.platform() === 'win32'; | ||
} | ||
|
||
export function isSupportReaddirWithFileTypes(): boolean { | ||
return IS_SUPPORT_READDIR_WITH_FILE_TYPES; | ||
} |