tests/env: add unsetting invalid variables test

This commit is contained in:
Thomas Queiroz
2021-11-02 19:51:37 -03:00
parent 3d74e7b452
commit c44b5952b8
+15 -1
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();