mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 17:58:06 +00:00
569cd162d3
Updates to individual integration tests - use proposed conventional approach to beginning tests - use new convenience functions for using fixtures - use new names for TestScenario Updates to integration test modules - add proposed conventional module-level functions Updates to test/common/util.rs - rename TestSet, and its methods, for semantic clarity - create convenience functions for use of fixtures - delete convenience functions obsoleted by new conventions
77 lines
1.7 KiB
Rust
77 lines
1.7 KiB
Rust
use common::util::*;
|
|
|
|
static UTIL_NAME: &'static str = "env";
|
|
fn new_ucmd() -> UCommand {
|
|
TestScenario::new(UTIL_NAME).ucmd()
|
|
}
|
|
|
|
#[test]
|
|
fn test_single_name_value_pair() {
|
|
let out = new_ucmd()
|
|
.arg("FOO=bar").run().stdout;
|
|
|
|
assert!(out.lines().any(|line| line == "FOO=bar"));
|
|
}
|
|
|
|
#[test]
|
|
fn test_multiple_name_value_pairs() {
|
|
let out = new_ucmd()
|
|
.arg("FOO=bar")
|
|
.arg("ABC=xyz")
|
|
.run()
|
|
.stdout;
|
|
|
|
assert_eq!(out.lines().filter(|&line| line == "FOO=bar" || line == "ABC=xyz").count(),
|
|
2);
|
|
}
|
|
|
|
#[test]
|
|
fn test_ignore_environment() {
|
|
let scene = TestScenario::new(UTIL_NAME);
|
|
|
|
let out = scene.ucmd()
|
|
.arg("-i")
|
|
.run()
|
|
.stdout;
|
|
|
|
assert_eq!(out, "");
|
|
|
|
let out = scene.ucmd()
|
|
.arg("-")
|
|
.run()
|
|
.stdout;
|
|
|
|
assert_eq!(out, "");
|
|
}
|
|
|
|
#[test]
|
|
fn test_null_delimiter() {
|
|
let out = new_ucmd()
|
|
.arg("-i")
|
|
.arg("--null")
|
|
.arg("FOO=bar")
|
|
.arg("ABC=xyz")
|
|
.run()
|
|
.stdout;
|
|
|
|
let mut vars : Vec<_> = out.split('\0').collect();
|
|
assert_eq!(vars.len(), 3);
|
|
vars.sort();
|
|
assert_eq!(vars[0], "");
|
|
assert_eq!(vars[1], "ABC=xyz");
|
|
assert_eq!(vars[2], "FOO=bar");
|
|
}
|
|
|
|
#[test]
|
|
fn test_unset_variable() {
|
|
// This test depends on the HOME variable being pre-defined by the
|
|
// default shell
|
|
let out = TestScenario::new(UTIL_NAME)
|
|
.ucmd_keepenv()
|
|
.arg("-u")
|
|
.arg("HOME")
|
|
.run()
|
|
.stdout;
|
|
|
|
assert_eq!(out.lines().any(|line| line.starts_with("HOME=")), false);
|
|
}
|