From e60b581c38eaf195fa3264b84693427fe9645cb7 Mon Sep 17 00:00:00 2001 From: Hanif Ariffin Date: Thu, 3 Feb 2022 23:02:50 +0800 Subject: [PATCH] test_sort: Preserve the environment variable when executing tests (#3031) * test_sort: Output sorted files to a file with different name Signed-off-by: Hanif Bin Ariffin * Fix the test by saving the environment variable Signed-off-by: Hanif Bin Ariffin Co-authored-by: Hanif Bin Ariffin --- tests/by-util/test_sort.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 5cf622fb8..5ae56b29e 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -1066,10 +1066,13 @@ fn test_separator_null() { #[test] fn test_output_is_input() { let input = "a\nb\nc\n"; - let (at, mut cmd) = at_and_ucmd!(); + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; at.touch("file"); at.append("file", input); - cmd.args(&["-m", "-u", "-o", "file", "file", "file", "file"]) + scene + .ucmd_keepenv() + .args(&["-m", "-u", "-o", "file", "file", "file", "file"]) .succeeds(); assert_eq!(at.read("file"), input); }