1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that the CompilerCalls interface to the compiler works.
13 // ignore-cross-compile
15 #![feature(rustc_private, path)]
20 extern crate rustc_driver;
23 use rustc::session::Session;
24 use rustc::session::config::{self, Input};
25 use rustc_driver::{driver, CompilerCalls, Compilation};
26 use syntax::diagnostics;
28 use std::path::PathBuf;
34 impl<'a> CompilerCalls<'a> for TestCalls {
35 fn early_callback(&mut self,
37 _: &diagnostics::registry::Registry)
43 fn late_callback(&mut self,
54 fn some_input(&mut self, input: Input, input_path: Option<PathBuf>)
55 -> (Input, Option<PathBuf>) {
60 fn no_input(&mut self,
65 _: &diagnostics::registry::Registry)
66 -> Option<(Input, Option<PathBuf>)> {
67 panic!("This shouldn't happen");
70 fn build_controller(&mut self, _: &Session) -> driver::CompileController<'a> {
71 panic!("This shouldn't be called");
77 let mut tc = TestCalls { count: 1 };
78 // we should never get use this filename, but lets make sure they are valid args.
79 let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
80 rustc_driver::run_compiler(&args, &mut tc);
81 assert_eq!(tc.count, 30);