Skip to content

Commit f323b53

Browse files
committed
fix '<slt:ignore>' edge case in default validator
1 parent 265f332 commit f323b53

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

sqllogictest/src/runner.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,18 @@ pub fn default_validator(
506506
let actual_snapshot = actual_rows.join("\n");
507507
let fragments: Vec<&str> = expected_snapshot.split(IGNORE_MARKER).collect();
508508
let mut pos = 0;
509-
for frag in fragments {
509+
for (i, frag) in fragments.iter().enumerate() {
510510
if frag.is_empty() {
511511
continue;
512512
}
513513
if let Some(idx) = actual_snapshot[pos..].find(frag) {
514+
// Edge case: The following example is expected to fail
515+
// Actual - 'foo bar baz'
516+
// Expected - 'bar <slt:ignore>'
517+
if (i == 0) && (idx != 0) {
518+
return false;
519+
}
520+
514521
pos += idx + frag.len();
515522
} else {
516523
tracing::error!(
@@ -2361,7 +2368,10 @@ Caused by:
23612368
"beta".to_string(),
23622369
"gamma".to_string(),
23632370
]];
2364-
let expected = vec!["alpha<slt:ignore>delta".to_string()];
2365-
assert!(!default_validator(normalizer, &actual, &expected));
2371+
let expected1 = vec!["alpha<slt:ignore>delta".to_string()];
2372+
assert!(!default_validator(normalizer, &actual, &expected1));
2373+
2374+
let expected2 = vec!["pha<slt:ignore>gamma".to_string()];
2375+
assert!(!default_validator(normalizer, &actual, &expected2));
23662376
}
23672377
}

0 commit comments

Comments
 (0)