1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tests/env: add unsetting invalid variables test

This commit is contained in:
Thomas Queiroz 2021-11-02 19:32:41 -03:00
parent 3d74e7b452
commit c44b5952b8
No known key found for this signature in database
GPG key ID: 229D2DDF7ECA5F8F

View file

@ -1,4 +1,4 @@
// spell-checker:ignore (words) bamf chdir
// spell-checker:ignore (words) bamf chdir rlimit prlimit
#[cfg(not(windows))]
use std::fs;
@ -80,6 +80,20 @@ fn test_combined_file_set_unset() {
);
}
#[test]
fn test_unset_invalid_variables() {
use uucore::display::Quotable;
// Cannot test input with \0 in it, since output will also contain \0. rlimit::prlimit fails
// with this error: Error { kind: InvalidInput, message: "nul byte found in provided data" }
for var in &["", "a=b"] {
new_ucmd!().arg("-u").arg(var).run().stderr_only(format!(
"env: cannot unset {}: Invalid argument",
var.quote()
));
}
}
#[test]
fn test_single_name_value_pair() {
let out = new_ucmd!().arg("FOO=bar").run();