[fine] Ignore tests sometimes

This commit is contained in:
John Doty 2024-01-08 22:23:46 -08:00
parent 6d2fd446ee
commit f2b9eae339
3 changed files with 12 additions and 1 deletions

View file

@ -10,6 +10,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
let display_path = path.display().to_string();
// Start iterating over lines and processing directives....
let mut disabled = quote! {};
let mut assertions = Vec::new();
let mut lines = contents.lines();
while let Some(line) = lines.next() {
@ -19,7 +20,9 @@ fn generate_test_for_file(path: PathBuf) -> String {
};
let line = line.trim();
if line == "@concrete:" {
if line == "@disabled" {
disabled = quote! { #[ignore] };
} else if line == "@concrete:" {
let mut concrete = String::new();
while let Some(line) = lines.next() {
let line = match line.strip_prefix("// | ") {
@ -65,6 +68,7 @@ fn generate_test_for_file(path: PathBuf) -> String {
let name = format_ident!("{}", path.file_stem().unwrap().to_string_lossy());
let test_method = quote! {
#disabled
fn #name() {
let (_tree, _lines) = fine::parser::parse(#contents);
#(#assertions)*

View file

@ -37,6 +37,8 @@ e.g., a test might look like this:
The various assertions are as follows:
- The `// @disabled` directive marks the test as ignored.
- The `// @concrete:` assertion says that the following lines
(prefixed with `// | `, as above) describe the concrete syntax tree
of the file after parsing.

View file

@ -0,0 +1,5 @@
// @disabled
// @concrete:
// |
;