diff --git a/package.json b/package.json index 2a994bccb1..a1fd5337b2 100644 --- a/package.json +++ b/package.json @@ -29,13 +29,14 @@ "contributors": [ "Simon de Lang ", "Nico Jansen ", - "global ", "Philipp Weissenbacher ", "Jasper Catthoor ", "Nico Stapelbroek ", "Alex van Assem ", "Jeremy Nagel ", - "Michael Williamson " + "Michael Williamson ", + "Philipp Weissenbacher ", + "Alex van Assem filePaths.map(filePath => this.createInputFile(filePath))); + + // If there is a previous globbing expression, resolve that one as well if (this.previous) { - // If there is a previous globbing expression, resolve that one as well return Promise.all([this.previous.resolve(), globbingTask]).then(results => { const previousFiles = results[0]; const currentFiles = results[1]; // If this expression started with a '!', exclude current files if (this.ignore) { - return previousFiles.filter(previousFile => currentFiles.some(currentFile => previousFile.path !== currentFile.path)); + return previousFiles.filter(previousFile => currentFiles.every(currentFile => previousFile.path !== currentFile.path)); } else { // Only add files which were not already added return previousFiles.concat(currentFiles.filter(currentFile => !previousFiles.some(file => file.path === currentFile.path))); diff --git a/src/reporters/ProgressReporter.ts b/src/reporters/ProgressReporter.ts index 5255eaa926..5122891c23 100644 --- a/src/reporters/ProgressReporter.ts +++ b/src/reporters/ProgressReporter.ts @@ -12,11 +12,11 @@ export default class ProgressReporter implements Reporter { killed: 0, timeout: 0, noCoverage: 0, - killedLabel: `${chalk.green.bold('killed')}`, - survivedLabel: `${chalk.red.bold('survived')}`, - noCoverageLabel: `${chalk.red.bold('no coverage')}`, - timeoutLabel: `${chalk.yellow.bold('timeout')}`, - errorLabel: `${chalk.yellow.bold('error')}` + killedLabel: chalk.green.bold('killed'), + survivedLabel: chalk.red.bold('survived'), + noCoverageLabel: chalk.red.bold('no coverage'), + timeoutLabel: chalk.yellow.bold('timeout'), + errorLabel: chalk.yellow.bold('error') }; onAllMutantsMatchedWithTests(matchedMutants: ReadonlyArray): void { diff --git a/src/utils/fileUtils.ts b/src/utils/fileUtils.ts index 95855a4284..21e04636e7 100644 --- a/src/utils/fileUtils.ts +++ b/src/utils/fileUtils.ts @@ -54,7 +54,7 @@ export function normalize(files: string[]): void { export function glob(expression: string): Promise { return new Promise((resolve, reject) => { - nodeGlob(expression, (error, matches) => { + nodeGlob(expression, { nodir: true }, (error, matches) => { if (error) { reject(error); } else { diff --git a/test/integration/utils/fileUtilsSpec.ts b/test/integration/utils/fileUtilsSpec.ts index 7dd12d3bf6..a867b7fcd1 100644 --- a/test/integration/utils/fileUtilsSpec.ts +++ b/test/integration/utils/fileUtilsSpec.ts @@ -13,9 +13,8 @@ describe('fileUtils', () => { afterEach(() => sandbox.restore()); - describe('should be able to read a file', () => { - - it('synchronously', () => { + describe('readFileSync()', () => { + it('should synchronously', () => { const msg = 'hello 1 2'; sandbox.stub(fs, 'readFileSync', (filename: string, encoding: string) => msg); const data = fileUtils.readFile('hello.js'); @@ -23,16 +22,25 @@ describe('fileUtils', () => { }); }); - it('should indicate that an existing file exists', () => { - const exists = fileUtils.fileOrFolderExistsSync('src/Stryker.ts'); + describe('fileOrFolderExistsSync()', () => { + it('should indicate that an existing file exists', () => { + const exists = fileUtils.fileOrFolderExistsSync('src/Stryker.ts'); + + expect(exists).to.equal(true); + }); + it('should indicate that an non-existing file does not exists', () => { + const exists = fileUtils.fileOrFolderExistsSync('src/Strykerfaefeafe.js'); - expect(exists).to.equal(true); + expect(exists).to.equal(false); + }); }); - it('should indicate that an non-existing file does not exists', () => { - const exists = fileUtils.fileOrFolderExistsSync('src/Strykerfaefeafe.js'); + describe('glob', () => { + it('should resolve files', () => + expect(fileUtils.glob('testResources/sampleProject/**/*.js')).to.eventually.have.length(9)); - expect(exists).to.equal(false); + it('should not resolve to directories', () => + expect(fileUtils.glob('testResources/vendor/**/*.js')).to.eventually.have.length(1)); }); }); diff --git a/test/unit/InputFileResolverSpec.ts b/test/unit/InputFileResolverSpec.ts index d0a1a955b6..52e33a4dcf 100644 --- a/test/unit/InputFileResolverSpec.ts +++ b/test/unit/InputFileResolverSpec.ts @@ -161,24 +161,27 @@ describe('InputFileResolver', () => { it('should not exclude files added using an input file descriptor', () => expect(new InputFileResolver([], ['file2', { pattern: '!file2' }]).resolve()).to.eventually.deep.equal(fileDescriptors(['/file2.js']))); + + it('should not exlude files when the globbing expression results in an empty array', () => + expect(new InputFileResolver([], ['file2', '!does/not/exist']).resolve()).to.eventually.deep.equal(fileDescriptors(['/file2.js']))); }); describe('when provided duplicate files', () => { - it('should deduplicate files that occur more than once', () => + it('should deduplicate files that occur more than once', () => expect(new InputFileResolver([], ['file2', 'file2']).resolve()).to.eventually.deep.equal(fileDescriptors(['/file2.js']))); - - it('should deduplicate files that previously occured in a wildcard expression', () => + + it('should deduplicate files that previously occured in a wildcard expression', () => expect(new InputFileResolver([], ['file*', 'file2']).resolve()).to.eventually.deep.equal(fileDescriptors(['/file1.js', '/file2.js', '/file3.js']))); - - it('should order files by expression order', () => + + it('should order files by expression order', () => expect(new InputFileResolver([], ['file2', 'file*']).resolve()).to.eventually.deep.equal(fileDescriptors(['/file2.js', '/file1.js', '/file3.js']))); }); describe('with url as file pattern', () => { it('should pass through the web urls without globbing', () => { - return new InputFileResolver([], ['http://www', {pattern: 'https://ok'}]) + return new InputFileResolver([], ['http://www', { pattern: 'https://ok' }]) .resolve() .then(() => expect(fileUtils.glob).to.not.have.been.called); }); @@ -188,7 +191,7 @@ describe('InputFileResolver', () => { }); it('should fail when web url is to be mutated', () => { - expect(() => new InputFileResolver([], [ { pattern: 'http://www', mutated: true } ])).throws('Cannot mutate web url "http://www".'); + expect(() => new InputFileResolver([], [{ pattern: 'http://www', mutated: true }])).throws('Cannot mutate web url "http://www".'); }); }); diff --git a/test/unit/reporters/ProgressReporterSpec.ts b/test/unit/reporters/ProgressReporterSpec.ts index 9512567276..bb0e21b618 100644 --- a/test/unit/reporters/ProgressReporterSpec.ts +++ b/test/unit/reporters/ProgressReporterSpec.ts @@ -18,7 +18,6 @@ describe('ProgressReporter', () => { `[:noCoverage :noCoverageLabel] ` + `[:timeout :timeoutLabel] ` + `[:error :errorLabel]`; - let progressBarOptions: any; beforeEach(() => { sut = new ProgressReporter(); diff --git a/testResources/vendor/zone.js/zone.file.js b/testResources/vendor/zone.js/zone.file.js new file mode 100644 index 0000000000..e69de29bb2