mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-04 01:14:26 +08:00
Make string_tests.rs deterministic regardless of qmark-noglob
Move all qmark tests to `scoped_test()` sections with explicitly set feature flags. We already test the default qmark behavior in the functionality tests.
This commit is contained in:
parent
34a5443cfd
commit
ea980c19db
@ -34,18 +34,19 @@ fn test_string() {
|
||||
|
||||
let rc = string(parser, &mut streams, args.as_mut_slice()).expect("string failed");
|
||||
|
||||
assert_eq!(
|
||||
expected_rc.unwrap(),
|
||||
rc,
|
||||
"string builtin returned unexpected return code"
|
||||
);
|
||||
|
||||
let actual = escape(outs.contents());
|
||||
let expected = escape(expected_out);
|
||||
assert_eq!(
|
||||
expected, actual,
|
||||
"string builtin returned unexpected output"
|
||||
);
|
||||
|
||||
// Check return code after so we get a chance to identify the difference first
|
||||
assert_eq!(
|
||||
expected_rc.unwrap(),
|
||||
rc,
|
||||
"string builtin returned unexpected return code"
|
||||
);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
@ -88,15 +89,11 @@ fn test_string() {
|
||||
(["string", "match"], STATUS_INVALID_ARGS, ""),
|
||||
(["string", "match", ""], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "", ""], STATUS_CMD_OK, "\n"),
|
||||
(["string", "match", "?", "a"], STATUS_CMD_OK, "a\n"),
|
||||
(["string", "match", "*", ""], STATUS_CMD_OK, "\n"),
|
||||
(["string", "match", "**", ""], STATUS_CMD_OK, "\n"),
|
||||
(["string", "match", "*", "xyzzy"], STATUS_CMD_OK, "xyzzy\n"),
|
||||
(["string", "match", "**", "plugh"], STATUS_CMD_OK, "plugh\n"),
|
||||
(["string", "match", "a*b", "axxb"], STATUS_CMD_OK, "axxb\n"),
|
||||
(["string", "match", "a??b", "axxb"], STATUS_CMD_OK, "axxb\n"),
|
||||
(["string", "match", "-i", "a??B", "axxb"], STATUS_CMD_OK, "axxb\n"),
|
||||
(["string", "match", "-i", "a??b", "Axxb"], STATUS_CMD_OK, "Axxb\n"),
|
||||
(["string", "match", "a*", "axxb"], STATUS_CMD_OK, "axxb\n"),
|
||||
(["string", "match", "*a", "xxa"], STATUS_CMD_OK, "xxa\n"),
|
||||
(["string", "match", "*a*", "axa"], STATUS_CMD_OK, "axa\n"),
|
||||
@ -107,14 +104,7 @@ fn test_string() {
|
||||
(["string", "match", "a*b*c", "axxbyyc"], STATUS_CMD_OK, "axxbyyc\n"),
|
||||
(["string", "match", "\\*", "*"], STATUS_CMD_OK, "*\n"),
|
||||
(["string", "match", "a*\\", "abc\\"], STATUS_CMD_OK, "abc\\\n"),
|
||||
(["string", "match", "a*\\?", "abc?"], STATUS_CMD_OK, "abc?\n"),
|
||||
|
||||
(["string", "match", "?", ""], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "?", "ab"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "??", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "?a", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a?", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a??B", "axxb"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a*b", "axxbc"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "*b", "bbba"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "0x[0-9a-fA-F][0-9a-fA-F]", "0xbad"], STATUS_CMD_ERROR, ""),
|
||||
@ -293,6 +283,20 @@ fn test_string() {
|
||||
(["string", "match", "?*", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "?*", "ab"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a*\\?", "abc?"], STATUS_CMD_ERROR, ""),
|
||||
|
||||
(["string", "match", "?", "?"], STATUS_CMD_OK, "?\n"),
|
||||
(["string", "match", "a??b", "axxb"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a??b", "a??b"], STATUS_CMD_OK, "a??b\n"),
|
||||
(["string", "match", "-i", "a??B", "axxb"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "-i", "a??b", "A??b"], STATUS_CMD_OK, "A??b\n"),
|
||||
(["string", "match", "a*\\?", "abc\\?"], STATUS_CMD_OK, "abc\\?\n"),
|
||||
|
||||
(["string", "match", "?", ""], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "?", "ab"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "??", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "?a", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a?", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a??B", "axxb"], STATUS_CMD_ERROR, ""),
|
||||
];
|
||||
|
||||
scoped_test(FeatureFlag::qmark_noglob, true, || {
|
||||
@ -309,6 +313,13 @@ fn test_string() {
|
||||
(["string", "match", "?*", "a"], STATUS_CMD_OK, "a\n"),
|
||||
(["string", "match", "?*", "ab"], STATUS_CMD_OK, "ab\n"),
|
||||
(["string", "match", "a*\\?", "abc?"], STATUS_CMD_OK, "abc?\n"),
|
||||
|
||||
(["string", "match", "?", ""], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "?", "ab"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "??", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "?a", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a?", "a"], STATUS_CMD_ERROR, ""),
|
||||
(["string", "match", "a??B", "axxb"], STATUS_CMD_ERROR, ""),
|
||||
];
|
||||
|
||||
scoped_test(FeatureFlag::qmark_noglob, false, || {
|
||||
|
Loading…
x
Reference in New Issue
Block a user