forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename to squeeze out a bit more balanced perf (2)
- Loading branch information
1 parent
fc7eb53
commit 47c0d67
Showing
64 changed files
with
77 additions
and
21 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,24 +1,80 @@ | ||
/* eslint-disable no-console */ | ||
|
||
require('@packages/coffee/register') | ||
|
||
const _ = require('lodash') | ||
const path = require('path') | ||
const Promise = require('bluebird') | ||
const minimist = require('minimist') | ||
const fs = require('../../lib/util/fs') | ||
const glob = require('../../lib/util/glob') | ||
|
||
glob('test/e2e/**/*') | ||
.map((spec) => { | ||
spec += '.js' | ||
const options = minimist(process.argv.slice(2)) | ||
|
||
const specName = path.basename(spec) | ||
const { size, reset, snapshots } = options | ||
|
||
const pathToSnapshot = path.resolve( | ||
__dirname, '..', '..', '__snapshots__', specName.slice(2) | ||
) | ||
const removeChunkPrefixes = () => { | ||
const forwardSlashNumUnderscoreRe = /(\/\d_)/ | ||
|
||
const renameFiles = (pattern) => { | ||
return glob(pattern) | ||
.map((spec) => { | ||
return fs.renameAsync(spec, spec.replace(forwardSlashNumUnderscoreRe, '/')) | ||
}) | ||
} | ||
|
||
const pathToRenamedSnapshot = path.join( | ||
path.dirname(pathToSnapshot), | ||
specName | ||
return Promise.join( | ||
renameFiles('test/e2e/**/*'), | ||
renameFiles('__snapshots__/**/*') | ||
) | ||
} | ||
|
||
const renameSnapshotsToMatchSpecs = () => { | ||
glob('test/e2e/**/*') | ||
.map((spec) => { | ||
spec += '.js' | ||
|
||
const specName = path.basename(spec) | ||
|
||
const pathToSnapshot = path.resolve( | ||
__dirname, '..', '..', '__snapshots__', specName.slice(2) | ||
) | ||
|
||
const pathToRenamedSnapshot = path.join( | ||
path.dirname(pathToSnapshot), | ||
specName | ||
) | ||
|
||
return fs.renameAsync(pathToSnapshot, pathToRenamedSnapshot) | ||
}) | ||
.catchReturn({ code: 'ENOENT' }, null) | ||
} | ||
|
||
if (reset) { | ||
return removeChunkPrefixes() | ||
} | ||
|
||
if (snapshots) { | ||
return renameSnapshotsToMatchSpecs() | ||
} | ||
|
||
glob('test/e2e/**/*') | ||
.then((specs) => { | ||
if (!size) { | ||
console.error('must include --size for calculating chunk size') | ||
} | ||
|
||
return _.chunk(specs, size) | ||
}) | ||
.map((chunks, index) => { | ||
index += 1 | ||
|
||
return Promise | ||
.map(chunks, (spec) => { | ||
const folder = path.dirname(spec) | ||
const specName = path.basename(spec) | ||
const renamedSpec = `${index}_${specName}` | ||
|
||
return fs.renameAsync(pathToSnapshot, pathToRenamedSnapshot) | ||
return fs.renameAsync(spec, path.join(folder, renamedSpec)) | ||
}) | ||
}) | ||
.catchReturn({ code: 'ENOENT' }, null) |