diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9577eb042..1452a4177 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: name: continuous-integration env: - NUSHELL_CARGO_TARGET: ci + NUSHELL_CARGO_PROFILE: ci NU_LOG_LEVEL: DEBUG CLIPPY_OPTIONS: "-D warnings -D clippy::unwrap_used" diff --git a/crates/nu-std/tests/test_std.nu b/crates/nu-std/tests/test_std.nu index 86836cb9c..fcbc00fa4 100644 --- a/crates/nu-std/tests/test_std.nu +++ b/crates/nu-std/tests/test_std.nu @@ -27,7 +27,13 @@ def path_add [] { assert equal (get_path) ["fooooo", "foo", "bar", "baz"] load-env {$path_name: []} - let target_paths = {linux: "foo", windows: "bar", macos: "baz"} + + let target_paths = { + linux: "foo", + windows: "bar", + macos: "baz", + android: "quux", + } std path add $target_paths assert equal (get_path) [($target_paths | get $nu.os-info.name)] diff --git a/crates/nu-test-support/src/commands.rs b/crates/nu-test-support/src/commands.rs index ae26b970a..dca43c3c1 100644 --- a/crates/nu-test-support/src/commands.rs +++ b/crates/nu-test-support/src/commands.rs @@ -23,7 +23,7 @@ pub fn ensure_plugins_built() { let cargo_path = env!("CARGO"); let mut arguments = vec!["build", "--package", "nu_plugin_*", "--quiet"]; - let profile = std::env::var("NUSHELL_CARGO_TARGET"); + let profile = std::env::var("NUSHELL_CARGO_PROFILE"); if let Ok(profile) = &profile { arguments.push("--profile"); arguments.push(profile); diff --git a/crates/nu-test-support/src/fs.rs b/crates/nu-test-support/src/fs.rs index af000bbf4..bd2338631 100644 --- a/crates/nu-test-support/src/fs.rs +++ b/crates/nu-test-support/src/fs.rs @@ -233,18 +233,21 @@ pub fn root() -> PathBuf { } pub fn binaries() -> PathBuf { - let mut build_type = "debug".to_string(); - if !cfg!(debug_assertions) { - build_type = "release".to_string() - } - if let Ok(target) = std::env::var("NUSHELL_CARGO_TARGET") { - build_type = target; - } + let build_target = std::env::var("CARGO_BUILD_TARGET").unwrap_or(String::new()); + + let profile = if let Ok(env_profile) = std::env::var("NUSHELL_CARGO_PROFILE") { + env_profile + } else if cfg!(debug_assertions) { + "debug".into() + } else { + "release".into() + }; std::env::var("CARGO_TARGET_DIR") - .ok() - .map(|target_dir| PathBuf::from(target_dir).join(&build_type)) - .unwrap_or_else(|| root().join(format!("target/{}", &build_type))) + .map(PathBuf::from) + .unwrap_or_else(|_| root().join("target")) + .join(build_target) + .join(profile) } pub fn fixtures() -> PathBuf { diff --git a/scripts/coverage-local.nu b/scripts/coverage-local.nu index eecd16d65..4c1aeb68e 100755 --- a/scripts/coverage-local.nu +++ b/scripts/coverage-local.nu @@ -45,7 +45,7 @@ let start = (date now) # 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_TARGET = "ci" +$env.NUSHELL_CARGO_PROFILE = "ci" # Manual gathering of coverage to catch invocation of the `nu` binary. # This is relevant for tests using the `nu!` macro from `nu-test-support` diff --git a/scripts/coverage-local.sh b/scripts/coverage-local.sh index fd05e1055..2bae08dd6 100755 --- a/scripts/coverage-local.sh +++ b/scripts/coverage-local.sh @@ -17,7 +17,7 @@ REPO_ROOT=$(dirname $DIR) # 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` -export NUSHELL_CARGO_TARGET=ci +export NUSHELL_CARGO_PROFILE=ci # Manual gathering of coverage to catch invocation of the `nu` binary. # This is relevant for tests using the `nu!` macro from `nu-test-support` diff --git a/toolkit.nu b/toolkit.nu index 6e843a91f..59d0daa95 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -436,7 +436,7 @@ def compute-coverage [] { # - https://github.com/andythigpen/nvim-coverage (probably needs some additional config) export def cov [] { let start = (date now) - $env.NUSHELL_CARGO_TARGET = "ci" + $env.NUSHELL_CARGO_PROFILE = "ci" compute-coverage