File tree 4 files changed +39
-4
lines changed
4 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ proc-macro2 = "0.4.29"
9
9
dylib = " 0.0.3"
10
10
goblin = " 0.0.22"
11
11
syn = " 0.15.33"
12
- tempfile = " 3"
12
+ tempfile = " 3"
13
+ test_proc_macro = { path = " ./test_proc_macro" }
Original file line number Diff line number Diff line change @@ -123,11 +123,29 @@ fn compile_proc_macro(dir: &PathBuf) -> io::Result<PathBuf> {
123
123
}
124
124
}
125
125
126
+ fn find_test_proc_macro ( ) -> io:: Result < PathBuf > {
127
+ let mut test_exe = std:: env:: current_exe ( ) ?;
128
+ test_exe. pop ( ) ;
129
+
130
+ for entry in fs:: read_dir ( & test_exe) ? {
131
+ let entry = entry?;
132
+ let name = entry. file_name ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
133
+ if entry. path ( ) . is_file ( )
134
+ && name. starts_with ( "libtest_proc_macro" )
135
+ && name. ends_with ( ".so" ) {
136
+ return Ok ( entry. path ( ) ) ;
137
+ }
138
+ }
139
+
140
+ Err ( io:: Error :: from ( ErrorKind :: NotFound ) )
141
+ }
142
+
126
143
#[ test]
127
144
fn test_getset_expansion ( ) -> io:: Result < ( ) > {
128
- let tmp_dir = TempDir :: new ( ) ?;
129
- setup_temp_proc_macro_project ( & tmp_dir. path ( ) . to_path_buf ( ) ) ?;
130
- let proc_macro_lib = canonicalize ( compile_proc_macro ( & tmp_dir. path ( ) . to_path_buf ( ) ) ?) ?;
145
+ // let tmp_dir = TempDir::new()?;
146
+ // setup_temp_proc_macro_project(&tmp_dir.path().to_path_buf())?;
147
+ // let proc_macro_lib = canonicalize(compile_proc_macro(&tmp_dir.path().to_path_buf())?)?;
148
+ let proc_macro_lib = find_test_proc_macro ( ) ?;
131
149
132
150
let symbol_name = find_registrar_symbol ( & proc_macro_lib) . expect (
133
151
& format ! ( "Cannot find registrar symbol in file {:?}" , & proc_macro_lib)
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " test_proc_macro"
3
+ version = " 0.1.0"
4
+
5
+ [lib ]
6
+ proc-macro = true
7
+
8
+ [dependencies ]
Original file line number Diff line number Diff line change
1
+ extern crate proc_macro;
2
+
3
+ use proc_macro:: TokenStream ;
4
+
5
+ #[ proc_macro]
6
+ pub fn make_answer_macro ( input : TokenStream ) -> TokenStream {
7
+ "fn answer() -> u32 { 42 }" . parse ( ) . unwrap ( )
8
+ }
You can’t perform that action at this time.
0 commit comments