2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
2018-06-07 23:09:19 -05:00
|
|
|
// Testing that a libsyntax can parse modules with canonicalized base path
|
|
|
|
// ignore-cross-compile
|
|
|
|
|
|
|
|
#![feature(rustc_private)]
|
|
|
|
|
|
|
|
extern crate syntax;
|
2019-10-10 03:26:10 -05:00
|
|
|
extern crate syntax_expand;
|
2018-06-07 23:09:19 -05:00
|
|
|
|
|
|
|
use std::path::Path;
|
2019-10-14 03:08:26 -05:00
|
|
|
use syntax::sess::ParseSess;
|
2018-08-18 05:14:03 -05:00
|
|
|
use syntax::source_map::FilePathMapping;
|
2019-10-10 03:26:10 -05:00
|
|
|
use syntax::parse::new_parser_from_file;
|
|
|
|
use syntax_expand::config::process_configure_mod;
|
2018-06-07 23:09:19 -05:00
|
|
|
|
|
|
|
#[path = "mod_dir_simple/test.rs"]
|
|
|
|
mod gravy;
|
|
|
|
|
|
|
|
pub fn main() {
|
2019-04-05 17:15:49 -05:00
|
|
|
syntax::with_default_globals(|| parse());
|
2018-06-07 23:09:19 -05:00
|
|
|
|
|
|
|
assert_eq!(gravy::foo(), 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse() {
|
2019-10-10 03:26:10 -05:00
|
|
|
let parse_session = ParseSess::new(FilePathMapping::empty(), process_configure_mod);
|
2018-06-07 23:09:19 -05:00
|
|
|
|
|
|
|
let path = Path::new(file!());
|
|
|
|
let path = path.canonicalize().unwrap();
|
2019-10-10 03:26:10 -05:00
|
|
|
let mut parser = new_parser_from_file(&parse_session, &path);
|
2018-06-07 23:09:19 -05:00
|
|
|
let _ = parser.parse_crate_mod();
|
|
|
|
}
|