fix: correct test name parsing when the prior test has equal signs

This commit is contained in:
Amaan Qureshi 2024-09-29 19:33:49 -04:00
parent 4dad379928
commit 2fffe036e0

View file

@ -27,7 +27,7 @@ lazy_static! {
(?P<equals>(?:=+){3,})
(?P<suffix1>[^=\r\n][^\r\n]*)?
\r?\n
(?P<test_name_and_markers>(?:[^=][^\r\n]*\r?\n)+)
(?P<test_name_and_markers>(?:([^=\r\n]|\s+:)[^\r\n]*\r?\n)+)
===+
(?P<suffix2>[^=\r\n][^\r\n]*)?\r?\n"
)
@ -1242,7 +1242,27 @@ NOT A TEST HEADER
---asdf\()[]|{}*+?^$.-
(a)
"
==============================asdf\()[]|{}*+?^$.-
Test containing equals
==============================asdf\()[]|{}*+?^$.-
===
------------------------------asdf\()[]|{}*+?^$.-
(a)
==============================asdf\()[]|{}*+?^$.-
Subsequent test containing equals
==============================asdf\()[]|{}*+?^$.-
===
------------------------------asdf\()[]|{}*+?^$.-
(a)
"
.trim(),
None,
);
@ -1252,7 +1272,7 @@ NOT A TEST HEADER
=========================\n\
-------------------------\n"
.to_vec();
assert_eq!(
pretty_assertions::assert_eq!(
entry,
TestEntry::Group {
name: "the-filename".to_string(),
@ -1286,6 +1306,26 @@ NOT A TEST HEADER
has_fields: false,
attributes_str: String::new(),
attributes: TestAttributes::default(),
},
TestEntry::Example {
name: "Test containing equals".to_string(),
input: "\n===\n".into(),
output: "(a)".into(),
header_delim_len: 30,
divider_delim_len: 30,
has_fields: false,
attributes_str: String::new(),
attributes: TestAttributes::default(),
},
TestEntry::Example {
name: "Subsequent test containing equals".to_string(),
input: "\n===\n".into(),
output: "(a)".into(),
header_delim_len: 30,
divider_delim_len: 30,
has_fields: false,
attributes_str: String::new(),
attributes: TestAttributes::default(),
}
],
file_path: None,
@ -1406,6 +1446,7 @@ a
=============================
Test with bad platform marker
:platform({})
:language(foo)
=============================
a
@ -1452,9 +1493,9 @@ a
divider_delim_len: 3,
has_fields: false,
attributes_str: if std::env::consts::OS == "linux" {
":platform(macos)\n:language(foo)".to_string()
":platform(macos)\n\n:language(foo)".to_string()
} else {
":platform(linux)\n:language(foo)".to_string()
":platform(linux)\n\n:language(foo)".to_string()
},
attributes: TestAttributes {
skip: false,