Files
Piepmatz b9d514df7b Replace old Playground usages with the new one (#18915)
## Description

This PR replaces all the `Playground::setup` calls with the new injected
`Playground`.

Most of the changes are done via [this
script](https://tangled.org/cptpiepmatz.de/nushell_playground_asr) which
uses the rust-analyzer internals to replace code via the AST.

All the test should behave exactly the same as before but they don't
need to manually set up a playground anymore. Also this removes quite a
lot of lines, which is nice.

## User-facing changes (Release notes)

n/a

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-11-19 14:29:12 +01:00

39 lines
971 B
Rust

use nu_test_support::prelude::*;
#[test]
#[deps(NU_PLUGIN_EXAMPLE)]
fn get_env_by_name() -> Result {
let mut tester = test();
let () = tester.run("$env.FOO = 'bar'")?;
tester.run("example env FOO").expect_value_eq("bar")?;
let () = tester.run("$env.FOO = 'baz'")?;
tester.run("example env FOO").expect_value_eq("baz")?;
Ok(())
}
#[test]
#[deps(NU_PLUGIN_EXAMPLE)]
fn get_envs() -> Result {
test()
.run("$env.BAZ = 'foo'; example env | get BAZ")
.expect_value_eq("foo")
}
#[test]
#[deps(NU_PLUGIN_EXAMPLE)]
fn get_current_dir(playground: Playground) -> Result {
playground.dir("tests")?;
test()
.cwd(playground.path())
.run("cd tests; example env --cwd")
.expect_value_eq(playground.path().join("tests"))
}
#[test]
#[deps(NU_PLUGIN_EXAMPLE)]
fn set_env() -> Result {
test()
.run("example env NUSHELL_OPINION --set=rocks; $env.NUSHELL_OPINION")
.expect_value_eq("rocks")
}