Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

npm test fails on fresh checkout #801

Closed
nicksnyder opened this issue Feb 15, 2017 · 6 comments
Closed

npm test fails on fresh checkout #801

nicksnyder opened this issue Feb 15, 2017 · 6 comments
Labels
engineering-debt Tasks for the betterment of the project and not necessarily fixing a bug or adding a feature help wanted

Comments

@nicksnyder
Copy link
Contributor

nicksnyder commented Feb 15, 2017

npm test fails with error

Uncaught Exception:  AssertionError: Package not found by goPkgs: github.com/rogpeppe/godef/vendor/9fans.net/go/acme

How to reproduce

  1. git clone git@github.com:Microsoft/vscode-go.git && cd vscode-go && npm install
  2. npm run compile (then ctrl+c once it is done compiling)
  3. npm run test

Environment

$ node --version
v6.9.5
$ npm --version
3.10.10
$ code --version
1.9.1
f9d0c687ff2ea7aabd85fb9a43129117c0ecf519
$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.12.2 (16C67)
      Kernel Version: Darwin 16.3.0

Full log

$ npm run test
npm ERR! Darwin 16.3.0
npm ERR! argv "/Users/nick/.nvm/versions/node/v6.9.5/bin/node" "/Users/nick/.nvm/versions/node/v6.9.5/bin/npm" "run" "tests"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10

npm ERR! missing script: tests
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /private/tmp/vscode-go/npm-debug.log
nick@nick-mbp:vscode-go $ 
nick@nick-mbp:vscode-go $ npm run test

> Go@0.6.53 test /private/tmp/vscode-go
> node ./node_modules/vscode/bin/test

### VS Code Extension Test Run ###
Current working directory: /private/tmp/vscode-go
Running extension tests: /private/tmp/vscode-go/.vscode-test/Visual Studio Code.app/Contents/MacOS/Electron /private/tmp/vscode-go/out/test --extensionDevelopmentPath=/private/tmp/vscode-go --extensionTestsPath=/private/tmp/vscode-go/out/test




  Go Extension Tests

    ✓ Test Definition Provider using godoc (492ms)

    1) Test Definition Provider using gogetdoc

    ✓ Test SignatureHelp Provider using godoc (254ms)

    2) Test SignatureHelp Provider using gogetdoc

    ✓ Test Hover Provider using godoc (231ms)

    3) Test Hover Provider using gogetdoc

    ✓ Test Completion (782ms)

    ✓ Test Completion on unimported packages (517ms)

    ✓ Error checking (278ms)

    ✓ Test Generate unit tests squeleton for file (240ms)

    ✓ Test Generate unit tests squeleton for a function (275ms)

    ✓ Test Generate unit tests squeleton for package (336ms)

    4) Gometalinter error checking

    ✓ Test diffUtils.getEditsFromUnifiedDiffStr (259ms)

    ✓ Test diffUtils.getEdits (291ms)

    ✓ Test Outline

    ✓ Test Outline imports only

    ✓ Test listPackages (268ms)

Uncaught Exception:  AssertionError: Package not found by goPkgs: github.com/rogpeppe/godef/vendor/9fans.net/go/acme

AssertionError: Package not found by goPkgs: github.com/rogpeppe/godef/vendor/9fans.net/go/acme
    at vendorPkgsFullPath.forEach.pkg (/private/tmp/vscode-go/test/go.test.ts:627:15)
    at Array.forEach (native)
    at cp.execFile (/private/tmp/vscode-go/test/go.test.ts:626:26)
    at ChildProcess.exithandler (child_process.js:209:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

    5) Replace vendor packages with relative path

Uncaught Exception:  AssertionError: Package not found by goPkgs: github.com/rogpeppe/godef/vendor/9fans.net/go/acme

