diff --git a/src/etc/check-summary.py b/src/etc/check-summary.py index de777c997299d..dbff82d2b6bbb 100755 --- a/src/etc/check-summary.py +++ b/src/etc/check-summary.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # xfail-license +import glob import sys if __name__ == '__main__': @@ -24,7 +25,8 @@ def summarise(fname): def count(t): return sum(map(lambda (f, s): len(s.get(t, [])), summaries)) logfiles = sys.argv[1:] - map(summarise, logfiles) + for files in map(glob.glob, logfiles): + map(summarise, files) ok = count('ok') failed = count('failed') ignored = count('ignored') diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index f8e7a28d27708..fd8c620dc4e96 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -160,8 +160,24 @@ fn make_rustpkg_target_lib_path(dir: &Path, } pub fn get_or_default_sysroot() -> Path { - match os::self_exe_path() { - option::Some(p) => { let mut p = p; p.pop(); p } + // Follow symlinks. If the resolved path is relative, make it absolute. + fn canonicalize(path: Option) -> Option { + path.and_then(|mut path| + match io::io_error::cond.trap(|_| ()).inside(|| fs::readlink(&path)) { + Some(canon) => { + if canon.is_absolute() { + Some(canon) + } else { + path.pop(); + Some(path.join(canon)) + } + }, + None => Some(path), + }) + } + + match canonicalize(os::self_exe_name()) { + option::Some(p) => { let mut p = p; p.pop(); p.pop(); p } option::None => fail!("can't determine value for sysroot") } } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 93762a3cdd5c7..1b55427fc2dbc 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -337,9 +337,9 @@ pub fn dll_filename(base: &str) -> ~str { format!("{}{}{}", consts::DLL_PREFIX, base, consts::DLL_SUFFIX) } -/// Optionally returns the filesystem path to the current executable which is +/// Optionally returns the filesystem path of the current executable which is /// running. If any failure occurs, None is returned. -pub fn self_exe_path() -> Option { +pub fn self_exe_name() -> Option { #[cfg(target_os = "freebsd")] fn load_self() -> Option<~[u8]> { @@ -402,7 +402,14 @@ pub fn self_exe_path() -> Option { } } - load_self().and_then(|path| Path::new_opt(path).map(|mut p| { p.pop(); p })) + load_self().and_then(Path::new_opt) +} + +/// Optionally returns the filesystem path to the current executable which is +/// running. Like self_exe_name() but without the binary's name. +/// If any failure occurs, None is returned. +pub fn self_exe_path() -> Option { + self_exe_name().map(|mut p| { p.pop(); p }) } /** @@ -1310,6 +1317,17 @@ mod tests { assert_eq!(getenv(n), option::Some(s)); } + #[test] + fn test_self_exe_name() { + let path = os::self_exe_name(); + assert!(path.is_some()); + let path = path.unwrap(); + debug!("{:?}", path.clone()); + + // Hard to test this function + assert!(path.is_absolute()); + } + #[test] fn test_self_exe_path() { let path = os::self_exe_path();