Skip to content

Commit

Permalink
Rollup merge of rust-lang#61778 - petrochenkov:pass, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
compiletest: Introduce `// {check,build,run}-pass` pass modes

Pass UI tests now have three modes
```
// check-pass
// build-pass
// run-pass
```
mirroring equivalent well-known `cargo` commands.

`// check-pass` will compile the test skipping codegen (which is expensive and isn't supposed to fail in most cases).
`// build-pass` will compile and link the test without running it.
`// run-pass` will compile, link and run the test.
Tests without a "pass" annotation are still considered "fail" tests.

Most UI tests would probably want to switch to `check-pass`.
Tests validating codegen would probably want to run the generated code as well and use `run-pass`.
`build-pass` should probably be rare (linking tests?).

rust-lang#61755 will provide a way to run the tests with any mode, e.g. bump `check-pass` tests to `run-pass` to satisfy especially suspicious people, and be able to make sure that codegen doesn't breaks in some entirely unexpected way.
Tests marked with any mode are expected to pass with any other mode, if that's not the case for some legitimate reason, then the test should be made a "fail" test rather than a "pass" test.
Perhaps some secondary CI can verify this invariant, but that's not super urgent.

`// compile-pass` still works and is equivalent to `build-pass`.
Why is `// compile-pass` bad - 1) it gives an impression that the test is only compiled, but not linked, 2) it doesn't mirror a cargo command.
It can be removed some time in the future in a separate PR.

cc rust-lang#61712
  • Loading branch information
Centril committed Jun 23, 2019
2 parents a96ba96 + 0886bc4 commit 6e06fa0
Show file tree
Hide file tree
Showing 67 changed files with 389 additions and 478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// rustc_on_unimplemented, but with this bug we are seeing it fire (on
// subsequent runs) if incremental compilation is enabled.

// revisions: rpass1 rpass2
// revisions: cfail1 cfail2
// compile-pass

#![feature(on_unimplemented)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// seeing it fire (on subsequent runs) if incremental compilation is
// enabled.

// revisions: rpass1 rpass2
// revisions: cfail1 cfail2
// compile-pass

#![feature(rustc_attrs)]
Expand Down
4 changes: 2 additions & 2 deletions src/test/incremental/no_mangle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// revisions:rpass1 rpass2
// revisions:cfail1 cfail2
// check-pass
// compile-flags: --crate-type cdylib
// skip-codegen

#![deny(unused_attributes)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-pass
// error-pattern:returned Box<dyn Error> from main()
// failure-status: 1

use std::error::Error;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-pass
// error-pattern:returned Box<Error> from main()
// failure-status: 1

use std::io::{Error, ErrorKind};
Expand Down
7 changes: 0 additions & 7 deletions src/test/run-pass/compiletest-skip-codegen.rs

This file was deleted.

6 changes: 2 additions & 4 deletions src/test/ui/asm/asm-misplaced-option.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// check-pass
// ignore-android
// ignore-arm
// ignore-aarch64
Expand All @@ -11,14 +12,11 @@
// ignore-mips
// ignore-mips64

// compile-pass
// skip-codegen
#![feature(asm)]
#![allow(dead_code, non_upper_case_globals)]

#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
pub fn main() {
fn main() {
// assignment not dead
let mut x: isize = 0;
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/asm/asm-misplaced-option.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
warning: unrecognized option
--> $DIR/asm-misplaced-option.rs:26:64
--> $DIR/asm-misplaced-option.rs:24:64
|
LL | asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
| ^^^^

warning: expected a clobber, found an option
--> $DIR/asm-misplaced-option.rs:33:80
--> $DIR/asm-misplaced-option.rs:31:80
|
LL | asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
| ^^^^^^^^^^
Expand Down
17 changes: 8 additions & 9 deletions src/test/ui/associated-types/cache/chrono-scan.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// compile-pass
// skip-codegen
#![allow(warnings)]
// check-pass

pub type ParseResult<T> = Result<T, ()>;

pub enum Item<'a> { Literal(&'a str),
}
pub enum Item<'a> {
Literal(&'a str)
}

