rust/src/compiletest/common.rs

157 lines
4.2 KiB
Rust
Raw Normal View History

// 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.
pub use self::Mode::*;
2014-04-15 23:56:39 -05:00
use std::fmt;
2014-11-14 22:52:00 -06:00
use std::str::FromStr;
use std::path::PathBuf;
2014-04-15 23:56:39 -05:00
2015-01-24 15:36:30 -06:00
#[derive(Clone, Copy, PartialEq, Debug)]
2014-04-15 23:56:39 -05:00
pub enum Mode {
CompileFail,
2015-02-11 16:09:30 -06:00
ParseFail,
2014-04-15 23:56:39 -05:00
RunFail,
RunPass,
RunPassValgrind,
2014-04-15 23:56:39 -05:00
Pretty,
DebugInfoGdb,
DebugInfoLldb,
Codegen,
Rustdoc,
2014-04-15 23:56:39 -05:00
}
impl FromStr for Mode {
type Err = ();
fn from_str(s: &str) -> Result<Mode, ()> {
2014-04-15 23:56:39 -05:00
match s {
"compile-fail" => Ok(CompileFail),
2015-02-11 16:09:30 -06:00
"parse-fail" => Ok(ParseFail),
"run-fail" => Ok(RunFail),
"run-pass" => Ok(RunPass),
"run-pass-valgrind" => Ok(RunPassValgrind),
"pretty" => Ok(Pretty),
"debuginfo-lldb" => Ok(DebugInfoLldb),
"debuginfo-gdb" => Ok(DebugInfoGdb),
"codegen" => Ok(Codegen),
"rustdoc" => Ok(Rustdoc),
_ => Err(()),
2014-04-15 23:56:39 -05:00
}
}
}
std: Rename Show/String to Debug/Display This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436
2015-01-20 17:45:07 -06:00
impl fmt::Display for Mode {
2014-04-15 23:56:39 -05:00
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
std: Rename Show/String to Debug/Display This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436
2015-01-20 17:45:07 -06:00
fmt::Display::fmt(match *self {
CompileFail => "compile-fail",
2015-02-11 16:09:30 -06:00
ParseFail => "parse-fail",
RunFail => "run-fail",
RunPass => "run-pass",
RunPassValgrind => "run-pass-valgrind",
Pretty => "pretty",
DebugInfoGdb => "debuginfo-gdb",
DebugInfoLldb => "debuginfo-lldb",
Codegen => "codegen",
Rustdoc => "rustdoc",
}, f)
}
}
#[derive(Clone)]
2014-04-15 23:56:39 -05:00
pub struct Config {
// The library paths required for running the compiler
pub compile_lib_path: String,
// The library paths required for running compiled programs
pub run_lib_path: String,
// The rustc executable
pub rustc_path: PathBuf,
// The rustdoc executable
pub rustdoc_path: PathBuf,
// The python executable
pub python: String,
// The llvm binaries path
pub llvm_bin_path: Option<PathBuf>,
// The valgrind path
pub valgrind_path: Option<String>,
// Whether to fail if we can't run run-pass-valgrind tests under valgrind
// (or, alternatively, to silently run them like regular run-pass tests).
pub force_valgrind: bool,
// The directory containing the tests to run
pub src_base: PathBuf,
// The directory where programs should be built
pub build_base: PathBuf,
// Directory for auxiliary libraries
pub aux_base: PathBuf,
// The name of the stage being built (stage1, etc)
pub stage_id: String,
// The test mode, compile-fail, run-fail, run-pass
2014-04-15 23:56:39 -05:00
pub mode: Mode,
// Run ignored tests
pub run_ignored: bool,
// Only run tests that match this filter
pub filter: Option<String>,
// Write out a parseable log of tests that were run
pub logfile: Option<PathBuf>,
// A command line to prefix program execution with,
// for running under valgrind
pub runtool: Option<String>,
2014-02-11 15:51:08 -06:00
// Flags to pass to the compiler when building for the host
pub host_rustcflags: Option<String>,
2014-02-11 15:51:08 -06:00
// Flags to pass to the compiler when building for the target
pub target_rustcflags: Option<String>,
2013-05-03 20:35:07 -05:00
// Target system to be tested
pub target: String,
// Host triple for the compiler being invoked
pub host: String,
// Version of GDB
pub gdb_version: Option<String>,
// Version of LLDB
pub lldb_version: Option<String>,
// Path to the android tools
pub android_cross_path: PathBuf,
// Extra parameter to run adb on arm-linux-androideabi
pub adb_path: String,
2014-08-01 18:40:21 -05:00
// Extra parameter to run test suite on arm-linux-androideabi
pub adb_test_dir: String,
2013-05-03 20:35:07 -05:00
// status whether android device available or not
pub adb_device_status: bool,
// the path containing LLDB's Python module
pub lldb_python_dir: Option<String>,
// Explain what's going on
pub verbose: bool
}