Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rolling up PRs in the queue #14187

Merged
merged 33 commits into from
May 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cbc31df
std: Move the owned module from core to std
alexcrichton May 13, 2014
24ece07
Allow blocks in const expressions
Kimundi May 4, 2014
de2c48c
Add tests for from_bits.
omasanori May 13, 2014
a390b5d
Replaced ~T by Box<T> in manual
aochagavia May 13, 2014
655487b
Implements Default trait for BigInt and BigUint
Sawyer47 May 13, 2014
5bf268d
Fix #8391
edwardw May 13, 2014
21867fa
check_match: get rid of superfluous clones
edwardw May 13, 2014
74ad023
std, core: Generate unicode.rs using unicode.py
Florob May 12, 2014
2f71b72
core: Use appropriately sized integers for codepoints and bytes
Florob May 12, 2014
8c54d5b
core: Move Hangul decomposition into unicode.rs
Florob May 12, 2014
df802a2
std: Rename str::Normalizations to str::Decompositions
Florob May 12, 2014
ef23fa1
docs: Add a not found page
richo May 12, 2014
0004953
add a line to the example to clarify semantics
May 12, 2014
6d535b5
rustc: Make std_inject valid for pretty-printer
klutzy Apr 16, 2014
7f203b6
pprust: Add parentheses to some Expr
klutzy Apr 16, 2014
cc31bb0
pprust: Fix asm output
klutzy Apr 17, 2014
4675a87
pprust: Print `&&e` instead of `& &e`
klutzy Apr 18, 2014
90d976e
pprust: Remove unnecessary && of `print_tt`
klutzy Apr 18, 2014
bdd360b
libsyntax: Workaround pprust `for` issue
klutzy Apr 17, 2014
0350d8e
test: Add missing `#![feature(managed_boxes)]`
klutzy Apr 17, 2014
96eeda9
compiletest: Modernize typenames
klutzy Apr 16, 2014
ce8c467
compiletest: Test `--pretty expanded`
klutzy Apr 16, 2014
1237530
Touch up and rebase previous commits
alexcrichton May 11, 2014
042c8ae
syntax: Fix printing INT64_MIN
alexcrichton May 11, 2014
ac1a270
syntax: Fix parsing << with closure types
alexcrichton May 11, 2014
560def1
test: Fix a pretty printing test
alexcrichton May 11, 2014
1581fb8
test: Ignore a pretty expanded failing test
alexcrichton May 11, 2014
d92b9ae
syntax: Print suffixed token literals correctly
alexcrichton May 11, 2014
f912005
test: Give a test a bigger stack for pretty printing
alexcrichton May 11, 2014
25ac81e
syntax: Preserve attributes in #[deriving]
alexcrichton May 11, 2014
6878039
syntax: Improve --pretty normal slightly
alexcrichton May 11, 2014
9f7caed
rustllvm: Add LLVMRustArrayType
klutzy May 10, 2014
f09592a
io: Implement process wait timeouts
alexcrichton May 5, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mk/docs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DOCS := index intro tutorial guide-ffi guide-macros guide-lifetimes \
guide-tasks guide-container guide-pointers guide-testing \
guide-runtime complement-bugreport complement-cheatsheet \
complement-lang-faq complement-project-faq rust rustdoc \
guide-unsafe
guide-unsafe not_found

PDF_DOCS := tutorial rust

Expand Down
53 changes: 43 additions & 10 deletions src/compiletest/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,52 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::from_str::FromStr;
use std::fmt;

#[deriving(Clone, Eq)]
pub enum mode {
mode_compile_fail,
mode_run_fail,
mode_run_pass,
mode_pretty,
mode_debug_info_gdb,
mode_debug_info_lldb,
mode_codegen
pub enum Mode {
CompileFail,
RunFail,
RunPass,
Pretty,
DebugInfoGdb,
DebugInfoLldb,
Codegen
}

impl FromStr for Mode {
fn from_str(s: &str) -> Option<Mode> {
match s {
"compile-fail" => Some(CompileFail),
"run-fail" => Some(RunFail),
"run-pass" => Some(RunPass),
"pretty" => Some(Pretty),
"debuginfo-lldb" => Some(DebugInfoLldb),
"debuginfo-gdb" => Some(DebugInfoGdb),
"codegen" => Some(Codegen),
_ => None,
}
}
}

impl fmt::Show for Mode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let msg = match *self {
CompileFail => "compile-fail",
RunFail => "run-fail",
RunPass => "run-pass",
Pretty => "pretty",
DebugInfoGdb => "debuginfo-gdb",
DebugInfoLldb => "debuginfo-lldb",
Codegen => "codegen",
};
write!(f.buf, "{}", msg)
}
}