pub fn colon_or_space(s: &str) -> ParseResult<&str> {
unimplemented!()
Expand All @@ -20,10 +20,9 @@ pub fn parse<'a, I>(mut s: &str, items: I) -> ParseResult<()>
macro_rules! try_consume {
($e:expr) => ({ let (s_, v) = try!($e); s = s_; v })
}
let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space));
let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space));
let offset = try_consume!(timezone_offset_zulu(s.trim_start(), colon_or_space));
let offset = try_consume!(timezone_offset_zulu(s.trim_start(), colon_or_space));
Ok(())
}


fn main() { }
fn main() {}
5 changes: 2 additions & 3 deletions src/test/ui/associated-types/cache/elision.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// compile-pass
// skip-codegen
#![allow(warnings)]
// Check that you are allowed to implement using elision but write
// trait without elision (a bug in this cropped up during
// bootstrapping, so this is a regression test).

// check-pass

pub struct SplitWhitespace<'a> {
x: &'a u8
}
Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/bad/bad-lint-cap3.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// check-pass
// compile-flags: --cap-lints warn

#![warn(unused)]
#![deny(warnings)]
// compile-pass
// skip-codegen
use std::option; //~ WARN

use std::option; //~ WARN

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-lint-cap3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | use std::option;
| ^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/bad-lint-cap3.rs:4:9
--> $DIR/bad-lint-cap3.rs:5:9
|
LL | #![deny(warnings)]
| ^^^^^^^^
Expand Down
10 changes: 4 additions & 6 deletions src/test/ui/coherence/coherence-projection-ok-orphan.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// compile-pass
// skip-codegen
// Here we do not get a coherence conflict because `Baz: Iterator`
// does not hold and (due to the orphan rules), we can rely on that.

// check-pass
// revisions: old re

#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]
// Here we do not get a coherence conflict because `Baz: Iterator`
// does not hold and (due to the orphan rules), we can rely on that.

pub trait Foo<P> {}

Expand All @@ -18,5 +17,4 @@ impl Foo<i32> for Baz { }

impl<A:Iterator> Foo<A::Item> for A { }


fn main() {}
5 changes: 2 additions & 3 deletions src/test/ui/coherence/coherence-projection-ok.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// compile-pass
// skip-codegen
// check-pass
// revisions: old re

#![cfg_attr(re, feature(re_rebalance_coherence))]

pub trait Foo<P> {}

