nushell/scripts/coverage-local.nu

64 lines
2.5 KiB
Plaintext
Raw Normal View History

REFACTOR: clean the root of the repo (#9231) # Description i've almost always wanted to clean up the root of the repo, so here is my take at it, with some important advice given by @fdncred :relieved: - `README.release.txt` is now gone and directly inline in the `release-pkg` script used in the `release` *workflow* - `build.rs` has been moved to `scripts/` and its path has been changed in [`Cargo.toml`](https://github.com/amtoine/nushell/blob/refactor/clean-root/Cargo.toml#L3) according to the [*Build Scripts* section](https://doc.rust-lang.org/cargo/reference/build-scripts.html#build-scripts) of *The Cargo Book* - i've merged `images/` into `assets/` and fix the only mention to the GIF in the README - i've moved the `docs/README.md` inside the main `README.md` as a new [*Configuration* section](https://github.com/amtoine/nushell/tree/refactor/clean-root#configuration) - the very deprecated `pkg_mgrs/` has been removed - all the `.nu`, `.sh`, `.ps1` and `.cmd` scripts have been moved to `scripts/` ### things i've left as-is - all the other `.md` documents - the configuration files - all the Rust and core stuff - `docker/` - `toolkit.nu` - the `wix/` diretory which appears to be important for `winget` # User-Facing Changes scripts that used to rely on the paths to some of the scripts should now call the scripts inside `scripts/` => i think this for the greater good, it was not pretty nor scalable to have a bunch of scripts in the root of our main `nushell` :scream: *i even think we might want to move these scripts outside the main `nushell` repo* maybe to `nu_scripts` or some other tool :+1: # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :black_circle: `toolkit test` - :black_circle: `toolkit test stdlib` # After Submitting ``` $nothing ```
2023-05-20 14:57:51 +02:00
#!/usr/bin/env nu
use std log warning
warning "./scripts/coverage-local.nu will be deprecated, please use the `toolkit cov` command instead"
REFACTOR: clean the root of the repo (#9231) # Description i've almost always wanted to clean up the root of the repo, so here is my take at it, with some important advice given by @fdncred :relieved: - `README.release.txt` is now gone and directly inline in the `release-pkg` script used in the `release` *workflow* - `build.rs` has been moved to `scripts/` and its path has been changed in [`Cargo.toml`](https://github.com/amtoine/nushell/blob/refactor/clean-root/Cargo.toml#L3) according to the [*Build Scripts* section](https://doc.rust-lang.org/cargo/reference/build-scripts.html#build-scripts) of *The Cargo Book* - i've merged `images/` into `assets/` and fix the only mention to the GIF in the README - i've moved the `docs/README.md` inside the main `README.md` as a new [*Configuration* section](https://github.com/amtoine/nushell/tree/refactor/clean-root#configuration) - the very deprecated `pkg_mgrs/` has been removed - all the `.nu`, `.sh`, `.ps1` and `.cmd` scripts have been moved to `scripts/` ### things i've left as-is - all the other `.md` documents - the configuration files - all the Rust and core stuff - `docker/` - `toolkit.nu` - the `wix/` diretory which appears to be important for `winget` # User-Facing Changes scripts that used to rely on the paths to some of the scripts should now call the scripts inside `scripts/` => i think this for the greater good, it was not pretty nor scalable to have a bunch of scripts in the root of our main `nushell` :scream: *i even think we might want to move these scripts outside the main `nushell` repo* maybe to `nu_scripts` or some other tool :+1: # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :black_circle: `toolkit test` - :black_circle: `toolkit test stdlib` # After Submitting ``` $nothing ```
2023-05-20 14:57:51 +02:00
def compute-coverage [] {
2023-10-19 22:07:01 +02:00
cd ($env.CURRENT_FILE | path dirname --num-levels 2)
REFACTOR: clean the root of the repo (#9231) # Description i've almost always wanted to clean up the root of the repo, so here is my take at it, with some important advice given by @fdncred :relieved: - `README.release.txt` is now gone and directly inline in the `release-pkg` script used in the `release` *workflow* - `build.rs` has been moved to `scripts/` and its path has been changed in [`Cargo.toml`](https://github.com/amtoine/nushell/blob/refactor/clean-root/Cargo.toml#L3) according to the [*Build Scripts* section](https://doc.rust-lang.org/cargo/reference/build-scripts.html#build-scripts) of *The Cargo Book* - i've merged `images/` into `assets/` and fix the only mention to the GIF in the README - i've moved the `docs/README.md` inside the main `README.md` as a new [*Configuration* section](https://github.com/amtoine/nushell/tree/refactor/clean-root#configuration) - the very deprecated `pkg_mgrs/` has been removed - all the `.nu`, `.sh`, `.ps1` and `.cmd` scripts have been moved to `scripts/` ### things i've left as-is - all the other `.md` documents - the configuration files - all the Rust and core stuff - `docker/` - `toolkit.nu` - the `wix/` diretory which appears to be important for `winget` # User-Facing Changes scripts that used to rely on the paths to some of the scripts should now call the scripts inside `scripts/` => i think this for the greater good, it was not pretty nor scalable to have a bunch of scripts in the root of our main `nushell` :scream: *i even think we might want to move these scripts outside the main `nushell` repo* maybe to `nu_scripts` or some other tool :+1: # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :black_circle: `toolkit test` - :black_circle: `toolkit test stdlib` # After Submitting ``` $nothing ```
2023-05-20 14:57:51 +02:00
print "Setting up environment variables for coverage"
# Enable LLVM coverage tracking through environment variables
# show env outputs .ini/.toml style description of the variables
# In order to use from toml, we need to make sure our string literals are single quoted
# This is especially important when running on Windows since "C:\blah" is treated as an escape
cargo llvm-cov show-env | str replace (char dq) (char sq) -a | from toml | load-env
print "Cleaning up coverage data"
cargo llvm-cov clean --workspace
print "Building with workspace and profile=ci"
# Apparently we need to explicitly build the necessary parts
# using the `--profile=ci` is basically `debug` build with unnecessary symbols stripped
# leads to smaller binaries and potential savings when compiling and running
cargo build --workspace --profile=ci
print "Running tests with --workspace and profile=ci"
cargo test --workspace --profile=ci
# You need to provide the used profile to find the raw data
print "Generating coverage report as lcov.info"
cargo llvm-cov report --lcov --output-path lcov.info --profile=ci
}
let start = (date now)
# Script to generate coverage locally
#
# Output: `lcov.info` file
#
# Relies on `cargo-llvm-cov`. Install via `cargo install cargo-llvm-cov`
# https://github.com/taiki-e/cargo-llvm-cov
# You probably have to run `cargo llvm-cov clean` once manually,
# as you have to confirm to install additional tooling for your rustup toolchain.
# Else the script might stall waiting for your `y<ENTER>`
# Some of the internal tests rely on the exact cargo profile
# (This is somewhat criminal itself)
# but we have to signal to the tests that we use the `ci` `--profile`
$env.NUSHELL_CARGO_PROFILE = "ci"
REFACTOR: clean the root of the repo (#9231) # Description i've almost always wanted to clean up the root of the repo, so here is my take at it, with some important advice given by @fdncred :relieved: - `README.release.txt` is now gone and directly inline in the `release-pkg` script used in the `release` *workflow* - `build.rs` has been moved to `scripts/` and its path has been changed in [`Cargo.toml`](https://github.com/amtoine/nushell/blob/refactor/clean-root/Cargo.toml#L3) according to the [*Build Scripts* section](https://doc.rust-lang.org/cargo/reference/build-scripts.html#build-scripts) of *The Cargo Book* - i've merged `images/` into `assets/` and fix the only mention to the GIF in the README - i've moved the `docs/README.md` inside the main `README.md` as a new [*Configuration* section](https://github.com/amtoine/nushell/tree/refactor/clean-root#configuration) - the very deprecated `pkg_mgrs/` has been removed - all the `.nu`, `.sh`, `.ps1` and `.cmd` scripts have been moved to `scripts/` ### things i've left as-is - all the other `.md` documents - the configuration files - all the Rust and core stuff - `docker/` - `toolkit.nu` - the `wix/` diretory which appears to be important for `winget` # User-Facing Changes scripts that used to rely on the paths to some of the scripts should now call the scripts inside `scripts/` => i think this for the greater good, it was not pretty nor scalable to have a bunch of scripts in the root of our main `nushell` :scream: *i even think we might want to move these scripts outside the main `nushell` repo* maybe to `nu_scripts` or some other tool :+1: # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :black_circle: `toolkit test` - :black_circle: `toolkit test stdlib` # After Submitting ``` $nothing ```
2023-05-20 14:57:51 +02:00
# Manual gathering of coverage to catch invocation of the `nu` binary.
# This is relevant for tests using the `nu!` macro from `nu-test-support`
# see: https://github.com/taiki-e/cargo-llvm-cov#get-coverage-of-external-tests
compute-coverage
let end = (date now)
print $"Coverage generation took ($end - $start)."
# To display the coverage in your editor see:
#
# - https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
# - https://github.com/umaumax/vim-lcov
# - https://github.com/andythigpen/nvim-coverage (probably needs some additional config)