Skip to content

Commit

Permalink
Auto merge of #49321 - ishitatsuyuki:compile-pass, r=alexcrichton
Browse files Browse the repository at this point in the history
Introduce compile-pass

r? @alexcrichton

The plan is to move things that cannot fail (no assert, unwrap, etc) out so we don't have to run them, and in the long term we can also stop running LLVM for them.

Out of 3215 tests...

```
Language            Files        Lines         Code     Comments       Blanks
Rust                 3215       119254        64688        35135        19431
```

16% of them has an empty main (which is already moved in this PR).

```
grep -rnPzl 'fn main\(\)\s*{\s*}' | xargs rg --files-without-match cfg | wc -l
547
```

And only 50% of the tests contains assertions:

```
rg -e assert -e unwrap -e expect -e panic -l | wc -l
1600
```

The remainder is likely able to get moved, but they need check by a human so I didn't touch them in PR.

cc @rust-lang/compiler

* [ ] Update documentation
  • Loading branch information
bors committed Apr 25, 2018
2 parents 81135c9 + 00bc634 commit 25749ad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/test/run-pass/compiletest-skip-trans.rs
Original file line number Diff line number Diff line change
@@ -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.

// Test that with the `skip-trans` option the test isn't executed.

// skip-trans

fn main() {
unreachable!();
}
11 changes: 11 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ pub struct TestProps {
pub check_test_line_numbers_match: bool,
// The test must be compiled and run successfully. Only used in UI tests for now.
pub run_pass: bool,
// Skip any codegen step and running the executable. Only for run-pass.
pub skip_trans: bool,
// Do not pass `-Z ui-testing` to UI tests
pub disable_ui_testing_normalization: bool,
// customized normalization rules
Expand Down Expand Up @@ -260,6 +262,7 @@ impl TestProps {
compile_pass: false,
check_test_line_numbers_match: false,
run_pass: false,
skip_trans: false,
disable_ui_testing_normalization: false,
normalize_stdout: vec![],
normalize_stderr: vec![],
Expand Down Expand Up @@ -381,6 +384,10 @@ impl TestProps {
config.parse_compile_pass(ln) || self.run_pass;
}

if !self.skip_trans {

This comment has been minimized.

Copy link
@therealprof

therealprof Apr 26, 2018

Contributor

Indention is quite funky here.

self.skip_trans = config.parse_skip_trans(ln);
}

if !self.disable_ui_testing_normalization {
self.disable_ui_testing_normalization =
config.parse_disable_ui_testing_normalization(ln);
Expand Down Expand Up @@ -524,6 +531,10 @@ impl Config {
self.parse_name_directive(line, "run-pass")
}

fn parse_skip_trans(&self, line: &str) -> bool {
self.parse_name_directive(line, "skip-trans")
}

fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> {
self.parse_name_value_directive(line, name).map(|nv| {
// nv is either FOO or FOO=BAR
Expand Down
13 changes: 10 additions & 3 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,11 @@ impl<'test> TestCx<'test> {
"run-pass tests with expected warnings should be moved to ui/"
);

let proc_res = self.exec_compiled_test();
if !proc_res.status.success() {
self.fatal_proc_rec("test run failed!", &proc_res);
if !self.props.skip_trans {
let proc_res = self.exec_compiled_test();
if !proc_res.status.success() {
self.fatal_proc_rec("test run failed!", &proc_res);
}
}
}

Expand Down Expand Up @@ -1697,6 +1699,11 @@ impl<'test> TestCx<'test> {
}
}

if self.props.skip_trans {
assert!(!self.props.compile_flags.iter().any(|s| s.starts_with("--emit")));
rustc.args(&["--emit", "metadata"]);
}

if !is_rustdoc {
if self.config.target == "wasm32-unknown-unknown" {
// rustc.arg("-g"); // get any backtrace at all on errors
Expand Down

0 comments on commit 25749ad

Please sign in to comment.