#[deriving(Clone)]
pub struct config {
pub struct Config {
// The library paths required for running the compiler
pub compile_lib_path: ~str,

Expand Down Expand Up @@ -49,7 +82,7 @@ pub struct config {
pub stage_id: ~str,

// The test mode, compile-fail, run-fail, run-pass
pub mode: mode,
pub mode: Mode,

// Run ignored tests
pub run_ignored: bool,
Expand Down
69 changes: 21 additions & 48 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// we use our own (green) start below; do not link in libnative; issue #13247.
#![no_start]

#![allow(non_camel_case_types)]
#![deny(warnings)]

extern crate test;
Expand All @@ -27,9 +26,10 @@ extern crate rustuv;
use std::os;
use std::io;
use std::io::fs;
use std::from_str::FromStr;
use getopts::{optopt, optflag, reqopt};
use common::{config, mode_run_pass, mode_run_fail, mode_compile_fail, mode_pretty,
mode_debug_info_gdb, mode_debug_info_lldb, mode_codegen, mode};
use common::Config;
use common::{Pretty, DebugInfoGdb, Codegen};
use util::logv;

pub mod procsrv;
Expand All @@ -51,7 +51,7 @@ pub fn main() {
run_tests(&config);
}

pub fn parse_config(args: Vec<~str> ) -> config {
pub fn parse_config(args: Vec<~str> ) -> Config {

let groups : Vec<getopts::OptGroup> =
vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
Path::new(m.opt_str(nm).unwrap())
}

config {
Config {
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
rustc_path: opt_path(matches, "rustc-path"),
Expand All @@ -122,7 +122,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
build_base: opt_path(matches, "build-base"),
aux_base: opt_path(matches, "aux-base"),
stage_id: matches.opt_str("stage-id").unwrap(),
mode: str_mode(matches.opt_str("mode").unwrap()),
mode: FromStr::from_str(matches.opt_str("mode").unwrap()).expect("invalid mode"),
run_ignored: matches.opt_present("ignored"),
filter:
if !matches.free.is_empty() {
Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
}
}

pub fn log_config(config: &config) {
pub fn log_config(config: &Config) {
let c = config;
logv(c, format!("configuration:"));
logv(c, format!("compile_lib_path: {}", config.compile_lib_path));
Expand All @@ -164,7 +164,7 @@ pub fn log_config(config: &config) {
logv(c, format!("src_base: {}", config.src_base.display()));
logv(c, format!("build_base: {}", config.build_base.display()));
logv(c, format!("stage_id: {}", config.stage_id));
logv(c, format!("mode: {}", mode_str(config.mode)));
logv(c, format!("mode: {}", config.mode));
logv(c, format!("run_ignored: {}", config.run_ignored));
logv(c, format!("filter: {}", opt_str(&config.filter)));
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
Expand Down Expand Up @@ -198,35 +198,10 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
match maybestr { None => "(none)".to_owned(), Some(s) => { s } }
}

pub fn str_mode(s: ~str) -> mode {
match s.as_slice() {
"compile-fail" => mode_compile_fail,
"run-fail" => mode_run_fail,
"run-pass" => mode_run_pass,
"pretty" => mode_pretty,
"debuginfo-gdb" => mode_debug_info_gdb,
"debuginfo-lldb" => mode_debug_info_lldb,
"codegen" => mode_codegen,
s => fail!("invalid mode: " + s)
}
}

pub fn mode_str(mode: mode) -> ~str {
match mode {
mode_compile_fail => "compile-fail".to_owned(),
mode_run_fail => "run-fail".to_owned(),
mode_run_pass => "run-pass".to_owned(),
mode_pretty => "pretty".to_owned(),
mode_debug_info_gdb => "debuginfo-gdb".to_owned(),
mode_debug_info_lldb => "debuginfo-lldb".to_owned(),
mode_codegen => "codegen".to_owned(),
}
}

pub fn run_tests(config: &config) {
pub fn run_tests(config: &Config) {
if config.target == "arm-linux-androideabi".to_owned() {
match config.mode{
mode_debug_info_gdb => {
match config.mode {
DebugInfoGdb => {
println!("arm-linux-androideabi debug-info \
test uses tcp 5039 port. please reserve it");
}
Expand Down Expand Up @@ -255,7 +230,7 @@ pub fn run_tests(config: &config) {
}
}

pub fn test_opts(config: &config) -> test::TestOpts {
pub fn test_opts(config: &Config) -> test::TestOpts {
test::TestOpts {
filter: config.filter.clone(),
run_ignored: config.run_ignored,
Expand All @@ -270,7 +245,7 @@ pub fn test_opts(config: &config) -> test::TestOpts {
}
}

pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
debug!("making tests from {}",
config.src_base.display());
let mut tests = Vec::new();
Expand All @@ -281,7 +256,7 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
if is_test(config, &file) {
let t = make_test(config, &file, || {
match config.mode {
mode_codegen => make_metrics_test_closure(config, &file),
Codegen => make_metrics_test_closure(config, &file),
_ => make_test_closure(config, &file)
}
});
Expand All @@ -291,11 +266,11 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
tests
}

pub fn is_test(config: &config, testfile: &Path) -> bool {
pub fn is_test(config: &Config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
mode_pretty => vec!(".rs".to_owned()),
Pretty => vec!(".rs".to_owned()),
_ => vec!(".rc".to_owned(), ".rs".to_owned())
};
let invalid_prefixes = vec!(".".to_owned(), "#".to_owned(), "~".to_owned());
Expand All @@ -314,7 +289,7 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
return valid;
}

pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn)
pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
-> test::TestDescAndFn {
test::TestDescAndFn {
desc: test::TestDesc {
Expand All @@ -326,7 +301,7 @@ pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn)
}
}

pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {

// Try to elide redundant long paths
fn shorten(path: &Path) -> ~str {
Expand All @@ -336,19 +311,17 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
format!("{}/{}", dir.unwrap_or(""), filename.unwrap_or(""))
}

test::DynTestName(format!("[{}] {}",
mode_str(config.mode),
shorten(testfile)))
test::DynTestName(format!("[{}] {}", config.mode, shorten(testfile)))
}

pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
let config = (*config).clone();
// FIXME (#9639): This needs to handle non-utf8 paths
let testfile = testfile.as_str().unwrap().to_owned();
test::DynTestFn(proc() { runtest::run(config, testfile) })
}

pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
let config = (*config).clone();
// FIXME (#9639): This needs to handle non-utf8 paths
let testfile = testfile.as_str().unwrap().to_owned();
Expand Down
22 changes: 17 additions & 5 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use common::config;
use common::Config;
use common;
use util;

Expand All @@ -34,6 +34,8 @@ pub struct TestProps {
pub check_stdout: bool,
// Don't force a --crate-type=dylib flag on the command line
pub no_prefer_dynamic: bool,
// Don't run --pretty expanded when running pretty printing tests
pub no_pretty_expanded: bool,
}

// Load any test directives embedded in the file
Expand All @@ -48,6 +50,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut force_host = false;
let mut check_stdout = false;
let mut no_prefer_dynamic = false;
let mut no_pretty_expanded = false;
iter_header(testfile, |ln| {
match parse_error_pattern(ln) {
Some(ep) => error_patterns.push(ep),
Expand Down Expand Up @@ -78,6 +81,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
no_prefer_dynamic = parse_no_prefer_dynamic(ln);
}

if !no_pretty_expanded {
no_pretty_expanded = parse_no_pretty_expanded(ln);
}

match parse_aux_build(ln) {
Some(ab) => { aux_builds.push(ab); }
None => {}
Expand Down Expand Up @@ -107,22 +114,23 @@ pub fn load_props(testfile: &Path) -> TestProps {
force_host: force_host,
check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic,
no_pretty_expanded: no_pretty_expanded,
}
}

pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
fn ignore_target(config: &config) -> ~str {
pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
fn ignore_target(config: &Config) -> ~str {
"ignore-".to_owned() + util::get_os(config.target)
}
fn ignore_stage(config: &config) -> ~str {
fn ignore_stage(config: &Config) -> ~str {
"ignore-".to_owned() + config.stage_id.split('-').next().unwrap()
}

let val = iter_header(testfile, |ln| {
if parse_name_directive(ln, "ignore-test") { false }
else if parse_name_directive(ln, ignore_target(config)) { false }
else if parse_name_directive(ln, ignore_stage(config)) { false }
else if config.mode == common::mode_pretty &&
else if config.mode == common::Pretty &&
parse_name_directive(ln, "ignore-pretty") { false }
else if config.target != config.host &&
parse_name_directive(ln, "ignore-cross-compile") { false }
Expand Down Expand Up @@ -180,6 +188,10 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
parse_name_directive(line, "no-prefer-dynamic")
}

fn parse_no_pretty_expanded(line: &str) -> bool {
parse_name_directive(line, "no-pretty-expanded")
}

fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
parse_name_value_directive(line, "exec-env".to_owned()).map(|nv| {
// nv is either FOO or FOO=BAR
Expand Down
7 changes: 4 additions & 3 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ pub fn run(lib_path: &str,
input: Option<~str>) -> Option<Result> {

let env = env.clone().append(target_env(lib_path, prog).as_slice());
let mut opt_process = Process::configure(ProcessConfig {
let opt_process = Process::configure(ProcessConfig {
program: prog,
args: args,
env: Some(env.as_slice()),
.. ProcessConfig::new()
});

match opt_process {
Ok(ref mut process) => {
Ok(mut process) => {
for input in input.iter() {
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
}
let ProcessOutput { status, output, error } = process.wait_with_output();
let ProcessOutput { status, output, error } =
process.wait_with_output().unwrap();

Some(Result {
status: status,
Expand Down
Loading