Skip to content
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

test: run cli tests in top level npm test #825

Merged
merged 2 commits into from
Jan 3, 2018
Merged

test: run cli tests in top level npm test #825

merged 2 commits into from
Jan 3, 2018

Conversation

virkt25
Copy link
Contributor

@virkt25 virkt25 commented Jan 2, 2018

Description

CLI Tests aren't run as part of top level npm test. Test count before change was 609. After this change it is 694.

Related issues

  • connect to <link_to_referenced_issue>

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide

@bajtos
Copy link
Member

bajtos commented Jan 2, 2018

I am fine with this change as a short-term fix, but wouldn't it better to fix the layout of CLI test folder to follow the convention we have everywhere else, namely "unit", "integration" and "acceptance" folders?

Copy link
Contributor

@kjdelisle kjdelisle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the CLI tests aren't following our monorepo layout, that tells me something fishy is going on...

@@ -39,7 +39,7 @@
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current",
"test": "node packages/build/bin/run-nyc npm run mocha",
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\"",
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\" \"packages/cli/test\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there no dist folder for the CLI tests? It should follow the existing pattern in the current command (packages/cli/dist/test/**/*.js)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjdelisle I think the CLI cannot use TypeScript because it's a Yeoman generator under the hood, which has implications on the project layout. One more reason for getting rid of Yeoman! See #844

@virkt25
Copy link
Contributor Author

virkt25 commented Jan 2, 2018

CLI is written in JS not TS! So there's no build for it, which means there is no dist folder for it.

@raymondfeng
Copy link
Contributor

@virkt25 Please check why CI fails.

package.json Outdated
@@ -37,7 +37,8 @@
"clean": "lerna run --loglevel=silent clean",
"build": "lerna run --loglevel=silent build",
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current",
"pretest": "npm run build:current && npm run cli:link",
"cli:link": "cd packages/cli && npm link",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this?

Copy link
Contributor

@kjdelisle kjdelisle Jan 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the cli:link command, but not having it added to pretest. This means that any time someone runs tests, they're going to lose their existing global installation of the CLI and have it replaced with the locally-linked one. I expect this would cause havoc for contributors down the line.

Copy link
Contributor

@kjdelisle kjdelisle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the alteration to pretest, IMO.

package.json Outdated
@@ -37,7 +37,8 @@
"clean": "lerna run --loglevel=silent clean",
"build": "lerna run --loglevel=silent build",
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current",
"pretest": "npm run build:current && npm run cli:link",
"cli:link": "cd packages/cli && npm link",
Copy link
Contributor

@kjdelisle kjdelisle Jan 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the cli:link command, but not having it added to pretest. This means that any time someone runs tests, they're going to lose their existing global installation of the CLI and have it replaced with the locally-linked one. I expect this would cause havoc for contributors down the line.

@virkt25
Copy link
Contributor Author

virkt25 commented Jan 2, 2018

I'm testing this right now to see if this fixes the issue with tests failing on Windows based on http://yeoman.io/authoring/

I'll ping the team if it works and is ready for review.

@virkt25 virkt25 changed the title test: run cli tests in top level npm test [WIP] test: run cli tests in top level npm test Jan 2, 2018
package.json Outdated
@@ -38,7 +38,7 @@
"build": "lerna run --loglevel=silent build",
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current && npm run cli:link",
"cli:link": "cd packages/cli/generators && npm link && cd ../../..",
"cli:link": "cd packages/cli/generators/app && npm link && cd ../controller && npm link && ../extension && npm link && ../project && npm link && cd ../../..",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is completely wrong. Can you explain?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note we don't depend on global installation of generators as @loopback/cli does not use yo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I'll have to see if I can get my hands on a windows machine as I see a lot of tests failing on AppVeyor with the following message:

Error: You don't seem to have a generator with the name “loopback4:C:\projects\loopback-next\packages\cli\generators\app” installed.
But help is on the way:
You can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/. 
Install them with npm install generator-loopback4:C:\projects\loopback-next\packages\cli\generators\app.
To see all your installed generators run yo without any arguments. Adding the --help option will also show subgenerators. 
If yo cannot find the generator, run yo doctor to troubleshoot your system.
      at Environment.create (packages\cli\node_modules\yeoman-environment\lib\environment.js:368:9)
      at Object.exports.testSetUpGen (packages\cli\test\test-utils.js:15:14)
      at Context.it (packages\cli\test\base-generator.js:15:29)

@raymondfeng
Copy link
Contributor

I think I know what causes the Windows build issue now. There are a few places that we use / as a separator to split paths.

We need to use path.sep as the separator so that it works on all platforms.

@virkt25 virkt25 changed the title [WIP] test: run cli tests in top level npm test test: run cli tests in top level npm test Jan 2, 2018
@virkt25 virkt25 merged commit 6474763 into master Jan 3, 2018
@virkt25 virkt25 deleted the cli-tests branch January 3, 2018 00:16
virkt25 added a commit that referenced this pull request Jan 3, 2018
* test: run cli tests in top level npm test

* fix(cli): use path.sep to be platform agnostic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants