about summary refs log tree commit diff
path: root/src/test/run-pass-fulldeps
diff options
context:
space:
mode:
authorEvgenii Pashkin <eapashkin@gmail.com>2018-06-08 07:09:19 +0300
committerEvgenii Pashkin <eapashkin@gmail.com>2018-06-08 18:05:01 +0300
commitcb5e9731bb17eb7ecd81c72b09b036e5420d3ea7 (patch)
treeef9bc1c27df372575f61bbbb9c681b304be66c29 /src/test/run-pass-fulldeps
parentb417701ac118d4864e3bd07b700f3c8af724b199 (diff)
downloadrust-cb5e9731bb17eb7ecd81c72b09b036e5420d3ea7.tar.gz
rust-cb5e9731bb17eb7ecd81c72b09b036e5420d3ea7.zip
Add test for libsyntax with canonicalized base path
Diffstat (limited to 'src/test/run-pass-fulldeps')
-rw-r--r--src/test/run-pass-fulldeps/mod_dir_path_canonicalized.rs38
-rw-r--r--src/test/run-pass-fulldeps/mod_dir_simple/compiletest-ignore-dir0
-rw-r--r--src/test/run-pass-fulldeps/mod_dir_simple/test.rs11
3 files changed, 49 insertions, 0 deletions
diff --git a/src/test/run-pass-fulldeps/mod_dir_path_canonicalized.rs b/src/test/run-pass-fulldeps/mod_dir_path_canonicalized.rs
new file mode 100644
index 00000000000..3bf50652113
--- /dev/null
+++ b/src/test/run-pass-fulldeps/mod_dir_path_canonicalized.rs
@@ -0,0 +1,38 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Testing that a libsyntax can parse modules with canonicalized base path
+// ignore-cross-compile
+
+#![feature(rustc_private)]
+
+extern crate syntax;
+
+use std::path::Path;
+use syntax::codemap::FilePathMapping;
+use syntax::parse::{self, ParseSess};
+
+#[path = "mod_dir_simple/test.rs"]
+mod gravy;
+
+pub fn main() {
+    syntax::with_globals(|| parse());
+
+    assert_eq!(gravy::foo(), 10);
+}
+
+fn parse() {
+    let parse_session = ParseSess::new(FilePathMapping::empty());
+
+    let path = Path::new(file!());
+    let path = path.canonicalize().unwrap();
+    let mut parser = parse::new_parser_from_file(&parse_session, &path);
+    let _ = parser.parse_crate_mod();
+}
diff --git a/src/test/run-pass-fulldeps/mod_dir_simple/compiletest-ignore-dir b/src/test/run-pass-fulldeps/mod_dir_simple/compiletest-ignore-dir
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/src/test/run-pass-fulldeps/mod_dir_simple/compiletest-ignore-dir
diff --git a/src/test/run-pass-fulldeps/mod_dir_simple/test.rs b/src/test/run-pass-fulldeps/mod_dir_simple/test.rs
new file mode 100644
index 00000000000..58c1beee3be
--- /dev/null
+++ b/src/test/run-pass-fulldeps/mod_dir_simple/test.rs
@@ -0,0 +1,11 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub fn foo() -> isize { 10 }