Skip to content

Commit 1ccbcfe

Browse files
authored
Merge pull request Manishearth#171 from phansch/proc_macro_extern_run_pass
Add a proc-macro UI test example to the test project
2 parents 3cbd33a + 4f1f614 commit 1ccbcfe

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// no-prefer-dynamic
2+
3+
#![crate_type = "proc-macro"]
4+
5+
extern crate proc_macro;
6+
7+
use proc_macro::{TokenStream};
8+
9+
#[proc_macro]
10+
pub fn macro_test(input_stream: TokenStream) -> TokenStream {
11+
TokenStream::new()
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// run-pass
2+
// aux-build:simple_proc_macro.rs
3+
4+
#![feature(proc_macro_hygiene)]
5+
6+
extern crate simple_proc_macro;
7+
use simple_proc_macro::macro_test;
8+
9+
fn main() {
10+
println!("hi");
11+
macro_test!(2);
12+
}
13+

test-project/tests/tests.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ extern crate compiletest_rs as compiletest;
22

33
use std::path::PathBuf;
44

5-
fn run_mode(mode: &'static str) {
6-
5+
fn run_mode(mode: &'static str, custom_dir: Option<&'static str>) {
76
let mut config = compiletest::Config::default().tempdir();
87
let cfg_mode = mode.parse().expect("Invalid mode");
98

109
config.mode = cfg_mode;
11-
config.src_base = PathBuf::from(format!("tests/{}", mode));
10+
11+
let dir = custom_dir.unwrap_or(mode);
12+
config.src_base = PathBuf::from(format!("tests/{}", dir));
1213
config.target_rustcflags = Some("-L target/debug -L target/debug/deps".to_string());
1314
config.clean_rmeta();
1415

@@ -17,10 +18,12 @@ fn run_mode(mode: &'static str) {
1718

1819
#[test]
1920
fn compile_test() {
20-
run_mode("compile-fail");
21-
run_mode("run-pass");
22-
run_mode("ui");
21+
run_mode("compile-fail", None);
22+
run_mode("run-pass", None);
23+
run_mode("ui", None);
2324

2425
#[cfg(not(feature = "stable"))]
25-
run_mode("pretty");
26+
run_mode("pretty", None);
27+
#[cfg(not(feature = "stable"))]
28+
run_mode("ui", Some("nightly"));
2629
}

0 commit comments

Comments
 (0)