locator
locator copied to clipboard
Tests fail on Windows (Cannot read property 'baseDirectory' of undefined)
Example of stacktrace:
~\locator>npm test
> [email protected] pretest ~\locator
> jshint --config ./node_modules/yui-lint/jshint.json ./lib/ tests/lib/
> [email protected] test ~\locator
> mocha tests/lib/parseBundle.js --reporter spec
BundleLocator.parseBundle()
1) parseBundle()
0 passing (253 ms)
1 failing
1) BundleLocator.parseBundle() parseBundle():
TypeError: Cannot read property 'baseDirectory' of undefined
at n.<anonymous> (~\locator\lib\bundleLocator.js:497:23)
at new n (~\locator\node_modules\yui\promise\promise-min.js:1:2
28)
at Object.BundleLocator._processFileQueue (~\locator\lib\bundle
Locator.js:486:16)
at n.<anonymous> (~\locator\lib\bundleLocator.js:564:29)
at ~\locator\node_modules\yui\promise\promise-min.js:1:1450
at Object._onImmediate (~\locator\node_modules\yui\timers\timer
s-min.js:1:207)
at processImmediate [as _immediateCallback] (timers.js:330:15)
npm ERR! weird error 1
npm ERR! not ok code 0
Issue in the code
Looking at the code, the build fails in bundleLocator.js
on line 346 - 348. If I am reading the code correctly, the assumption is that paths will follow the Unix layout, hence the '/' check.
Inserting another condition, '\\' === findPath.charAt(bundlePath.length)
, will fix the Cannot read property 'baseDirectory' of undefined
error, but the tests will not fully pass where actual is 26 and expected is 31.
~\locator>npm test
> [email protected] pretest ~\locator
> jshint --config ./node_modules/yui-lint/jshint.json ./lib/ tests/lib/
> [email protected] test ~\locator
> mocha tests/lib/parseBundle.js --reporter spec
BundleLocator.parseBundle()
1) parseBundle()
0 passing (295 ms)
1 failing
1) BundleLocator.parseBundle() parseBundle():
actual expected
31 26
npm ERR! weird error 1
npm ERR! not ok code 0
I think _getBundleNameByPath() should use path.sep
here, or something along the lines of this pkg..
good catch! we have a similar situation a while ago in locator, and @drewfish managed to avoid the verification of the root. For locator the root is actually the dirname passed into locator, not need to look outside of that.