Skip to content

Commit

Permalink
Merge pull request #1919 from rust-lang-nursery/ui
Browse files Browse the repository at this point in the history
Move all our tests back to ui tests
  • Loading branch information
oli-obk committed Aug 2, 2017
2 parents 5595027 + b1eec6b commit 49b00ec
Show file tree
Hide file tree
Showing 401 changed files with 1,534 additions and 1,692 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ out
# Generated by Cargo
/target/
/clippy_lints/target/
/clippy_tests/target/

# We don't pin yet
Cargo.lock
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sudo: false
cache:
cargo: true
directories:
- clippy_tests/target
- target

env:
global:
Expand All @@ -32,7 +32,7 @@ script:
- cargo build --features debugging
- cargo test --features debugging
- mkdir -p ~/rust/cargo/bin
- cp clippy_tests/target/debug/cargo-clippy ~/rust/cargo/bin/cargo-clippy
- cp target/debug/cargo-clippy ~/rust/cargo/bin/cargo-clippy
- PATH=$PATH:~/rust/cargo/bin cargo clippy -- -D clippy
- cd clippy_lints && PATH=$PATH:~/rust/cargo/bin cargo clippy -- -D clippy && cd ..
- cd clippy_workspace_tests && PATH=$PATH:~/rust/cargo/bin cargo clippy -- -D clippy && cd ..
Expand Down
13 changes: 4 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@ Compiling clippy can take almost a minute or more depending on your machine.
You can set the environment flag `CARGO_INCREMENTAL=1` to cut down that time to
almost a third on average, depending on the influence your change has.

Clippy uses its own version of UI tests. Run `cargo test examples` to run only the ui tests.
This will update all the `*.stderr` files in `clippy_tests/examples`. You need to check
the stderr files whether they look as you expected them and commit them together with your
changes.
When you want to test a new lint, just create a new file in `clippy_tests/examples` and
rerun `cargo test examples`.

You can check just one example by running `cargo run --example example_name` inside the
`clippy_tests` directory.
Clippy uses UI tests. UI tests check that the output of the compiler is exactly as expected.
Of course there's little sense in writing the output yourself or copying it around.
Therefore you can simply run `tests/ui/update-all-references.sh` and check whether
the output looks as you expect with `git diff`. Commit all `*.stderr` files, too.

Also please document your lint with a doc comment akin to the following:
```rust
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ readme = "README.md"
license = "MPL-2.0"
keywords = ["clippy", "lint", "plugin"]
categories = ["development-tools", "development-tools::cargo-plugins"]
workspace = "clippy_tests"

[badges]
travis-ci = { repository = "Manishearth/rust-clippy" }
Expand Down Expand Up @@ -47,3 +46,5 @@ serde = "1.0"

[features]
debugging = []

[workspace]
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test_script:
- set RUST_BACKTRACE=1
- cargo build --features debugging
- cargo test --features debugging
- copy clippy_tests\target\debug\cargo-clippy.exe C:\Users\appveyor\.cargo\bin\
- copy target\debug\cargo-clippy.exe C:\Users\appveyor\.cargo\bin\
- cargo clippy -- -D clippy
- cd clippy_lints && cargo clippy -- -D clippy && cd ..

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository = "https://github.com/Manishearth/rust-clippy"
readme = "README.md"
license = "MPL-2.0"
keywords = ["clippy", "lint", "plugin"]
workspace = "../clippy_tests"
workspace = ".."

[dependencies]
itertools = "0.6.0"
Expand Down
9 changes: 0 additions & 9 deletions clippy_tests/Cargo.toml

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/attrs.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/cast.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/dlist.stdout
Empty file.
Empty file removed clippy_tests/examples/doc.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/entry.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/eq_op.stdout
Empty file.
Empty file.
Empty file removed clippy_tests/examples/eta.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/panic.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/print.stdout
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/range.stdout
Empty file.
36 changes: 0 additions & 36 deletions clippy_tests/examples/redundant_closure_call.stderr

This file was deleted.

Empty file.
Empty file.
10 changes: 0 additions & 10 deletions clippy_tests/examples/regex.stderr

This file was deleted.

Empty file removed clippy_tests/examples/regex.stdout
Empty file.
10 changes: 0 additions & 10 deletions clippy_tests/examples/serde.stderr

This file was deleted.

Empty file removed clippy_tests/examples/serde.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file removed clippy_tests/examples/swap.stdout
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
10 changes: 0 additions & 10 deletions clippy_tests/examples/useless_attribute.stderr

This file was deleted.

Empty file.
Empty file removed clippy_tests/examples/vec.stdout
Empty file.
Empty file.
26 changes: 0 additions & 26 deletions clippy_tests/examples/wrong_macro_span.rs_

This file was deleted.

Empty file.
Empty file.
Empty file.
6 changes: 0 additions & 6 deletions clippy_tests/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ fn run_mode(dir: &'static str, mode: &'static str) {
let mut config = compiletest::default_config();

let cfg_mode = mode.parse().expect("Invalid mode");
config.target_rustcflags = Some("-L clippy_tests/target/debug/ -L clippy_tests/target/debug/deps".to_owned());
config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps -Dwarnings".to_owned());
if let Ok(name) = var::<&str>("TESTNAME") {
let s: String = name.to_owned();
config.filter = Some(s)
}

config.mode = cfg_mode;
config.build_base = PathBuf::from("clippy_tests/target/debug/test_build_base");
config.build_base = PathBuf::from("target/debug/test_build_base");
config.src_base = PathBuf::from(format!("tests/{}", dir));

compiletest::run_tests(&config);
Expand Down
4 changes: 2 additions & 2 deletions tests/dogfood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ fn dogfood() {

let cfg_mode = "run-fail".parse().expect("Invalid mode");
let mut s = String::new();
s.push_str(" -L clippy_tests/target/debug/");
s.push_str(" -L clippy_tests/target/debug/deps");
s.push_str(" -L target/debug/");
s.push_str(" -L target/debug/deps");
s.push_str(" -Zextra-plugins=clippy -Ltarget_recur/debug -Dwarnings -Dclippy_pedantic -Dclippy -Dclippy_internal");
config.target_rustcflags = Some(s);
if let Ok(name) = var("TESTNAME") {
Expand Down
51 changes: 0 additions & 51 deletions tests/examples.rs

This file was deleted.

1 change: 0 additions & 1 deletion tests/run-pass/associated-constant-ice.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(associated_consts)]
#![feature(plugin)]
#![plugin(clippy)]

Expand Down
1 change: 1 addition & 0 deletions tests/run-pass/enum-glob-import-crate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy)]
#![allow(unused_imports)]

use std::*;

Expand Down
3 changes: 2 additions & 1 deletion tests/run-pass/needless_lifetimes_impl_trait.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![feature(plugin)]
#![plugin(clippy)]
#![feature(conservative_impl_trait)]
#![deny(needless_lifetime)]
#![deny(needless_lifetimes)]
#![allow(dead_code)]

trait Foo {}

Expand Down
1 change: 1 addition & 0 deletions tests/run-pass/regressions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![feature(plugin)]
#![plugin(clippy)]
#![allow(blacklisted_name)]

pub fn foo(bar: *const u8) {
println!("{:#p}", bar);
Expand Down
File renamed without changes.
Loading

0 comments on commit 49b00ec

Please sign in to comment.