nushell/crates/nu-command/tests/commands/ulimit.rs

219 lines
5.6 KiB
Rust
Raw Normal View History

Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn limit_set_soft1() {
Playground::setup("limit_set_soft1", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(
"
let soft = (ulimit -s | first | get soft);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
ulimit -s -H $soft;
let hard = (ulimit -s | first | get hard);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
$soft == $hard
"
));
assert!(actual.out.contains("true"));
});
}
#[test]
fn limit_set_soft2() {
Playground::setup("limit_set_soft2", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(
"
let soft = (ulimit -s | first | get soft);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
ulimit -s -H soft;
let hard = (ulimit -s | first | get hard);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
$soft == $hard
"
));
assert!(actual.out.contains("true"));
});
}
#[test]
fn limit_set_hard1() {
Playground::setup("limit_set_hard1", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(
"
let hard = (ulimit -s | first | get hard);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
ulimit -s $hard;
let soft = (ulimit -s | first | get soft);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
$soft == $hard
"
));
assert!(actual.out.contains("true"));
});
}
#[test]
fn limit_set_hard2() {
Playground::setup("limit_set_hard2", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(
"
let hard = (ulimit -s | first | get hard);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
ulimit -s hard;
let soft = (ulimit -s | first | get soft);
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
$soft == $hard
"
));
assert!(actual.out.contains("true"));
});
}
#[test]
fn limit_set_invalid1() {
Playground::setup("limit_set_invalid1", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(
"
let hard = (ulimit -s | first | get hard);
match $hard {
\"unlimited\" => { echo \"unlimited\" },
$x => {
let new = $x + 1;
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
ulimit -s $new
}
}
"
));
assert!(
actual.out.contains("unlimited")
|| actual.err.contains("EPERM: Operation not permitted")
);
});
}
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))]
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
#[test]
fn limit_set_invalid2() {
Playground::setup("limit_set_invalid2", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(),
"
let val = -100;
ulimit -c $val
"
);
assert!(actual.err.contains("can't convert i64 to rlim_t"));
});
}
#[test]
fn limit_set_invalid3() {
Playground::setup("limit_set_invalid3", |dirs, _sandbox| {
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
let actual = nu!(
cwd: dirs.test(),
"
ulimit -c abcd
"
);
assert!(actual
.err
.contains("Only unlimited, soft and hard are supported for strings"));
});
}
#[test]
fn limit_set_invalid4() {
Playground::setup("limit_set_invalid4", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(),
"
ulimit -c 100.0
"
);
Allow `filesize` type as a valid limit value (#11349) # Description This pr allow us to use `filesize` type as a valid limit value, which is benefit for some file size based limits. # User-Facing Changes ```console /data/source/nushell> ulimit -f ╭───┬─────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ ╰───┴─────────────────────────────────────────────────────┴───────────┴───────────╯ /data/source/nushell> ulimit -f 10Mib /data/source/nushell> ulimit -f ╭───┬─────────────────────────────────────────────────────┬───────┬───────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────────────────────────────┼───────┼───────┤ │ 0 │ Maximum size of files created by the shell (kB, -f) │ 10240 │ 10240 │ ╰───┴─────────────────────────────────────────────────────┴───────┴───────╯ /data/source/nushell> ulimit -n ╭───┬──────────────────────────────────────────────┬──────┬────────╮ │ # │ description │ soft │ hard │ ├───┼──────────────────────────────────────────────┼──────┼────────┤ │ 0 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ ╰───┴──────────────────────────────────────────────┴──────┴────────╯ /data/source/nushell> ulimit -n 10Mib Error: nu::shell::type_mismatch × Type mismatch. ╭─[entry #5:1:1] 1 │ ulimit -n 10Mib · ─┬─ · ╰── filesize is not compatible with resource RLIMIT_NOFILE ╰──── ``` # Tests + Formatting Make sure you've run and fixed any issues with these commands: - [x] add `commands::ulimit::limit_set_filesize1` - [x] add `commands::ulimit::limit_set_filesize2` - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-16 16:56:03 +01:00
assert!(actual.err.contains("string, int or filesize required"));
});
}
#[test]
fn limit_set_invalid5() {
use nix::sys::resource::rlim_t;
let max = (rlim_t::MAX / 1024) + 1;
Playground::setup("limit_set_invalid5", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(
format!(
"
let hard = (ulimit -c | first | get hard);
match $hard {{
\"unlimited\" => {{
ulimit -c -S 0;
ulimit -c {max};
ulimit -c
| first
| get soft
}},
_ => {{
echo \"unlimited\"
}}
}}
").as_str()
));
assert!(actual.out.eq("unlimited"));
Add ulimit command (#11324) # Description Add `ulimit` command to Nushell. Closes #9563 Closes #3976 Related pr #11246 Reference: https://github.com/fish-shell/fish-shell/blob/master/fish-rust/src/builtins/ulimit.rs https://github.com/mirror/busybox/blob/master/shell/shell_common.c#L529 # User-Facing Changes ``` nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 [3/246] ❯ ulimit -a ╭────┬──────────────────────────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├────┼──────────────────────────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of core files created (kB, -c) │ unlimited │ unlimited │ │ 1 │ Maximum size of a process's data segment (kB, -d) │ unlimited │ unlimited │ │ 2 │ Controls of maximum nice priority (-e) │ 0 │ 0 │ │ 3 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ │ 4 │ Maximum number of pending signals (-i) │ 55273 │ 55273 │ │ 5 │ Maximum size that may be locked into memory (kB, -l) │ 8192 │ 8192 │ │ 6 │ Maximum resident set size (kB, -m) │ unlimited │ unlimited │ │ 7 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ │ 8 │ Maximum bytes in POSIX message queues (kB, -q) │ 800 │ 800 │ │ 9 │ Maximum realtime scheduling priority (-r) │ 0 │ 0 │ │ 10 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ │ 11 │ Maximum amount of CPU time in seconds (seconds, -t) │ unlimited │ unlimited │ │ 12 │ Maximum number of processes available to the current user (-u) │ 55273 │ 55273 │ │ 13 │ Maximum amount of virtual memory available to each process (kB, -v) │ unlimited │ unlimited │ │ 14 │ Maximum number of file locks (-x) │ unlimited │ unlimited │ │ 15 │ Maximum contiguous realtime CPU time (-y) │ unlimited │ unlimited │ ╰────┴──────────────────────────────────────────────────────────────────────────┴───────────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼───────────┤ │ 0 │ Maximum stack size (kB, -s) │ 8192 │ unlimited │ ╰───┴─────────────────────────────┴──────┴───────────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s 100 nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ❯ ulimit -s ╭───┬─────────────────────────────┬──────┬──────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────┼──────┼──────┤ │ 0 │ Maximum stack size (kB, -s) │ 100 │ 100 │ ╰───┴─────────────────────────────┴──────┴──────╯ nushell on  ulimit is 📦 v0.88.2 via 🦀 v1.72.1 ``` # Tests + Formatting - [x] add commands::ulimit::limit_set_soft1 - [x] add commands::ulimit::limit_set_soft2 - [x] add commands::ulimit::limit_set_hard1 - [x] add commands::ulimit::limit_set_hard2 - [x] add commands::ulimit::limit_set_invalid1 - [x] add commands::ulimit::limit_set_invalid2 - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-15 14:11:17 +01:00
});
}
Allow `filesize` type as a valid limit value (#11349) # Description This pr allow us to use `filesize` type as a valid limit value, which is benefit for some file size based limits. # User-Facing Changes ```console /data/source/nushell> ulimit -f ╭───┬─────────────────────────────────────────────────────┬───────────┬───────────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────────────────────────────┼───────────┼───────────┤ │ 0 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │ ╰───┴─────────────────────────────────────────────────────┴───────────┴───────────╯ /data/source/nushell> ulimit -f 10Mib /data/source/nushell> ulimit -f ╭───┬─────────────────────────────────────────────────────┬───────┬───────╮ │ # │ description │ soft │ hard │ ├───┼─────────────────────────────────────────────────────┼───────┼───────┤ │ 0 │ Maximum size of files created by the shell (kB, -f) │ 10240 │ 10240 │ ╰───┴─────────────────────────────────────────────────────┴───────┴───────╯ /data/source/nushell> ulimit -n ╭───┬──────────────────────────────────────────────┬──────┬────────╮ │ # │ description │ soft │ hard │ ├───┼──────────────────────────────────────────────┼──────┼────────┤ │ 0 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │ ╰───┴──────────────────────────────────────────────┴──────┴────────╯ /data/source/nushell> ulimit -n 10Mib Error: nu::shell::type_mismatch × Type mismatch. ╭─[entry #5:1:1] 1 │ ulimit -n 10Mib · ─┬─ · ╰── filesize is not compatible with resource RLIMIT_NOFILE ╰──── ``` # Tests + Formatting Make sure you've run and fixed any issues with these commands: - [x] add `commands::ulimit::limit_set_filesize1` - [x] add `commands::ulimit::limit_set_filesize2` - [x] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [x] `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - [x] `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library
2023-12-16 16:56:03 +01:00
#[test]
fn limit_set_filesize1() {
Playground::setup("limit_set_filesize1", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(), pipeline(
"
let hard = (ulimit -c | first | get hard);
match $hard {
\"unlimited\" => {
ulimit -c 1Mib;
ulimit -c
| first
| get soft
},
$x if $x >= 1024 * 1024 => {
ulimit -c 1Mib;
ulimit -c
| first
| get soft
}
_ => {
echo \"hard limit too small\"
}
}
"
));
assert!(actual.out.eq("1024") || actual.out.eq("hard limit too small"));
});
}
#[test]
fn limit_set_filesize2() {
Playground::setup("limit_set_filesize2", |dirs, _sandbox| {
let actual = nu!(
cwd: dirs.test(),
"
ulimit -n 10Kib
"
);
assert!(actual
.err
.contains("filesize is not compatible with resource RLIMIT_NOFILE"));
});
}