diff options
| author | Luqman Aden <me@luqman.ca> | 2014-07-22 16:39:10 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-07-29 15:43:12 -0700 |
| commit | c2ac7fde0b4715ff87467be91d57d5afd49978a2 (patch) | |
| tree | 5ef767b49840ae298274c6d3a21d2d15d36cd5ba /src/compiletest | |
| parent | 445340771d8ead72709bbbaffc0b576389985264 (diff) | |
| download | rust-c2ac7fde0b4715ff87467be91d57d5afd49978a2.tar.gz rust-c2ac7fde0b4715ff87467be91d57d5afd49978a2.zip | |
Add pretty=typed test support to compiletest and add a test for fixed size arrays.
Diffstat (limited to 'src/compiletest')
| -rw-r--r-- | src/compiletest/header.rs | 24 | ||||
| -rw-r--r-- | src/compiletest/runtest.rs | 5 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 6ef2a52086e..aa96f3e2727 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -36,6 +36,10 @@ pub struct TestProps { pub no_prefer_dynamic: bool, // Don't run --pretty expanded when running pretty printing tests pub no_pretty_expanded: bool, + // Which pretty mode are we testing with, default to 'normal' + pub pretty_mode: String, + // Only compare pretty output and don't try compiling + pub pretty_compare_only: bool, } // Load any test directives embedded in the file @@ -51,6 +55,8 @@ pub fn load_props(testfile: &Path) -> TestProps { let mut check_stdout = false; let mut no_prefer_dynamic = false; let mut no_pretty_expanded = false; + let mut pretty_mode = None; + let mut pretty_compare_only = false; iter_header(testfile, |ln| { match parse_error_pattern(ln) { Some(ep) => error_patterns.push(ep), @@ -85,6 +91,14 @@ pub fn load_props(testfile: &Path) -> TestProps { no_pretty_expanded = parse_no_pretty_expanded(ln); } + if pretty_mode.is_none() { + pretty_mode = parse_pretty_mode(ln); + } + + if !pretty_compare_only { + pretty_compare_only = parse_pretty_compare_only(ln); + } + match parse_aux_build(ln) { Some(ab) => { aux_builds.push(ab); } None => {} @@ -115,6 +129,8 @@ pub fn load_props(testfile: &Path) -> TestProps { check_stdout: check_stdout, no_prefer_dynamic: no_prefer_dynamic, no_pretty_expanded: no_pretty_expanded, + pretty_mode: pretty_mode.unwrap_or("normal".to_string()), + pretty_compare_only: pretty_compare_only } } @@ -205,6 +221,14 @@ fn parse_no_pretty_expanded(line: &str) -> bool { parse_name_directive(line, "no-pretty-expanded") } +fn parse_pretty_mode(line: &str) -> Option<String> { + parse_name_value_directive(line, "pretty-mode") +} + +fn parse_pretty_compare_only(line: &str) -> bool { + parse_name_directive(line, "pretty-compare-only") +} + fn parse_exec_env(line: &str) -> Option<(String, String)> { parse_name_value_directive(line, "exec-env").map(|nv| { // nv is either FOO or FOO=BAR diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 6720b9a530f..b8a55fb234d 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -168,7 +168,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) { props, testfile, srcs[round].to_string(), - "normal"); + props.pretty_mode.as_slice()); if !proc_res.status.success() { fatal_proc_rec(format!("pretty-printing failed in round {}", @@ -200,6 +200,9 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) { compare_source(expected.as_slice(), actual.as_slice()); + // If we're only making sure that the output matches then just stop here + if props.pretty_compare_only { return; } + // Finally, let's make sure it actually appears to remain valid code let proc_res = typecheck_source(config, props, testfile, actual); |