pub trait Bar {
Expand All @@ -17,5 +17,4 @@ impl Bar for i32 {
type Output = u32;
}


fn main() {}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Test that we are able to introduce a negative constraint that
// `MyType: !MyTrait` along with other "fundamental" wrappers.

// check-pass
// aux-build:coherence_copy_like_lib.rs
// compile-pass
// skip-codegen
// revisions: old re

#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]

extern crate coherence_copy_like_lib as lib;

Expand All @@ -23,5 +21,4 @@ impl<T: lib::MyCopy> MyTrait for T { }
// Huzzah.
impl<'a> MyTrait for lib::MyFundamentalStruct<&'a MyType> { }


fn main() { }
7 changes: 2 additions & 5 deletions src/test/ui/coherence/coherence_local.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Test that we are able to introduce a negative constraint that
// `MyType: !MyTrait` along with other "fundamental" wrappers.

// check-pass
// aux-build:coherence_copy_like_lib.rs
// compile-pass
// skip-codegen
// revisions: old re

#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]

extern crate coherence_copy_like_lib as lib;

Expand All @@ -22,5 +20,4 @@ impl lib::MyCopy for Box<MyType> { }
impl lib::MyCopy for lib::MyFundamentalStruct<MyType> { }
impl lib::MyCopy for lib::MyFundamentalStruct<Box<MyType>> { }


fn main() { }
fn main() {}
5 changes: 1 addition & 4 deletions src/test/ui/coherence/coherence_local_ref.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Test that we are able to introduce a negative constraint that
// `MyType: !MyTrait` along with other "fundamental" wrappers.

// check-pass
// aux-build:coherence_copy_like_lib.rs
// compile-pass
// skip-codegen
// revisions: old re

#![cfg_attr(re, feature(re_rebalance_coherence))]
#![allow(dead_code)]

extern crate coherence_copy_like_lib as lib;

Expand All @@ -16,5 +14,4 @@ struct MyType { x: i32 }
// naturally, legal
impl lib::MyCopy for MyType { }


fn main() { }
7 changes: 3 additions & 4 deletions src/test/ui/conditional-compilation/cfg_attr_path.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// compile-pass
// skip-codegen
#![allow(dead_code)]
// check-pass

#![deny(unused_attributes)] // c.f #35584

mod auxiliary {
#[cfg_attr(any(), path = "nonexistent_file.rs")] pub mod namespaced_enums;
#[cfg_attr(all(), path = "namespaced_enums.rs")] pub mod nonexistent_file;
}


fn main() {
let _ = auxiliary::namespaced_enums::Foo::A;
let _ = auxiliary::nonexistent_file::Foo::A;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/const_transmute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// compile-pass
// run-pass

#![feature(const_fn_union)]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/enum_discr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// compile-pass
// run-pass

enum Foo {
Expand Down
5 changes: 1 addition & 4 deletions src/test/ui/consts/const-fn-stability-calls-3.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// Test use of const fn from another crate without a feature gate.

// compile-pass
// skip-codegen
#![allow(unused_variables)]
// check-pass
// aux-build:const_fn_lib.rs

extern crate const_fn_lib;

use const_fn_lib::foo;


fn main() {
let x = foo(); // use outside a constant is ok
}
4 changes: 1 addition & 3 deletions src/test/ui/expanded-cfg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// skip-codegen
// compile-pass
// check-pass

macro_rules! mac {
{} => {
Expand All @@ -19,5 +18,4 @@ macro_rules! mac {

mac! {}


fn main() {}
19 changes: 10 additions & 9 deletions src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
// inputs are handled by each, and (2.) to ease searching for related
// occurrences in the source text.

// check-pass

#![warn(unused_attributes, unknown_lints)]
#![allow(stable_features)]

// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES

Expand Down Expand Up @@ -75,7 +76,7 @@
// see issue-43106-gating-of-stable.rs
// see issue-43106-gating-of-unstable.rs
// see issue-43106-gating-of-deprecated.rs
#![windows_subsystem = "1000"]
#![windows_subsystem = "windows"]

// UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES

Expand Down Expand Up @@ -539,7 +540,7 @@ mod export_name {
#[export_name = "2200"] impl S { }
}

// Note that this test has a `skip-codegen`, so it
// Note that this is a `check-pass` test, so it
// will never invoke the linker. These are here nonetheless to point
// out that we allow them at non-crate-level (though I do not know
// whether they have the same effect here as at crate-level).
Expand Down Expand Up @@ -611,17 +612,17 @@ mod must_use {
#[must_use] impl S { }
}

#[windows_subsystem = "1000"]
#[windows_subsystem = "windows"]
mod windows_subsystem {
mod inner { #![windows_subsystem="1000"] }
mod inner { #![windows_subsystem="windows"] }

#[windows_subsystem = "1000"] fn f() { }
#[windows_subsystem = "windows"] fn f() { }

#[windows_subsystem = "1000"] struct S;
#[windows_subsystem = "windows"] struct S;

#[windows_subsystem = "1000"] type T = S;
#[windows_subsystem = "windows"] type T = S;

#[windows_subsystem = "1000"] impl S { }
#[windows_subsystem = "windows"] impl S { }
}

// BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES
Expand Down
Loading

0 comments on commit 6e06fa0

Please sign in to comment.