coreutils/tests/by-util/test_printenv.rs

38 lines
970 B
Rust
Raw Normal View History

2023-08-21 08:49:27 +00:00
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
2023-03-20 13:51:19 +00:00
use crate::common::util::TestScenario;
2020-05-02 14:54:29 +00:00
#[test]
fn test_get_all() {
2021-04-17 23:28:06 +00:00
TestScenario::new(util_name!())
.ucmd()
.env("HOME", "FOO")
.env("KEY", "VALUE")
2021-04-17 23:28:06 +00:00
.succeeds()
.stdout_contains("HOME=FOO")
2021-04-17 23:28:06 +00:00
.stdout_contains("KEY=VALUE");
2020-05-02 14:54:29 +00:00
}
#[test]
fn test_get_var() {
let result = TestScenario::new(util_name!())
.ucmd()
.env("KEY", "VALUE")
2020-05-02 14:54:29 +00:00
.arg("KEY")
2021-04-17 23:28:06 +00:00
.succeeds();
2020-05-02 14:54:29 +00:00
2021-04-17 23:28:06 +00:00
assert!(!result.stdout_str().is_empty());
assert_eq!(result.stdout_str().trim(), "VALUE");
2020-05-02 14:54:29 +00:00
}
#[test]
fn test_ignore_equal_var() {
let scene = TestScenario::new(util_name!());
// tested by gnu/tests/misc/printenv.sh
let result = scene.ucmd().env("a=b", "c").arg("a=b").fails();
assert!(result.stdout_str().is_empty());
}