mirror of https://github.com/rust-lang/rust.git
test: Make a dedicated testsuite for rustfix
This commit adds a dedicated mode to compiletest for running rustfix tests, adding a new `src/test/rustfix` directory which will execute all tests as a "rustfix" test, namely requiring that a `*.fixed` is next to the main file which is the result of the rustfix project's application of fixes. The `rustfix` crate is pulled in to actually perform the fixing, and the rustfix compiletest mode will assert a few properties about the fixing: * The expected fixed output must be the same as rustc's output suggestions applied to the original code. * The fixed code must compile successfully * The fixed code must have no further diagnostics emitted about it
This commit is contained in:
parent
b264504403
commit
fa9e55faeb
|
@ -394,6 +394,7 @@ dependencies = [
|
||||||
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rustfix 0.1.0 (git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion)",
|
||||||
"serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2234,6 +2235,19 @@ dependencies = [
|
||||||
"rustdoc 0.0.0",
|
"rustdoc 0.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustfix"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion#571b43a1a1777561ddd7a41b37512bf0e3452c1a"
|
||||||
|
dependencies = [
|
||||||
|
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_derive 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustfmt-nightly"
|
name = "rustfmt-nightly"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
|
@ -3146,6 +3160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum rustc-ap-syntax_pos 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55793c2a775230c42661194c48d44b35d4c8439d79ad8528e56651e854c48c63"
|
"checksum rustc-ap-syntax_pos 113.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55793c2a775230c42661194c48d44b35d4c8439d79ad8528e56651e854c48c63"
|
||||||
"checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb"
|
"checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb"
|
||||||
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
||||||
|
"checksum rustfix 0.1.0 (git+https://github.com/rust-lang-nursery/rustfix?branch=apply_suggestion)" = "<none>"
|
||||||
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
|
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
|
||||||
"checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637"
|
"checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637"
|
||||||
"checksum schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "85fd9df495640643ad2d00443b3d78aae69802ad488debab4f1dd52fc1806ade"
|
"checksum schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "85fd9df495640643ad2d00443b3d78aae69802ad488debab4f1dd52fc1806ade"
|
||||||
|
|
|
@ -326,7 +326,7 @@ impl<'a> Builder<'a> {
|
||||||
test::TheBook, test::UnstableBook, test::RustcBook,
|
test::TheBook, test::UnstableBook, test::RustcBook,
|
||||||
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
|
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
|
||||||
// Run run-make last, since these won't pass without make on Windows
|
// Run run-make last, since these won't pass without make on Windows
|
||||||
test::RunMake, test::RustdocUi),
|
test::RunMake, test::RustdocUi, test::Rustfix),
|
||||||
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
|
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
|
||||||
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
|
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
|
||||||
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,
|
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,
|
||||||
|
|
|
@ -716,6 +716,12 @@ default_test!(RunFail {
|
||||||
suite: "run-fail"
|
suite: "run-fail"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
default_test!(Rustfix {
|
||||||
|
path: "src/test/rustfix",
|
||||||
|
mode: "rustfix",
|
||||||
|
suite: "rustfix"
|
||||||
|
});
|
||||||
|
|
||||||
default_test!(RunPassValgrind {
|
default_test!(RunPassValgrind {
|
||||||
path: "src/test/run-pass-valgrind",
|
path: "src/test/run-pass-valgrind",
|
||||||
mode: "run-pass-valgrind",
|
mode: "run-pass-valgrind",
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
// Point at the captured immutable outer variable
|
||||||
|
|
||||||
|
fn foo(mut f: Box<FnMut()>) {
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut y = true;
|
||||||
|
foo(Box::new(move || y = false) as Box<_>);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
// Point at the captured immutable outer variable
|
||||||
|
|
||||||
|
fn foo(mut f: Box<FnMut()>) {
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let y = true;
|
||||||
|
foo(Box::new(move || y = false) as Box<_>);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
// compile-flags:--crate-type lib
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
// compile-flags:--crate-type lib
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
// compile-flags:--crate-type lib
|
||||||
|
fn foo() {}
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
#[no_mangle] pub static RAH: usize = 5;
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
#[no_mangle] pub const RAH: usize = 5;
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
extern crate std as other_std;
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
extern crate std;
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
#![allow(unused)]
|
||||||
|
|
||||||
|
fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
|
||||||
|
and_yet + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let behold: isize = 2;
|
||||||
|
let with_tears: usize = 3;
|
||||||
|
light_flows_our_war_of_mocking_words(&(behold as usize));
|
||||||
|
light_flows_our_war_of_mocking_words(&(with_tears + 4));
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
#![allow(unused)]
|
||||||
|
|
||||||
|
fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
|
||||||
|
and_yet + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let behold: isize = 2;
|
||||||
|
let with_tears: usize = 3;
|
||||||
|
light_flows_our_war_of_mocking_words(behold as usize);
|
||||||
|
light_flows_our_war_of_mocking_words(with_tears + 4);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
match &Some(3) {
|
||||||
|
&None => 1,
|
||||||
|
&Some(2) => { 3 }
|
||||||
|
_ => 2
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
match &Some(3) {
|
||||||
|
&None => 1
|
||||||
|
&Some(2) => { 3 }
|
||||||
|
_ => 2
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("●●");
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!('●●');
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// compile-flags: -Z parse-only
|
||||||
|
|
||||||
|
fn main () {
|
||||||
|
((1, (2, 3)).1).1;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2012 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.
|
||||||
|
|
||||||
|
// compile-flags: -Z parse-only
|
||||||
|
|
||||||
|
fn main () {
|
||||||
|
(1, (2, 3)).1.1;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright 2015 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.
|
||||||
|
|
||||||
|
# A script to update the references for all tests. The idea is that
|
||||||
|
# you do a run, which will generate files in the build directory
|
||||||
|
# containing the (normalized) actual output of the compiler. You then
|
||||||
|
# run this script, which will copy those files over. If you find
|
||||||
|
# yourself manually editing a foo.stderr file, you're doing it wrong.
|
||||||
|
#
|
||||||
|
# See all `update-references.sh`, if you just want to update a single test.
|
||||||
|
|
||||||
|
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" != "" ]]; then
|
||||||
|
echo "usage: $0 <build-directory>"
|
||||||
|
echo ""
|
||||||
|
echo "For example:"
|
||||||
|
echo " $0 ../../../build/x86_64-apple-darwin/test/rustfix"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_DIR=$PWD/$1
|
||||||
|
MY_DIR=$(dirname $0)
|
||||||
|
cd $MY_DIR
|
||||||
|
find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright 2015 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.
|
||||||
|
|
||||||
|
# A script to update the references for particular tests. The idea is
|
||||||
|
# that you do a run, which will generate files in the build directory
|
||||||
|
# containing the (normalized) actual output of the compiler. This
|
||||||
|
# script will then copy that output and replace the "expected output"
|
||||||
|
# files. You can then commit the changes.
|
||||||
|
#
|
||||||
|
# If you find yourself manually editing a foo.stderr file, you're
|
||||||
|
# doing it wrong.
|
||||||
|
|
||||||
|
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
|
||||||
|
echo "usage: $0 <build-directory> <relative-path-to-rs-files>"
|
||||||
|
echo ""
|
||||||
|
echo "For example:"
|
||||||
|
echo " $0 ../../../build/x86_64-apple-darwin/test/rustfix *.rs */*.rs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
MYDIR=$(dirname $0)
|
||||||
|
|
||||||
|
BUILD_DIR="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
while [[ "$1" != "" ]]; do
|
||||||
|
for OUT_NAME in $BUILD_DIR/${1%.rs}.*fixed; do
|
||||||
|
OUT_BASE=`basename "$OUT_NAME"`
|
||||||
|
if ! (diff $OUT_NAME $MYDIR/$OUT_BASE >& /dev/null); then
|
||||||
|
echo updating $MYDIR/$OUT_BASE
|
||||||
|
cp $OUT_NAME $MYDIR
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
done
|
|
@ -32,6 +32,7 @@ pub enum Mode {
|
||||||
RunMake,
|
RunMake,
|
||||||
Ui,
|
Ui,
|
||||||
MirOpt,
|
MirOpt,
|
||||||
|
Rustfix,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mode {
|
impl Mode {
|
||||||
|
@ -67,6 +68,7 @@ impl FromStr for Mode {
|
||||||
"run-make" => Ok(RunMake),
|
"run-make" => Ok(RunMake),
|
||||||
"ui" => Ok(Ui),
|
"ui" => Ok(Ui),
|
||||||
"mir-opt" => Ok(MirOpt),
|
"mir-opt" => Ok(MirOpt),
|
||||||
|
"rustfix" => Ok(Rustfix),
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,24 +76,25 @@ impl FromStr for Mode {
|
||||||
|
|
||||||
impl fmt::Display for Mode {
|
impl fmt::Display for Mode {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
fmt::Display::fmt(match *self {
|
let s = match *self {
|
||||||
CompileFail => "compile-fail",
|
CompileFail => "compile-fail",
|
||||||
ParseFail => "parse-fail",
|
ParseFail => "parse-fail",
|
||||||
RunFail => "run-fail",
|
RunFail => "run-fail",
|
||||||
RunPass => "run-pass",
|
RunPass => "run-pass",
|
||||||
RunPassValgrind => "run-pass-valgrind",
|
RunPassValgrind => "run-pass-valgrind",
|
||||||
Pretty => "pretty",
|
Pretty => "pretty",
|
||||||
DebugInfoGdb => "debuginfo-gdb",
|
DebugInfoGdb => "debuginfo-gdb",
|
||||||
DebugInfoLldb => "debuginfo-lldb",
|
DebugInfoLldb => "debuginfo-lldb",
|
||||||
Codegen => "codegen",
|
Codegen => "codegen",
|
||||||
Rustdoc => "rustdoc",
|
Rustdoc => "rustdoc",
|
||||||
CodegenUnits => "codegen-units",
|
CodegenUnits => "codegen-units",
|
||||||
Incremental => "incremental",
|
Incremental => "incremental",
|
||||||
RunMake => "run-make",
|
RunMake => "run-make",
|
||||||
Ui => "ui",
|
Ui => "ui",
|
||||||
MirOpt => "mir-opt",
|
MirOpt => "mir-opt",
|
||||||
},
|
Rustfix => "rustfix",
|
||||||
f)
|
};
|
||||||
|
fmt::Display::fmt(s, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,4 +275,4 @@ pub fn expected_output_path(testpaths: &TestPaths,
|
||||||
pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT, UI_FIXED];
|
pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT, UI_FIXED];
|
||||||
pub const UI_STDERR: &str = "stderr";
|
pub const UI_STDERR: &str = "stderr";
|
||||||
pub const UI_STDOUT: &str = "stdout";
|
pub const UI_STDOUT: &str = "stdout";
|
||||||
pub const UI_FIXED: &str = "rs.fixed";
|
pub const UI_FIXED: &str = "fixed";
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use common::{Config, TestPaths};
|
use common::{Config, TestPaths};
|
||||||
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
|
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
|
||||||
use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
|
use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
|
||||||
use common::{Incremental, MirOpt, RunMake, Ui};
|
use common::{Incremental, MirOpt, RunMake, Ui, Rustfix};
|
||||||
use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED};
|
use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED};
|
||||||
use common::CompareMode;
|
use common::CompareMode;
|
||||||
use diff;
|
use diff;
|
||||||
|
@ -21,6 +21,7 @@ use json;
|
||||||
use header::TestProps;
|
use header::TestProps;
|
||||||
use util::logv;
|
use util::logv;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use rustfix::{apply_suggestions, get_suggestions_from_json};
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -241,6 +242,7 @@ impl<'test> TestCx<'test> {
|
||||||
CodegenUnits => self.run_codegen_units_test(),
|
CodegenUnits => self.run_codegen_units_test(),
|
||||||
Incremental => self.run_incremental_test(),
|
Incremental => self.run_incremental_test(),
|
||||||
RunMake => self.run_rmake_test(),
|
RunMake => self.run_rmake_test(),
|
||||||
|
Rustfix => self.run_rustfix_test(),
|
||||||
Ui => self.run_ui_test(),
|
Ui => self.run_ui_test(),
|
||||||
MirOpt => self.run_mir_opt_test(),
|
MirOpt => self.run_mir_opt_test(),
|
||||||
}
|
}
|
||||||
|
@ -1687,6 +1689,7 @@ impl<'test> TestCx<'test> {
|
||||||
|
|
||||||
rustc.arg(dir_opt);
|
rustc.arg(dir_opt);
|
||||||
}
|
}
|
||||||
|
Rustfix |
|
||||||
RunPass |
|
RunPass |
|
||||||
RunFail |
|
RunFail |
|
||||||
RunPassValgrind |
|
RunPassValgrind |
|
||||||
|
@ -2603,29 +2606,6 @@ impl<'test> TestCx<'test> {
|
||||||
self.check_error_patterns(&proc_res.stderr, &proc_res);
|
self.check_error_patterns(&proc_res.stderr, &proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED);
|
|
||||||
|
|
||||||
// FIXME(killercup): Add `nll.rs.fixed` files matching
|
|
||||||
let nll = self.config.compare_mode
|
|
||||||
.as_ref()
|
|
||||||
.map(|x| *x == CompareMode::Nll)
|
|
||||||
.unwrap_or(false);
|
|
||||||
if fixture_path.exists() && !nll {
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use rustfix::{apply_suggestions, get_suggestions_from_json};
|
|
||||||
|
|
||||||
let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file)
|
|
||||||
.unwrap();
|
|
||||||
let expected_fixed = self.load_expected_output_from_path(&fixture_path).unwrap();
|
|
||||||
let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
|
|
||||||
let fixed_code = apply_suggestions(&unfixed_code, &suggestions);
|
|
||||||
let errors = self.compare_output("rs.fixed", &fixed_code, &expected_fixed);
|
|
||||||
if errors > 0 {
|
|
||||||
panic!("rustfix produced different fixed file!");
|
|
||||||
// FIXME(killercup): Add info for update-references.sh call
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_mir_opt_test(&self) {
|
fn run_mir_opt_test(&self) {
|
||||||
|
@ -2950,6 +2930,62 @@ impl<'test> TestCx<'test> {
|
||||||
println!("Actual {} saved to {}", kind, output_file.display());
|
println!("Actual {} saved to {}", kind, output_file.display());
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn run_rustfix_test(&self) {
|
||||||
|
// First up, compile the test with --error-format=json
|
||||||
|
let mut rustc = self.make_compile_args(
|
||||||
|
&self.testpaths.file,
|
||||||
|
TargetLocation::ThisFile(self.make_exe_name()),
|
||||||
|
);
|
||||||
|
rustc.arg("--error-format").arg("json")
|
||||||
|
.arg("-L").arg(&self.aux_output_dir_name());
|
||||||
|
let proc_res = self.compose_and_run_compiler(rustc, None);
|
||||||
|
|
||||||
|
// Now apply suggestions from rustc to the code itself
|
||||||
|
let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file)
|
||||||
|
.unwrap();
|
||||||
|
let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
|
||||||
|
let fixed_code = apply_suggestions(&unfixed_code, &suggestions);
|
||||||
|
|
||||||
|
// Load up what the expected result of fixing should be
|
||||||
|
let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED);
|
||||||
|
let expected_fixed = self.load_expected_output_from_path(&fixture_path)
|
||||||
|
.unwrap_or(String::new());
|
||||||
|
|
||||||
|
// Make sure our fixed code is the same as what we're expecting
|
||||||
|
let errors = self.compare_output(UI_FIXED, &fixed_code, &expected_fixed);
|
||||||
|
if errors > 0 {
|
||||||
|
println!("To update references, run this command from build directory:");
|
||||||
|
let relative_path_to_file = self.testpaths
|
||||||
|
.relative_dir
|
||||||
|
.join(self.testpaths.file.file_name().unwrap());
|
||||||
|
println!(
|
||||||
|
"{}/update-references.sh '{}' '{}'",
|
||||||
|
self.config.src_base.display(),
|
||||||
|
self.config.build_base.display(),
|
||||||
|
relative_path_to_file.display()
|
||||||
|
);
|
||||||
|
self.fatal_proc_rec(
|
||||||
|
&format!("{} errors occurred comparing output.", errors),
|
||||||
|
&proc_res,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// And finally, compile the fixed code and make sure it both succeeds
|
||||||
|
// and has no diagnostics.
|
||||||
|
let mut rustc = self.make_compile_args(
|
||||||
|
&self.testpaths.file.with_extension(UI_FIXED),
|
||||||
|
TargetLocation::ThisFile(self.make_exe_name()),
|
||||||
|
);
|
||||||
|
rustc.arg("-L").arg(&self.aux_output_dir_name());
|
||||||
|
let res = self.compose_and_run_compiler(rustc, None);
|
||||||
|
if !res.status.success() {
|
||||||
|
self.fatal_proc_rec("failed to compile fixed code", &res);
|
||||||
|
}
|
||||||
|
if !res.stderr.is_empty() {
|
||||||
|
self.fatal_proc_rec("fixed code is still producing diagnostics", &res);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ProcArgs {
|
struct ProcArgs {
|
||||||
|
|
Loading…
Reference in New Issue