Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Tests fail on Windows (Cannot read property 'baseDirectory' of undefined) #10

Open
bretkikehara opened this issue Jul 16, 2013 · 2 comments

Comments

@bretkikehara
Copy link

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
@isao
Copy link
Contributor

isao commented Jul 17, 2013

I think _getBundleNameByPath() should use path.sep here, or something along the lines of this pkg..

@caridy
Copy link
Contributor

caridy commented Jul 17, 2013

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants