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, errors}
;
28 use std
::path
::PathBuf
;
34 impl<'a
> CompilerCalls
<'a
> for TestCalls
{
35 fn early_callback(&mut self,
37 _
: &diagnostics
::registry
::Registry
,
38 _
: config
::ErrorOutputType
)
44 fn late_callback(&mut self,
55 fn some_input(&mut self, input
: Input
, input_path
: Option
<PathBuf
>)
56 -> (Input
, Option
<PathBuf
>) {
61 fn no_input(&mut self,
66 _
: &diagnostics
::registry
::Registry
)
67 -> Option
<(Input
, Option
<PathBuf
>)> {
68 panic
!("This shouldn't happen");
71 fn build_controller(&mut self, _
: &Session
) -> driver
::CompileController
<'a
> {
72 panic
!("This shouldn't be called");
78 let mut tc
= TestCalls { count: 1 }
;
79 // we should never get use this filename, but lets make sure they are valid args.
80 let args
= vec
!["compiler-calls".to_string(), "foo.rs".to_string()];
81 rustc_driver
::run_compiler(&args
, &mut tc
);
82 assert_eq
!(tc
.count
, 30);