Skip to content

Commit

Permalink
Fix null nodes with tags in flow constructs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethiraric committed Jan 22, 2024
1 parent 691e838 commit d66f0d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ impl<T: Iterator<Item = char>> Scanner<T> {
}
}

if is_blankz(self.look_ch()) {
if is_blankz(self.look_ch()) || (self.flow_level > 0 && is_flow(self.ch())) {
// XXX: ex 7.2, an empty scalar can follow a secondary tag
Ok(Token(start_mark, TokenType::Tag(handle, suffix)))
} else {
Expand Down
29 changes: 3 additions & 26 deletions tests/yaml-test-suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ struct YamlTest {
yaml: String,
expected_events: String,
expected_error: bool,
is_xfail: bool,
}

fn main() -> Result<()> {
Expand All @@ -33,16 +32,6 @@ fn main() -> Result<()> {
let mut tests: Vec<_> = tests.into_iter().flatten().collect();
tests.sort_by_key(|t| t.name.clone());

let missing_xfails: Vec<_> = EXPECTED_FAILURES
.iter()
.filter(|&&test| !tests.iter().any(|t| t.name == test))
.collect();
assert!(
missing_xfails.is_empty(),
"The following EXPECTED_FAILURES not found during discovery: {:?}",
missing_xfails
);

run_tests(&arguments, tests, run_yaml_test).exit();
}

Expand Down Expand Up @@ -80,13 +69,9 @@ fn run_yaml_test(test: &Test<YamlTest>) -> Outcome {
}
}

match (error_text, desc.is_xfail) {
(None, false) => Outcome::Passed,
(Some(txt), false) => Outcome::Failed { msg: Some(txt) },
(Some(_), true) => Outcome::Ignored,
(None, true) => Outcome::Failed {
msg: Some("expected to fail but passes".into()),
},
match error_text {
None => Outcome::Passed,
Some(txt) => Outcome::Failed { msg: Some(txt) },
}
}

Expand All @@ -106,7 +91,6 @@ fn load_tests_from_file(entry: &DirEntry) -> Result<Vec<Test<YamlTest>>> {
} else {
test_name.to_string()
};
let is_xfail = EXPECTED_FAILURES.contains(&name.as_str());

// Test fields except `fail` are "inherited"
let test_data = test_data.as_hash().unwrap();
Expand All @@ -131,7 +115,6 @@ fn load_tests_from_file(entry: &DirEntry) -> Result<Vec<Test<YamlTest>>> {
yaml: visual_to_raw(current_test["yaml"].as_str().unwrap()),
expected_events: visual_to_raw(current_test["tree"].as_str().unwrap()),
expected_error: current_test["fail"].as_bool() == Some(true),
is_xfail,
},
});
}
Expand Down Expand Up @@ -311,9 +294,3 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
})
.collect()
}

#[rustfmt::skip]
static EXPECTED_FAILURES: &[&str] = &[
// Misc
"WZ62", // Empty content
];

0 comments on commit d66f0d3

Please sign in to comment.