Fixes #404: Use log.rs and a file-per-thread logger instead of the dbg! macro;

This commit is contained in:
Benjamin Bouvier
2018-07-20 19:14:04 +02:00
committed by Dan Gohman
parent 60c2cad06e
commit a044f58cea
27 changed files with 123 additions and 221 deletions

View File

@@ -11,5 +11,7 @@ publish = false
[dependencies]
cranelift-codegen = { path = "../codegen", version = "0.18.1" }
cranelift-reader = { path = "../reader", version = "0.18.1" }
file-per-thread-logger = "0.1.1"
filecheck = "0.3.0"
num_cpus = "1.8.0"
log = "0.4.3"

View File

@@ -3,7 +3,9 @@
//! This module provides the `ConcurrentRunner` struct which uses a pool of threads to run tests
//! concurrently.
use cranelift_codegen::dbg::LOG_FILENAME_PREFIX;
use cranelift_codegen::timing;
use file_per_thread_logger;
use num_cpus;
use std::panic::catch_unwind;
use std::path::{Path, PathBuf};
@@ -100,6 +102,7 @@ fn heartbeat_thread(replies: Sender<Reply>) -> thread::JoinHandle<()> {
thread::Builder::new()
.name("heartbeat".to_string())
.spawn(move || {
file_per_thread_logger::initialize(LOG_FILENAME_PREFIX);
while replies.send(Reply::Tick).is_ok() {
thread::sleep(Duration::from_secs(1));
}
@@ -116,6 +119,7 @@ fn worker_thread(
thread::Builder::new()
.name(format!("worker #{}", thread_num))
.spawn(move || {
file_per_thread_logger::initialize(LOG_FILENAME_PREFIX);
loop {
// Lock the mutex only long enough to extract a request.
let Request(jobid, path) = match requests.lock().unwrap().recv() {
@@ -140,7 +144,7 @@ fn worker_thread(
});
if let Err(ref msg) = result {
dbg!("FAIL: {}", msg);
error!("FAIL: {}", msg);
}
replies.send(Reply::Done { jobid, result }).unwrap();

View File

@@ -18,11 +18,13 @@
)
)]
#[macro_use(dbg)]
extern crate cranelift_codegen;
extern crate file_per_thread_logger;
extern crate cranelift_reader;
extern crate filecheck;
extern crate num_cpus;
#[macro_use]
extern crate log;
use cranelift_reader::TestCommand;
use runner::TestRunner;

View File

@@ -29,7 +29,7 @@ fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
/// If running this test causes a panic, it will propagate as normal.
pub fn run(path: &Path) -> TestResult {
let _tt = timing::process_file();
dbg!("---\nFile: {}", path.to_string_lossy());
info!("---\nFile: {}", path.to_string_lossy());
let started = time::Instant::now();
let buffer = read_to_string(path).map_err(|e| e.to_string())?;
let testfile = parse_test(&buffer).map_err(|e| e.to_string())?;
@@ -122,7 +122,7 @@ fn run_one_test<'a>(
) -> SubtestResult<()> {
let (test, flags, isa) = tuple;
let name = format!("{}({})", test.name(), func.name);
dbg!("Test: {} {}", name, isa.map_or("-", TargetIsa::name));
info!("Test: {} {}", name, isa.map_or("-", TargetIsa::name));
context.flags = flags;
context.isa = isa;

View File

@@ -41,7 +41,7 @@ impl SubTest for TestCompile {
.compile(isa)
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
dbg!(
info!(
"Generated {} bytes of code:\n{}",
code_size,
comp_ctx.func.display(isa)