diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-09-30 14:46:21 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-09-30 16:09:04 +0200 |
| commit | 386b49ad7156570cfc437e1ff3b720f1f5cc9b39 (patch) | |
| tree | c1facbce135eaba50942077850e0336383f91bbe | |
| parent | e0e4e89822f06f05d7484dfd0e353902bb2816f8 (diff) | |
| download | mullvadvpn-386b49ad7156570cfc437e1ff3b720f1f5cc9b39.tar.xz mullvadvpn-386b49ad7156570cfc437e1ff3b720f1f5cc9b39.zip | |
Handle skip test_macro attribute as path
| -rw-r--r-- | test/test-manager/test_macro/src/lib.rs | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/test/test-manager/test_macro/src/lib.rs b/test/test-manager/test_macro/src/lib.rs index 88b1f4f1df..8fe3c32916 100644 --- a/test/test-manager/test_macro/src/lib.rs +++ b/test/test-manager/test_macro/src/lib.rs @@ -106,35 +106,38 @@ fn get_test_macro_parameters(attributes: &syn::AttributeArgs) -> Result<MacroPar let mut skip = false; for attribute in attributes { - // we only use name-value attributes - let NestedMeta::Meta(Meta::NameValue(nv)) = attribute else { - bail!(attribute, "unknown attribute"); - }; - let lit = &nv.lit; + match attribute { + NestedMeta::Meta(Meta::Path(path)) if path.is_ident("skip") => { + skip = true; + } + NestedMeta::Meta(Meta::NameValue(nv)) => { + let lit = &nv.lit; - match &nv.path { - path if path.is_ident("priority") => match lit { - Lit::Int(lit_int) => priority = Some(lit_int.base10_parse().unwrap()), - _ => bail!(nv, "'priority' should have an integer value"), - }, - path if path.is_ident("target_os") => { - let Lit::Str(lit_str) = lit else { - bail!(nv, "'target_os' should have a string value"); - }; + match &nv.path { + path if path.is_ident("priority") => match lit { + Lit::Int(lit_int) => priority = Some(lit_int.base10_parse().unwrap()), + _ => bail!(nv, "'priority' should have an integer value"), + }, + path if path.is_ident("target_os") => { + let Lit::Str(lit_str) = lit else { + bail!(nv, "'target_os' should have a string value"); + }; - let target = match lit_str.value().parse() { - Ok(os) => os, - Err(e) => bail!(lit_str, "{e}"), - }; + let target = match lit_str.value().parse() { + Ok(os) => os, + Err(e) => bail!(lit_str, "{e}"), + }; - if targets.contains(&target) { - bail!(nv, "Duplicate target"); - } + if targets.contains(&target) { + bail!(nv, "Duplicate target"); + } - targets.push(target); + targets.push(target); + } + _ => bail!(nv, "unknown attribute"), + } } - path if path.is_ident("skip") => skip = true, - _ => bail!(nv, "unknown attribute"), + _ => bail!(attribute, "unknown attribute"), } } |
