aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_srv/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-06-09 16:16:52 +0100
committerJonas Schievink <[email protected]>2021-06-09 16:16:52 +0100
commit05b3a4bc93cf6555857bfc68b5e85830a0da80dc (patch)
tree4bd5ad6b0b9a6a4a653ad8511122fa542021f588 /crates/proc_macro_srv/src
parent5f592f4f58a6e1e1db0f920af34a2f569b65017c (diff)
Build test-macros in a build script
Diffstat (limited to 'crates/proc_macro_srv/src')
-rw-r--r--crates/proc_macro_srv/src/tests/utils.rs29
1 files changed, 1 insertions, 28 deletions
diff --git a/crates/proc_macro_srv/src/tests/utils.rs b/crates/proc_macro_srv/src/tests/utils.rs
index 2e950c113..2c093aa0a 100644
--- a/crates/proc_macro_srv/src/tests/utils.rs
+++ b/crates/proc_macro_srv/src/tests/utils.rs
@@ -7,35 +7,8 @@ use proc_macro_api::ListMacrosTask;
7use std::str::FromStr; 7use std::str::FromStr;
8 8
9pub mod fixtures { 9pub mod fixtures {
10 use cargo_metadata::Message;
11 use std::path::PathBuf;
12 use std::process::Command;
13
14 // Use current project metadata to get the proc-macro dylib path
15 pub fn proc_macro_test_dylib_path() -> std::path::PathBuf { 10 pub fn proc_macro_test_dylib_path() -> std::path::PathBuf {
16 let name = "proc_macro_test"; 11 proc_macro_test::PROC_MACRO_TEST_LOCATION.into()
17 let version = "0.0.0";
18 let command = Command::new(toolchain::cargo())
19 .args(&["check", "--tests", "--message-format", "json"])
20 .output()
21 .unwrap()
22 .stdout;
23
24 for message in Message::parse_stream(command.as_slice()) {
25 match message.unwrap() {
26 Message::CompilerArtifact(artifact) => {
27 if artifact.target.kind.contains(&"proc-macro".to_string()) {
28 let repr = format!("{} {}", name, version);
29 if artifact.package_id.repr.starts_with(&repr) {
30 return PathBuf::from(&artifact.filenames[0]);
31 }
32 }
33 }
34 _ => (), // Unknown message
35 }
36 }
37
38 panic!("No proc-macro dylib for {} found!", name);
39 } 12 }
40} 13}
41 14