Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a proc-macro UI test example to the test project #171

Merged
merged 1 commit into from Sep 10, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,12 @@
// no-prefer-dynamic

#![crate_type = "proc-macro"]

extern crate proc_macro;

use proc_macro::{TokenStream};

#[proc_macro]
pub fn macro_test(input_stream: TokenStream) -> TokenStream {
TokenStream::new()
}
@@ -0,0 +1,13 @@
// run-pass
// aux-build:simple_proc_macro.rs

#![feature(proc_macro_hygiene)]

extern crate simple_proc_macro;
use simple_proc_macro::macro_test;

fn main() {
println!("hi");
macro_test!(2);
}

@@ -2,13 +2,14 @@ extern crate compiletest_rs as compiletest;

use std::path::PathBuf;

fn run_mode(mode: &'static str) {

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

config.mode = cfg_mode;
config.src_base = PathBuf::from(format!("tests/{}", mode));

let dir = custom_dir.unwrap_or(mode);
config.src_base = PathBuf::from(format!("tests/{}", dir));
config.target_rustcflags = Some("-L target/debug -L target/debug/deps".to_string());
config.clean_rmeta();

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

#[test]
fn compile_test() {
run_mode("compile-fail");
run_mode("run-pass");
run_mode("ui");
run_mode("compile-fail", None);
run_mode("run-pass", None);
run_mode("ui", None);

#[cfg(not(feature = "stable"))]
run_mode("pretty");
run_mode("pretty", None);
#[cfg(not(feature = "stable"))]
run_mode("ui", Some("nightly"));
}