about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-03-12 23:34:31 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-03-15 22:56:46 -0700
commit0015cab1fd7b4b47030c808a825bb5594cc1d4ac (patch)
treecf054fdf43843170e6479675e62a29b6213e2ce2
parent17ad504fef35191fe53874bd2fe77ffd14d8e1b9 (diff)
Test fixes and rebase conflicts
This commit switches over the backtrace infrastructure from piggy-backing off
the RUST_LOG environment variable to using the RUST_BACKTRACE environment
variable (logging is now disabled in libstd).
-rw-r--r--mk/crates.mk2
-rw-r--r--src/doc/index.md1
-rw-r--r--src/libflate/lib.rs1
-rw-r--r--src/liblog/lib.rs21
-rw-r--r--src/libnative/io/file_win32.rs2
-rw-r--r--src/librand/lib.rs5
-rw-r--r--src/librustc/lib.rs2
-rw-r--r--src/librustc/metadata/cstore.rs2
-rw-r--r--src/libstd/os.rs11
-rw-r--r--src/libstd/rt/backtrace.rs22
-rw-r--r--src/libstd/rt/unwind.rs2
-rw-r--r--src/libsync/lib.rs4
-rw-r--r--src/libworkcache/lib.rs2
-rw-r--r--src/test/run-pass/backtrace.rs4
-rw-r--r--src/test/run-pass/comm.rs2
-rw-r--r--src/test/run-pass/dead-code-one-arm-if.rs3
-rw-r--r--src/test/run-pass/parse-fail.rs2
17 files changed, 63 insertions, 25 deletions
diff --git a/mk/crates.mk b/mk/crates.mk
index 7c12b4edacb..e3534b6664c 100644
--- a/mk/crates.mk
+++ b/mk/crates.mk
@@ -82,7 +82,7 @@ DEPS_test := std collections getopts serialize term time
 DEPS_time := std serialize
 DEPS_rand := std
 DEPS_url := std collections
-DEPS_workcache := std serialize collections std
+DEPS_workcache := std serialize collections log
 DEPS_log := std sync
 
 TOOL_DEPS_compiletest := test green rustuv getopts
diff --git a/src/doc/index.md b/src/doc/index.md
index 0db15db9c33..5bcfd8e8305 100644
--- a/src/doc/index.md
+++ b/src/doc/index.md
@@ -51,6 +51,7 @@ li {list-style-type: none; }
 * [The `uuid` 128-bit universally unique identifier library](uuid/index.html)
 * [The `url` library](url/index.html)
 * [The `workcache` library](workcache/index.html)
+* [The `log` library](log/index.html)
 
 # Tooling
 
diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs
index 2482359c632..d9f7ae9a856 100644
--- a/src/libflate/lib.rs
+++ b/src/libflate/lib.rs
@@ -18,6 +18,7 @@ Simple compression
 #[crate_type = "rlib"];
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
+#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://static.rust-lang.org/doc/master")];
 #[feature(phase)];
diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs
index 6d2afa2a643..3ff7ee390f1 100644
--- a/src/liblog/lib.rs
+++ b/src/liblog/lib.rs
@@ -12,9 +12,24 @@
 
 Utilities for program-wide and customizable logging
 
-This module is used by the compiler when emitting output for the logging family
-of macros. The methods of this module shouldn't necessarily be used directly,
-but rather through the logging macros defined.
+## Example
+
+```
+#[feature(phase)];
+#[phase(syntax, link)] extern crate log;
+
+fn main() {
+    debug!("this is a debug {}", "message");
+    error!("this is printed by default");
+
+    if log_enabled!(log::INFO) {
+        let x = 3 * 4; // expensive computation
+        info!("the answer was: {}", x);
+    }
+}
+```
+
+## Logging Macros
 
 There are five macros that the logging subsystem uses:
 
diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs
index 8f4f9259ab7..c5ae4f00017 100644
--- a/src/libnative/io/file_win32.rs
+++ b/src/libnative/io/file_win32.rs
@@ -238,7 +238,7 @@ impl Drop for Inner {
         if self.close_on_drop && self.fd > libc::STDERR_FILENO {
             let n = unsafe { libc::close(self.fd) };
             if n != 0 {
-                warn!("error {} when closing file descriptor {}", n, self.fd);
+                println!("error {} when closing file descriptor {}", n, self.fd);
             }
         }
     }
