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

Code Suggestion: add testing framework and tests #545

Closed
shadowspawn opened this issue Dec 22, 2018 · 5 comments
Closed

Code Suggestion: add testing framework and tests #545

shadowspawn opened this issue Dec 22, 2018 · 5 comments

Comments

@shadowspawn
Copy link
Collaborator

Problem

n does not have any tests for contributors to run after making changes, to add to when making changes, or to prevent regressions. I would like the reassurance that the tests still pass when making a Pull Request, or similarly when reviewing a Pull Request. (End users would hopefully benefit from the increased checks with more robust releases, but would not run the tests themselves.)

The Pull Request template asks a good question and I don't think there is currently a good answer:

How to verify it doesn't effect the functionality of n

Possible Solutions

I looked around and found bats-core, which is quite widely used. I liked the strong focus on bash, and test and output formats

Using a caching proxy is an optional optimisation for the multiple web requests. On Mac, I have used mitmproxy

Using docker allows running commands or test suite on multiple flavours of operating system, all self-hosted.

Feedback

I am interested in any comments (including of course from maintainers!).

I develop primarily on a Mac, and use Linux flavours in VMs and containers as needed but not as my desktop, so found technology that works well for my situation. I know @troy0820 uses docker, and might be on a Mac too. There may be other frameworks or approaches that would work better for n contributors with other environments?

A framework for providing and running tests is separate from writing the tests themselves. Any comments on good tests also welcome.

I am aware I don't need to get this into n to use, as I can make a stand-alone repo for hosting the tests. I have used bats-core and mitmproxy and docker together to write tests for nvh so know I can get something functional.

History

Having some tests gets mentioned as desirable in #246. A roll-your-own framework and a single test was included with PR #364.

@troy0820
Copy link
Collaborator

Definitely, agree. I want to automate a lot of the testing because what ends up happening is that I make a bunch of containers with Docker to test the functionality of it. If we can get something started, I'm happy with the suggestions here.

@shadowspawn
Copy link
Collaborator Author

shadowspawn commented Dec 29, 2018

Started work in: https://github.com/shadowspawn/n-test

@shadowspawn
Copy link
Collaborator Author

shadowspawn commented Feb 10, 2019

An update. I spent some time on this at start of year, and have a functional setup and initial suite of tests in https://github.com/shadowspawn/n-test. Can open a PR when wanted.

I have ideas for improvements and additions but a low priority at the moment and I am not planning to change approach significantly (despite #554 #555). Easy to add travis support if desired.

Infrastructure:

  • tests can be run on native OS, independent of developers own installs and configuration
  • tests can be run in docker container for Ubuntu with curl only, and Ubuntu with wget only
  • run-all-tests script runs the full suite of tests on Ubuntu with curl, and Ubuntu with wget, and native
  • optional proxy (currently Mac-only) to speed up running full suite or rerunning tests

The current tests are focused on installs. (With some redundancy as more tests got added.)

  • "n lts" installs expected version of node, looked up separately
  • "n latest" installs expected version of node, looked up separately
  • "n --lts" outputs expected version, looked up separately
  • "n --latest" outputs expected version, looked up separately
  • "n 4.9.1" installs node v4.9.1
  • "n v4.9.1" installs node v4.9.1
  • "n 4" installs node v4.9.1
  • "n v4" install node v4.9.1
  • "n 4.9" installs node v4.9.1
  • "n --download 4.9.1" downloads but does not install 4.9.1
  • "n --quiet 4.9.1" installs node v4.9.1
  • "n 4.9.1" installs node v4.9.1 and npm and folder to bin and lib and include and share, and not the tarball README (i.e. inspired by Typo in bash code #246)

@shadowspawn
Copy link
Collaborator Author

Added to develop branch for next release.

@shadowspawn
Copy link
Collaborator Author

Included in v4.0.0

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

No branches or pull requests

2 participants