AssertionError: Package not found by goPkgs: github.com/rogpeppe/godef/vendor/9fans.net/go/acme
    at vendorPkgs.forEach.pkg (/private/tmp/vscode-go/test/go.test.ts:687:15)
    at Array.forEach (native)
    at cp.execFile (/private/tmp/vscode-go/test/go.test.ts:686:18)
    at ChildProcess.exithandler (child_process.js:209:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

    6) Vendor pkgs from other projects should not be allowed to import





  14 passing (5s)
  6 failing


  1) Go Extension Tests Test Definition Provider using gogetdoc:
     TypeError: Cannot read property 'uri' of null
      at provider.provideDefinition.then.definitionInfo (test/go.test.ts:59:32)
      at process._tickCallback (internal/process/next_tick.js:103:7)


  2) Go Extension Tests Test SignatureHelp Provider using gogetdoc:
     TypeError: Cannot read property 'signatures' of null
      at provider.provideSignatureHelp.then.sigHelp (test/go.test.ts:75:26)
      at process._tickCallback (internal/process/next_tick.js:103:7)


  3) Go Extension Tests Test Hover Provider using gogetdoc:
     TypeError: Cannot read property 'contents' of null
      at provider.provideHover.then.res (test/go.test.ts:108:79)
      at process._tickCallback (internal/process/next_tick.js:103:7)


  4) Go Extension Tests Gometalinter error checking:

      AssertionError: Failed to match expected error #0: [{"file":"/Users/nick/code/gopath/src/test/testfixture/errorsTest/errors.go","line":11,"msg":"undefined: prin","severity":"error"}]
      + expected - actual

      -11
      +7
      
      at goCheck_1.check.then.diagnostics (test/go.test.ts:434:13)
      at process._tickCallback (internal/process/next_tick.js:103:7)


  5) Go Extension Tests Replace vendor packages with relative path:

      Uncaught AssertionError: Package not found by goPkgs: github.com/rogpeppe/godef/vendor/9fans.net/go/acme
      + expected - actual

      -false
      +true
      
      at vendorPkgsFullPath.forEach.pkg (test/go.test.ts:627:15)
      at Array.forEach (native)
      at cp.execFile (test/go.test.ts:626:26)
      at ChildProcess.exithandler (child_process.js:209:7)
      at maybeClose (internal/child_process.js:877:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)


  6) Go Extension Tests Vendor pkgs from other projects should not be allowed to import:

      Uncaught AssertionError: Package not found by goPkgs: github.com/rogpeppe/godef/vendor/9fans.net/go/acme
      + expected - actual

      -false
      +true
      
      at vendorPkgs.forEach.pkg (test/go.test.ts:687:15)
      at Array.forEach (native)
      at cp.execFile (test/go.test.ts:686:18)
      at ChildProcess.exithandler (child_process.js:209:7)
      at maybeClose (internal/child_process.js:877:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)






Unhandled Rejection at: Promise  {}  reason:  TypeError: Cannot read property 'currentRetry' of undefined
    at /private/tmp/vscode-go/node_modules/mocha/lib/runner.js:531:27
    at done (/private/tmp/vscode-go/node_modules/mocha/lib/runnable.js:287:5)
    at /private/tmp/vscode-go/node_modules/mocha/lib/runnable.js:351:16
    at process._tickCallback (internal/process/next_tick.js:103:7)

Tests exited with code: 1

npm ERR! Darwin 16.3.0
npm ERR! argv "/Users/nick/.nvm/versions/node/v6.9.5/bin/node" "/Users/nick/.nvm/versions/node/v6.9.5/bin/npm" "run" "test"
npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! Go@0.6.53 test: `node ./node_modules/vscode/bin/test`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the Go@0.6.53 test script 'node ./node_modules/vscode/bin/test'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Go package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./node_modules/vscode/bin/test
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs Go
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls Go
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/tmp/vscode-go/npm-debug.log
@ramya-rao-a
Copy link
Contributor

Ah! This was a debt item I knew I had to pay some day ...

There is hack that a few unit tests bank on the fact that the machine already has the Go extension up and has all the dependent tools.

These specific tests are using the godef repo for running tests on vendoring.

The fix is to set up a small Go project with vendoring inside the "test/fixtures" folder, point GOPATH there while running unit tests and update the unit tests to use this Go project instead of godef

I am currently swamped a bit, and wont be able to do this refactoring until sometime next week.
Please feel free to send a PR and I can help out every way I can.

@ramya-rao-a ramya-rao-a added engineering-debt Tasks for the betterment of the project and not necessarily fixing a bug or adding a feature and removed bug labels Aug 26, 2019
@stamblerre
Copy link
Contributor

Is this still a problem? Enough has changed since 2017 with vendoring that I wonder if this issue still exist.

@ramya-rao-a
Copy link
Contributor

This is still a problem for a contributor who wants to run the tests but has not installed godef.

The function mainly being tested here is listPackages() which is used in the Go: Add Import command. We have code in place that ensures that this command

  • shows the relative path for vendor imports
  • does not show vendor imports from other packages

If we add a test fixture that has a 2 packages with vendor imports, then they can be used instead of relying on source code for the godef package

@stamblerre
Copy link
Contributor

Hm, I think the larger problem that needs to be solved is making sure that the user's current environment doesn't affect test execution in general. I see test failures quite often because I have gopls enabled in my environment, and the tests don't expect that. Does golang/vscode-go#43 cover this issue well enough?

@ramya-rao-a
Copy link
Contributor

Yes, golang/vscode-go#43 does kinda covers it.
The difference here is that the fix is much simpler. Because the tool in question i.e godef is not used for testing, it's being re-used since the test needs a project that has vendoring

@stamblerre
Copy link
Contributor

Thanks for clarifying! I edited the description to include a comment specific to this issue, so I think this can be closed for now in favor of golang/vscode-go#43.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
engineering-debt Tasks for the betterment of the project and not necessarily fixing a bug or adding a feature help wanted
Projects
None yet
Development

No branches or pull requests

3 participants