mirror of
https://github.com/nushell/nushell
synced 2025-01-20 00:55:54 +00:00
109 lines
2.8 KiB
Rust
109 lines
2.8 KiB
Rust
|
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 | into string);
|
||
|
ulimit -s -H $soft;
|
||
|
let hard = (ulimit -s | first | get hard | into string);
|
||
|
$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 | into string);
|
||
|
ulimit -s -H soft;
|
||
|
let hard = (ulimit -s | first | get hard | into string);
|
||
|
$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 | into string);
|
||
|
ulimit -s $hard;
|
||
|
let soft = (ulimit -s | first | get soft | into string);
|
||
|
$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 | into string);
|
||
|
ulimit -s hard;
|
||
|
let soft = (ulimit -s | first | get soft | into string);
|
||
|
$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 | into string);
|
||
|
ulimit -s $new
|
||
|
}
|
||
|
}
|
||
|
"
|
||
|
));
|
||
|
|
||
|
assert!(
|
||
|
actual.out.contains("unlimited")
|
||
|
|| actual.err.contains("EPERM: Operation not permitted")
|
||
|
);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn limit_set_invalid2() {
|
||
|
Playground::setup("limit_set_invalid2", |dirs, _sandbox| {
|
||
|
let actual = nu!(
|
||
|
cwd: dirs.test(),
|
||
|
"
|
||
|
ulimit -c abcd
|
||
|
"
|
||
|
);
|
||
|
|
||
|
assert!(actual.err.contains("Can't convert to rlim_t."));
|
||
|
});
|
||
|
}
|