File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,66 @@ fn basic() {
154
154
assert_eq ! ( p. glob( deps_dir. join( "*.dylib" ) ) . count( ) , 0 ) ;
155
155
}
156
156
157
+ #[ cargo_test( build_std_real) ]
158
+ fn host_proc_macro ( ) {
159
+ let p = project ( )
160
+ . file (
161
+ "Cargo.toml" ,
162
+ r#"
163
+ [package]
164
+ name = "foo"
165
+ version = "0.1.0"
166
+ edition = "2021"
167
+
168
+ [dependencies]
169
+ macro_test = { path = "macro_test" }
170
+ "# ,
171
+ )
172
+ . file (
173
+ "src/main.rs" ,
174
+ r#"
175
+ extern crate macro_test;
176
+ use macro_test::make_answer;
177
+
178
+ make_answer!();
179
+
180
+ fn main() {
181
+ println!("Hello, World: {}", answer());
182
+ }
183
+ "# ,
184
+ )
185
+ . file (
186
+ "macro_test/Cargo.toml" ,
187
+ r#"
188
+ [package]
189
+ name = "macro_test"
190
+ version = "0.1.0"
191
+ edition = "2021"
192
+
193
+ [lib]
194
+ proc-macro = true
195
+ "# ,
196
+ )
197
+ . file (
198
+ "macro_test/src/lib.rs" ,
199
+ r#"
200
+ extern crate proc_macro;
201
+ use proc_macro::TokenStream;
202
+
203
+ #[proc_macro]
204
+ pub fn make_answer(_item: TokenStream) -> TokenStream {
205
+ "fn answer() -> u32 { 42 }".parse().unwrap()
206
+ }
207
+ "# ,
208
+ )
209
+ . build ( ) ;
210
+
211
+ p. cargo ( "build" )
212
+ . build_std_arg ( "std" )
213
+ . build_std_arg ( "proc_macro" )
214
+ . run ( ) ;
215
+ }
216
+
157
217
#[ cargo_test( build_std_real) ]
158
218
fn cross_custom ( ) {
159
219
let p = project ( )
You can’t perform that action at this time.
0 commit comments