-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Windows: Found 0 matching tests #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3485d7b
42effc7
c78ddb9
726a0eb
2da47ad
f3c2680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,58 @@ | |
|
|
||
| jest.autoMockOff(); | ||
|
|
||
| describe('utils-pathNormalize', function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you throw this suite into a separate file (say, |
||
| var utils; | ||
|
|
||
| beforeEach(function() { | ||
| utils = require('../utils'); | ||
| }); | ||
|
|
||
| it('supports ../ paths and unix separators', function() { | ||
| var path = '/path/to/__tests__/foo/bar/baz/../../../test.js'; | ||
| var pathNormalized = utils.pathNormalize(path); | ||
|
|
||
| return expect(pathNormalized).toEqual('/path/to/__tests__/test.js'); | ||
| }); | ||
|
|
||
| it('supports ../ paths and windows separators', function() { | ||
| var path = 'c:\\path\\to\\__tests__\\foo\\bar\\baz\\..\\..\\..\\test.js'; | ||
| var pathNormalized = utils.pathNormalize(path); | ||
|
|
||
| return expect(pathNormalized).toEqual('c:/path/to/__tests__/test.js'); | ||
| }); | ||
|
|
||
| it('supports unix separators', function() { | ||
| var path = '/path/to/__tests__/test.js'; | ||
| var pathNormalized = utils.pathNormalize(path); | ||
|
|
||
| return expect(pathNormalized).toEqual(path); | ||
| }); | ||
|
|
||
| it('supports windows separators', function() { | ||
| var path = 'c:\\path\\to\\__tests__\\test.js'; | ||
| var pathNormalized = utils.pathNormalize(path); | ||
|
|
||
| return expect(pathNormalized).toEqual('c:/path/to/__tests__/test.js'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('utils-normalizeConfig', function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind rebasing + re-running your tests again just for sanity? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now i have only: without any info about tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I think there is race condition somewhere: |
||
| var path; | ||
| var root; | ||
| var utils; | ||
| var expectedPathFooBar; | ||
| var expectedPathFooQux; | ||
| var expectedPathAbs; | ||
| var expectedPathAbsAnother; | ||
|
|
||
| beforeEach(function() { | ||
| path = require('path'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Man, it's too bad the If it did, we might've been able to just stub out Anyway, I digressed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO there should be |
||
| root = path.resolve('/').replace(/[\\\/]/g, ''); | ||
| expectedPathFooBar = root + '/root/path/foo/bar/baz'; | ||
| expectedPathFooQux = root + '/root/path/foo/qux/quux'; | ||
| expectedPathAbs = root + '/an/abs/path'; | ||
| expectedPathAbsAnother = root + '/another/abs/path'; | ||
| utils = require('../utils'); | ||
| }); | ||
|
|
||
|
|
@@ -43,10 +91,11 @@ describe('utils-normalizeConfig', function() { | |
| } | ||
| }, '/root/path'); | ||
|
|
||
| expect(config.collectCoverageOnlyFrom).toEqual({ | ||
| '/root/path/foo/bar/baz': true, | ||
| '/root/path/foo/qux/quux': true | ||
| }); | ||
| var expected = {}; | ||
| expected[expectedPathFooBar] = true; | ||
| expected[expectedPathFooQux] = true; | ||
|
|
||
| expect(config.collectCoverageOnlyFrom).toEqual(expected); | ||
| }); | ||
|
|
||
| it('does not change absolute paths', function() { | ||
|
|
@@ -58,10 +107,11 @@ describe('utils-normalizeConfig', function() { | |
| } | ||
| }); | ||
|
|
||
| expect(config.collectCoverageOnlyFrom).toEqual({ | ||
| '/an/abs/path': true, | ||
| '/another/abs/path': true | ||
| }); | ||
| var expected = {}; | ||
| expected[expectedPathAbs] = true; | ||
| expected[expectedPathAbsAnother] = true; | ||
|
|
||
| expect(config.collectCoverageOnlyFrom).toEqual(expected); | ||
| }); | ||
|
|
||
| it('substitutes <rootDir> tokens', function() { | ||
|
|
@@ -72,9 +122,10 @@ describe('utils-normalizeConfig', function() { | |
| } | ||
| }); | ||
|
|
||
| expect(config.collectCoverageOnlyFrom).toEqual({ | ||
| '/root/path/foo/bar/baz': true | ||
| }); | ||
| var expected = {}; | ||
| expected[expectedPathFooBar] = true; | ||
|
|
||
| expect(config.collectCoverageOnlyFrom).toEqual(expected); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -89,8 +140,7 @@ describe('utils-normalizeConfig', function() { | |
| }, '/root/path'); | ||
|
|
||
| expect(config.testPathDirs).toEqual([ | ||
| '/root/path/foo/bar/baz', | ||
| '/root/path/foo/qux/quux' | ||
| expectedPathFooBar, expectedPathFooQux | ||
| ]); | ||
| }); | ||
|
|
||
|
|
@@ -104,8 +154,7 @@ describe('utils-normalizeConfig', function() { | |
| }); | ||
|
|
||
| expect(config.testPathDirs).toEqual([ | ||
| '/an/abs/path', | ||
| '/another/abs/path' | ||
| expectedPathAbs, expectedPathAbsAnother | ||
| ]); | ||
| }); | ||
|
|
||
|
|
@@ -117,7 +166,7 @@ describe('utils-normalizeConfig', function() { | |
| ] | ||
| }); | ||
|
|
||
| expect(config.testPathDirs).toEqual(['/root/path/foo/bar/baz']); | ||
| expect(config.testPathDirs).toEqual([expectedPathFooBar]); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -128,7 +177,7 @@ describe('utils-normalizeConfig', function() { | |
| scriptPreprocessor: 'bar/baz' | ||
| }, '/root/path'); | ||
|
|
||
| expect(config.scriptPreprocessor).toEqual('/root/path/foo/bar/baz'); | ||
| expect(config.scriptPreprocessor).toEqual(expectedPathFooBar); | ||
| }); | ||
|
|
||
| it('does not change absolute paths', function() { | ||
|
|
@@ -137,7 +186,7 @@ describe('utils-normalizeConfig', function() { | |
| scriptPreprocessor: '/an/abs/path' | ||
| }); | ||
|
|
||
| expect(config.scriptPreprocessor).toEqual('/an/abs/path'); | ||
| expect(config.scriptPreprocessor).toEqual(expectedPathAbs); | ||
| }); | ||
|
|
||
| it('substitutes <rootDir> tokens', function() { | ||
|
|
@@ -146,7 +195,7 @@ describe('utils-normalizeConfig', function() { | |
| scriptPreprocessor: '<rootDir>/bar/baz' | ||
| }); | ||
|
|
||
| expect(config.scriptPreprocessor).toEqual('/root/path/foo/bar/baz'); | ||
| expect(config.scriptPreprocessor).toEqual(expectedPathFooBar); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -157,7 +206,7 @@ describe('utils-normalizeConfig', function() { | |
| setupEnvScriptFile: 'bar/baz' | ||
| }, '/root/path'); | ||
|
|
||
| expect(config.setupEnvScriptFile).toEqual('/root/path/foo/bar/baz'); | ||
| expect(config.setupEnvScriptFile).toEqual(expectedPathFooBar); | ||
| }); | ||
|
|
||
| it('does not change absolute paths', function() { | ||
|
|
@@ -166,7 +215,7 @@ describe('utils-normalizeConfig', function() { | |
| setupEnvScriptFile: '/an/abs/path' | ||
| }); | ||
|
|
||
| expect(config.setupEnvScriptFile).toEqual('/an/abs/path'); | ||
| expect(config.setupEnvScriptFile).toEqual(expectedPathAbs); | ||
| }); | ||
|
|
||
| it('substitutes <rootDir> tokens', function() { | ||
|
|
@@ -175,7 +224,7 @@ describe('utils-normalizeConfig', function() { | |
| setupEnvScriptFile: '<rootDir>/bar/baz' | ||
| }); | ||
|
|
||
| expect(config.setupEnvScriptFile).toEqual('/root/path/foo/bar/baz'); | ||
| expect(config.setupEnvScriptFile).toEqual(expectedPathFooBar); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -186,9 +235,7 @@ describe('utils-normalizeConfig', function() { | |
| setupTestFrameworkScriptFile: 'bar/baz' | ||
| }, '/root/path'); | ||
|
|
||
| expect(config.setupTestFrameworkScriptFile).toEqual( | ||
| '/root/path/foo/bar/baz' | ||
| ); | ||
| expect(config.setupTestFrameworkScriptFile).toEqual(expectedPathFooBar); | ||
| }); | ||
|
|
||
| it('does not change absolute paths', function() { | ||
|
|
@@ -197,7 +244,7 @@ describe('utils-normalizeConfig', function() { | |
| setupTestFrameworkScriptFile: '/an/abs/path' | ||
| }); | ||
|
|
||
| expect(config.setupTestFrameworkScriptFile).toEqual('/an/abs/path'); | ||
| expect(config.setupTestFrameworkScriptFile).toEqual(expectedPathAbs); | ||
| }); | ||
|
|
||
| it('substitutes <rootDir> tokens', function() { | ||
|
|
@@ -206,9 +253,7 @@ describe('utils-normalizeConfig', function() { | |
| setupTestFrameworkScriptFile: '<rootDir>/bar/baz' | ||
| }); | ||
|
|
||
| expect(config.setupTestFrameworkScriptFile).toEqual( | ||
| '/root/path/foo/bar/baz' | ||
| ); | ||
| expect(config.setupTestFrameworkScriptFile).toEqual(expectedPathFooBar); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,10 +53,10 @@ function _replaceRootDirTags(rootDir, config) { | |
| return config; | ||
| } | ||
|
|
||
| return path.resolve( | ||
| return pathNormalize(path.resolve( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, not all config strings are paths (and thus we shouldn't necessarily normalize them as if they were). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree but there is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah you're right -- this whole function should only be called on path strings anyway. |
||
| rootDir, | ||
| './' + path.normalize(config.substr('<rootDir>'.length)) | ||
| ); | ||
| )); | ||
| } | ||
| return config; | ||
| } | ||
|
|
@@ -152,38 +152,40 @@ function normalizeConfig(config) { | |
| throw new Error('No rootDir config value found!'); | ||
| } | ||
|
|
||
| config.rootDir = pathNormalize(config.rootDir); | ||
|
|
||
| // Normalize user-supplied config options | ||
| Object.keys(config).reduce(function(newConfig, key) { | ||
| var value; | ||
| switch (key) { | ||
| case 'collectCoverageOnlyFrom': | ||
| value = Object.keys(config[key]).reduce(function(normObj, filePath) { | ||
| filePath = path.resolve( | ||
| filePath = pathNormalize(path.resolve( | ||
| config.rootDir, | ||
| _replaceRootDirTags(config.rootDir, filePath) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we only need to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No because path.resolve also returns not normalized path. gives |
||
| ); | ||
| )); | ||
| normObj[filePath] = true; | ||
| return normObj; | ||
| }, {}); | ||
| break; | ||
|
|
||
| case 'testPathDirs': | ||
| value = config[key].map(function(scanDir) { | ||
| return path.resolve( | ||
| return pathNormalize(path.resolve( | ||
| config.rootDir, | ||
| _replaceRootDirTags(config.rootDir, scanDir) | ||
| ); | ||
| )); | ||
| }); | ||
| break; | ||
|
|
||
| case 'cacheDirectory': | ||
| case 'scriptPreprocessor': | ||
| case 'setupEnvScriptFile': | ||
| case 'setupTestFrameworkScriptFile': | ||
| value = path.resolve( | ||
| value = pathNormalize(path.resolve( | ||
| config.rootDir, | ||
| _replaceRootDirTags(config.rootDir, config[key]) | ||
| ); | ||
| )); | ||
| break; | ||
|
|
||
| case 'testPathIgnorePatterns': | ||
|
|
@@ -231,6 +233,10 @@ function normalizeConfig(config) { | |
| return _replaceRootDirTags(newConfig.rootDir, newConfig); | ||
| } | ||
|
|
||
| function pathNormalize(dir) { | ||
| return path.normalize(dir.replace(/\\/g, '/')).replace(/\\/g, '/'); | ||
| } | ||
|
|
||
| function loadConfigFromFile(filePath) { | ||
| var fileDir = path.dirname(filePath); | ||
| return Q.nfcall(fs.readFile, filePath, 'utf8').then(function(fileData) { | ||
|
|
@@ -422,6 +428,7 @@ exports.getLinePercentCoverageFromCoverageInfo = | |
| exports.loadConfigFromFile = loadConfigFromFile; | ||
| exports.loadConfigFromPackageJson = loadConfigFromPackageJson; | ||
| exports.normalizeConfig = normalizeConfig; | ||
| exports.pathNormalize = pathNormalize; | ||
| exports.readAndPreprocessFileContent = readAndPreprocessFileContent; | ||
| exports.runContentWithLocalBindings = runContentWithLocalBindings; | ||
| exports.serializeConsoleArgValue = serializeConsoleArgValue; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the same - because here: https://github.com/kl3ryk/jest/blob/master/src/TestRunner.js#L232 FileFinder returns not normalized paths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, you're right. In that case, maybe we should just normalize in the
_onMatcherMatch()function before calling theonTestFoundcallback then.That puts this normalization closer to the source for anyone else who ever winds up using
TestRunner.findTestPathsMatching