forked from uutils/coreutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_printenv.rs
37 lines (32 loc) · 970 Bytes
/
test_printenv.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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.
use crate::common::util::TestScenario;
#[test]
fn test_get_all() {
TestScenario::new(util_name!())
.ucmd()
.env("HOME", "FOO")
.env("KEY", "VALUE")
.succeeds()
.stdout_contains("HOME=FOO")
.stdout_contains("KEY=VALUE");
}
#[test]
fn test_get_var() {
let result = TestScenario::new(util_name!())
.ucmd()
.env("KEY", "VALUE")
.arg("KEY")
.succeeds();
assert!(!result.stdout_str().is_empty());
assert_eq!(result.stdout_str().trim(), "VALUE");
}
#[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());
}