diff --git a/src/librand/lib.rs b/src/librand/lib.rs
index 70e5bb92816..dc4e3e50b65 100644
--- a/src/librand/lib.rs
+++ b/src/librand/lib.rs
@@ -70,9 +70,12 @@ println!("{:?}", tuple_ptr)
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://static.rust-lang.org/doc/master")];
 
-#[feature(macro_rules, managed_boxes)];
+#[feature(macro_rules, managed_boxes, phase)];
 #[allow(deprecated_owned_vector)];
 
+#[cfg(test)]
+#[phase(syntax, link)] extern crate log;
+
 use std::cast;
 use std::kinds::marker;
 use std::local_data;
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 66749cf5403..00cde129d1e 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -410,7 +410,7 @@ pub fn monitor(f: proc()) {
                 let xs = [
                     ~"the compiler hit an unexpected failure path. this is a bug.",
                     "we would appreciate a bug report: " + BUG_REPORT_URL,
-                    ~"run with `RUST_LOG=std::rt::backtrace` for a backtrace",
+                    ~"run with `RUST_BACKTRACE=1` for a backtrace",
                 ];
                 for note in xs.iter() {
                     emitter.emit(None, *note, diagnostic::Note)
diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs
index e6628da89f5..deadfb42904 100644
--- a/src/librustc/metadata/cstore.rs
+++ b/src/librustc/metadata/cstore.rs
@@ -176,7 +176,7 @@ impl CStore {
                 RequireDynamic => src.dylib.clone(),
                 RequireStatic => src.rlib.clone(),
             }))
-            .collect();
+            .collect::<Vec<(ast::CrateNum, Option<Path>)>>();
         libs.sort_by(|&(a, _), &(b, _)| {
             ordering.position_elem(&a).cmp(&ordering.position_elem(&b))
         });
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 0c46a501299..040d5c0e175 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -1155,10 +1155,7 @@ impl MemoryMap {
                 MapAddr(addr_) => { lpAddress = addr_ as LPVOID; },
                 MapFd(fd_) => { fd = fd_; },
                 MapOffset(offset_) => { offset = offset_; },
-                MapNonStandardFlags(f) => {
-                    info!("MemoryMap::new: MapNonStandardFlags used on \
-                           Windows: {}", f)
-                }
+                MapNonStandardFlags(..) => {}
             }
         }
 
@@ -1256,15 +1253,15 @@ impl Drop for MemoryMap {
                 MapVirtual => {
                     if libc::VirtualFree(self.data as *mut c_void, 0,
                                          libc::MEM_RELEASE) == 0 {
-                        error!("VirtualFree failed: {}", errno());
+                        println!("VirtualFree failed: {}", errno());
                     }
                 },
                 MapFile(mapping) => {
                     if libc::UnmapViewOfFile(self.data as LPCVOID) == FALSE {
-                        error!("UnmapViewOfFile failed: {}", errno());
+                        println!("UnmapViewOfFile failed: {}", errno());
                     }
                     if libc::CloseHandle(mapping as HANDLE) == FALSE {
-                        error!("CloseHandle failed: {}", errno());
+                        println!("CloseHandle failed: {}", errno());
                     }
                 }
             }
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index 831f6c73e35..bc75a98e085 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -16,15 +16,31 @@ use from_str::from_str;
 use io::{IoResult, Writer};
 use iter::Iterator;
 use option::{Some, None};
+use os;
 use result::{Ok, Err};
 use str::StrSlice;
+use sync::atomics;
 
 pub use self::imp::write;
 
-// This function is defined in this module so that the way to enable logging of
-// backtraces has the word 'backtrace' in it: std::rt::backtrace.
+// For now logging is turned off by default, and this function checks to see
+// whether the magical environment variable is present to see if it's turned on.
 pub fn log_enabled() -> bool {
-    log_enabled!(::logging::DEBUG)
+    static mut ENABLED: atomics::AtomicInt = atomics::INIT_ATOMIC_INT;
+    unsafe {
+        match ENABLED.load(atomics::SeqCst) {
+            1 => return false,
+            2 => return true,
+            _ => {}
+        }
+    }
+
+    let val = match os::getenv("RUST_BACKTRACE") {
+        Some(..) => 2,
+        None => 1,
+    };
+    unsafe { ENABLED.store(val, atomics::SeqCst); }
+    val == 2
 }
 
 #[cfg(target_word_size = "64")] static HEX_WIDTH: uint = 18;
diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs
index 3a06075ce48..7f54b8b3320 100644
--- a/src/libstd/rt/unwind.rs
+++ b/src/libstd/rt/unwind.rs
@@ -398,6 +398,8 @@ fn begin_unwind_inner(msg: ~Any, file: &'static str, line: uint) -> ! {
                 if backtrace::log_enabled() {
                     let mut err = ::rt::util::Stderr;
                     let _err = backtrace::write(&mut err);
+                } else {
+                    rterrln!("run with `RUST_BACKTRACE=1` to see a backtrace");
                 }
                 unsafe { intrinsics::abort() }
             }
diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs
index 924af6bfd42..d4593318eaf 100644
--- a/src/libsync/lib.rs
+++ b/src/libsync/lib.rs
@@ -21,10 +21,10 @@
       html_root_url = "http://static.rust-lang.org/doc/master")];
 #[feature(phase)];
 
-#[cfg(test)] #[phase(syntax, link)] extern crate log;
-
 #[allow(deprecated_owned_vector)];
 
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
+
 pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, ArcCondvar, CowArc};
 pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode,
                RWLockReadMode, Barrier, one, mutex};
diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs
index ce7557fb2aa..219bb38b3c8 100644
--- a/src/libworkcache/lib.rs
+++ b/src/libworkcache/lib.rs
@@ -15,8 +15,10 @@
 #[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://static.rust-lang.org/doc/master")];
+#[feature(phase)];
 #[allow(deprecated_owned_vector, visible_private_types)];
 
+#[phase(syntax, link)] extern crate log;
 extern crate serialize;
 extern crate collections;
 extern crate sync;
diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs
index 0e3b33a91d4..7252e319372 100644
--- a/src/test/run-pass/backtrace.rs
+++ b/src/test/run-pass/backtrace.rs
@@ -37,11 +37,11 @@ fn double() {
 
 fn runtest(me: &str) {
     let mut env = os::env();
-    match env.iter().position(|&(ref s, _)| "RUST_LOG" == *s) {
+    match env.iter().position(|&(ref s, _)| "RUST_BACKTRACE" == *s) {
         Some(i) => { env.remove(i); }
         None => {}
     }
-    env.push((~"RUST_LOG", ~"std::rt::backtrace"));
+    env.push((~"RUST_BACKTRACE", ~"1"));
 
     // Make sure that the stack trace is printed
     let mut p = Process::configure(ProcessConfig {
diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs
index ae21d53b7e0..03617537c49 100644
--- a/src/test/run-pass/comm.rs
+++ b/src/test/run-pass/comm.rs
@@ -20,7 +20,7 @@ pub fn main() {
 }
 
 fn child(c: &Sender<int>) {
-    error!("sending");
+    println!("sending");
     c.send(10);
     println!("value sent");
 }
diff --git a/src/test/run-pass/dead-code-one-arm-if.rs b/src/test/run-pass/dead-code-one-arm-if.rs
index 23c143445ab..197032b3315 100644
--- a/src/test/run-pass/dead-code-one-arm-if.rs
+++ b/src/test/run-pass/dead-code-one-arm-if.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+// ignore-test #12920
 
 pub fn main() { if 1 == 1 { return; } println!("Paul is dead"); }
diff --git a/src/test/run-pass/parse-fail.rs b/src/test/run-pass/parse-fail.rs
index 45f19a30e86..03f45900238 100644
--- a/src/test/run-pass/parse-fail.rs
+++ b/src/test/run-pass/parse-fail.rs
@@ -10,6 +10,8 @@
 
 #[allow(unreachable_code)];
 
+// ignore-test #12920
+
 fn dont_call_me() { fail!(); println!("{}", 1); }
 
 pub fn main() { }