/** * Creates a an exact copy of the AUT. * @private * @returns {Promise} - Promise that resolves once the copy is created. */ async copyFirst () { console.logSame('Creating a copy of your module... ') await copyDir('./', `.mutode/mutode-${this.id}-0`, { dot: true, filter: p => !p.startsWith('.') }) console.log('Done\n') }
/** * Creates <i>this.concurrency<i/> exact copies of the AUT. * @private * @returns {Promise} - Promise that resolves once the copies are created. */ async copy () { if (this.concurrency === 1) return console.logSame(`Creating ${this.concurrency - 1} extra copies of your module... `) for (let i = 1; i < this.concurrency; i++) { console.logSame(`${i}.. `) await copyDir('./', `.mutode/mutode-${this.id}-${i}`, { dot: true, filter: p => !p.startsWith('.') }) } console.log('Done\n') }
/** * Deletes available copies of the AUT. * @private * @returns {Promise} - Promise that resolves once copies have been deleted. */ async delete () { const toDelete = await globby('.mutode/*', { dot: true, onlyDirectories: true }) if (toDelete.length === 0) return console.logSame('Deleting copies...') for (const path of toDelete) { await del(path, { force: true }) } console.log('Done\n') }
/** * Synchronous load of mutators. * @private * @returns {Promise} - Promise that resolves with the loaded mutators */ static async loadMutants (mutatorsNames) { console.logSame('Loading mutators... ') let mutatorsPaths = mutatorsNames.map(m => `mutators/${m}Mutator.js`) const mutators = [] const mutatorsPath = path.resolve(__dirname, 'mutators/') mutatorsPaths = await globby(mutatorsPaths, { cwd: __dirname, absolute: true }) for (const mutatorPath of mutatorsPaths) { debug('Loaded mutator %s', mutatorPath.replace(mutatorsPath + '/', '').replace('Mutator.js', '')) mutators.push(require(path.resolve(mutatorPath))) } console.log('Done\n') return mutators }