From cb816b1ea87b24f34eeecfdd98aeeb629915d661 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 15 Aug 2020 00:19:47 +0200 Subject: Add a proc_macro_test crate This exports all 3 kinds of proc macros and is useful for testing --- crates/proc_macro_srv/Cargo.toml | 4 +++- crates/proc_macro_srv/src/tests/mod.rs | 15 ++++++++++++++- crates/proc_macro_srv/src/tests/utils.rs | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'crates/proc_macro_srv') diff --git a/crates/proc_macro_srv/Cargo.toml b/crates/proc_macro_srv/Cargo.toml index 7171f0808..a468b5560 100644 --- a/crates/proc_macro_srv/Cargo.toml +++ b/crates/proc_macro_srv/Cargo.toml @@ -21,7 +21,9 @@ test_utils = { path = "../test_utils" } [dev-dependencies] cargo_metadata = "0.11.1" difference = "2.0.0" -# used as proc macro test target + +# used as proc macro test targets serde_derive = "1.0.106" +proc_macro_test = { path = "../proc_macro_test" } toolchain = { path = "../toolchain" } diff --git a/crates/proc_macro_srv/src/tests/mod.rs b/crates/proc_macro_srv/src/tests/mod.rs index 8e6f28abd..1a827cbd7 100644 --- a/crates/proc_macro_srv/src/tests/mod.rs +++ b/crates/proc_macro_srv/src/tests/mod.rs @@ -35,7 +35,7 @@ SUBTREE $ #[test] fn test_derive_proc_macro_list() { - let res = list("serde_derive", "1.0").join("\n"); + let res = list("serde_derive", "1").join("\n"); assert_eq_text!( &res, @@ -43,3 +43,16 @@ fn test_derive_proc_macro_list() { Deserialize [CustomDerive]"# ); } + +/// Tests that we find and classify non-derive macros correctly. +#[test] +fn list_test_macros() { + let res = list("proc_macro_test", "0.0.0").join("\n"); + + assert_eq_text!( + &res, + r#"function_like_macro [FuncLike] +attribute_macro [Attr] +DummyTrait [CustomDerive]"# + ); +} diff --git a/crates/proc_macro_srv/src/tests/utils.rs b/crates/proc_macro_srv/src/tests/utils.rs index 5828512d6..36942147d 100644 --- a/crates/proc_macro_srv/src/tests/utils.rs +++ b/crates/proc_macro_srv/src/tests/utils.rs @@ -13,7 +13,7 @@ mod fixtures { // Use current project metadata to get the proc-macro dylib path pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf { let command = Command::new(toolchain::cargo()) - .args(&["check", "--message-format", "json"]) + .args(&["check", "--tests", "--message-format", "json"]) .output() .unwrap() .stdout; -- cgit v1.2.3