Skip to content

Testing the install script #552

@xcambar

Description

@xcambar

I was thinking about @ljharb's comment about the install script being untested, and had a look at how we could test it.

The testing tools that seem of interest to me are Roundup, shunt and the classic shunit2. Feedback about this list is more than welcome, I don't have much experience in unit-testing shell scripts.

The strategy is currently as follows:

  • rewrite the script so we have smaller and more dedicated functions
  • those smaller functions would be tested against their return code
  • external tools would be mocked using aliases, for example
curl_mock_success() {
  exit 0
}
curl_mock_failure() {
  exit 1
}

alias curl=curl_mock_success #or curl_mock_failure, depending on the test
  • setUp and tearDown would create/reset mocks as needed (if tests are not sandboxed)
  • function calls would be tested as external tools, with mocking. This is helpful to test the flow.

This is certainly not perfect and there is probably more to do than the described above, but I'm willing to give it a try and wanted to have your opinion on this firsthand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    installing nodeIssues with installing node/io.js versions.pull request wantedThis is a great way to contribute! Help us out :-DtestingStuff related to testing nvm itself.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions