-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
We want the CmdResult struct to hold Vec<u8>s instead of Strings so that we can run tests with non-utf8 output,
#1977 Defined a public API, but unfortunately, many tests still access fields of CmdResult directly.
E.g.
fn test_multiple_formats() {
let input = "abcdefghijklmnopqrstuvwxyz\n";
let result = new_ucmd!()
.arg("-c")
.arg("-b")
.run_piped_stdin(input.as_bytes());
assert_empty_stderr!(result);
assert!(result.success);
assert_eq!(
result.stdout,
unindent(
"
0000000 a b c d e f g h i j k l m n o p
141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160
0000020 q r s t u v w x y z \\n
161 162 163 164 165 166 167 170 171 172 012
0000033
"
)
);
}Is to be re-written as
fn test_multiple_formats() {
let input = "abcdefghijklmnopqrstuvwxyz\n";
new_ucmd!()
.arg("-c")
.arg("-b")
.run_piped_stdin(input.as_bytes())
.success()
.no_stderr()
.stdout_is(unindent(
"
0000000 a b c d e f g h i j k l m n o p
141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160
0000020 q r s t u v w x y z \\n
161 162 163 164 165 166 167 170 171 172 012
0000033
"
));
}I'll start work on od & ls for now. If you're interested in doing some, please comment so we don't do the same work twice!
It's not very hard; some tips:
- use the find/replace functionality of your IDE (or
sedeven) - take a look at
tests/common/util.rsto see all the functions aCmdResulthas - you can locally make these fields private (but please don't commit this!) and fix the resulting errors
Lastly, please make sure you're not changing the tests' functionality.
Metadata
Metadata
Assignees
Labels
No labels