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

Add nupm test #19

Merged
merged 38 commits into from
Oct 4, 2023
Merged

Add nupm test #19

merged 38 commits into from
Oct 4, 2023

Conversation

kubouch
Copy link
Contributor

@kubouch kubouch commented Sep 22, 2023

Adds a simple test runner to nupm.

nupm test requires a tests directory module—all exported commands from the module are treated as tests to run. It is possible to filter tests by name. The --show-stdout flag is useful for debugging.

Example tests are added for nupm install. As a consequence, a few bugs in nupm install were discovered and fixed as well.

The three tests included in this PR run ~5.7x faster with nupm test than using std testing run-tests (~127 ms vs. ~735 ms).

Running `nupm` by itself will ask to create NUPM_HOME directory, if it
does not exist. Also ensures $env.NUPM_HOME exists.

The `dirs` module contains utilities and constants related to
directories used in nupm.
This allows for other potential flags, such as --git, and running without
any flags to install from a package repository.
These are not need for installation, just for publishing.
* Changes module package to install the module, not the whole git
  repository.
* Modules are installed under $env.NUPM_HOME/modules and scripts under
  $env.NUPM_HOME/scripts.
* Adds --force flag to force overwrite
* If there is no 'scripts' field in package.nuon in a script package,
  nupm attempts to install <package_name>.nu.
This allows the build script to know information about itself.
Useful if the build script writes or downloads files, for example.
@kubouch kubouch marked this pull request as draft September 22, 2023 20:57
@kubouch kubouch marked this pull request as ready for review October 2, 2023 17:09
Copy link
Member

@amtoine amtoine left a comment

Choose a reason for hiding this comment

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

just a few minor questions and we should be good, love the ouput, the tests and the speed, very nice work 👌 🙏

do not take the Notes into account, i can address them in followup PRs 😉

nupm/install.nu Show resolved Hide resolved
nupm/install.nu Show resolved Hide resolved
nupm/test.nu Show resolved Hide resolved
nupm/test.nu Show resolved Hide resolved
nupm/utils/dirs.nu Show resolved Hide resolved
tests/packages/spam_module/spam_project.nu Outdated Show resolved Hide resolved
@amtoine amtoine mentioned this pull request Oct 3, 2023
Copy link
Member

@amtoine amtoine left a comment

Choose a reason for hiding this comment

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

i love this new command, thanks @kubouch 🙏

@amtoine amtoine merged commit 82f6266 into nushell:main Oct 4, 2023
amtoine added a commit to amtoine/nushell-nupm that referenced this pull request Oct 4, 2023
this should bring all the new `throw-error` calls from nushell#19.
This was referenced Oct 12, 2023
@kubouch kubouch deleted the nupm-test branch November 21, 2023 19:21
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.

2 participants