Skip to content

Commit 00bc634

Browse files
committed
compiletest: introduce skip-trans
1 parent 432fe0c commit 00bc634

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that with the `skip-trans` option the test isn't executed.
12+
13+
// skip-trans
14+
15+
fn main() {
16+
unreachable!();
17+
}

src/tools/compiletest/src/header.rs

+11
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ pub struct TestProps {
228228
pub check_test_line_numbers_match: bool,
229229
// The test must be compiled and run successfully. Only used in UI tests for now.
230230
pub run_pass: bool,
231+
// Skip any codegen step and running the executable. Only for run-pass.
232+
pub skip_trans: bool,
231233
// Do not pass `-Z ui-testing` to UI tests
232234
pub disable_ui_testing_normalization: bool,
233235
// customized normalization rules
@@ -260,6 +262,7 @@ impl TestProps {
260262
compile_pass: false,
261263
check_test_line_numbers_match: false,
262264
run_pass: false,
265+
skip_trans: false,
263266
disable_ui_testing_normalization: false,
264267
normalize_stdout: vec![],
265268
normalize_stderr: vec![],
@@ -381,6 +384,10 @@ impl TestProps {
381384
config.parse_compile_pass(ln) || self.run_pass;
382385
}
383386

387+
if !self.skip_trans {
388+
self.skip_trans = config.parse_skip_trans(ln);
389+
}
390+
384391
if !self.disable_ui_testing_normalization {
385392
self.disable_ui_testing_normalization =
386393
config.parse_disable_ui_testing_normalization(ln);
@@ -524,6 +531,10 @@ impl Config {
524531
self.parse_name_directive(line, "run-pass")
525532
}
526533

534+
fn parse_skip_trans(&self, line: &str) -> bool {
535+
self.parse_name_directive(line, "skip-trans")
536+
}
537+
527538
fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> {
528539
self.parse_name_value_directive(line, name).map(|nv| {
529540
// nv is either FOO or FOO=BAR

src/tools/compiletest/src/runtest.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ impl<'test> TestCx<'test> {
343343
"run-pass tests with expected warnings should be moved to ui/"
344344
);
345345

346-
let proc_res = self.exec_compiled_test();
347-
if !proc_res.status.success() {
348-
self.fatal_proc_rec("test run failed!", &proc_res);
346+
if !self.props.skip_trans {
347+
let proc_res = self.exec_compiled_test();
348+
if !proc_res.status.success() {
349+
self.fatal_proc_rec("test run failed!", &proc_res);
350+
}
349351
}
350352
}
351353

@@ -1697,6 +1699,11 @@ impl<'test> TestCx<'test> {
16971699
}
16981700
}
16991701

1702+
if self.props.skip_trans {
1703+
assert!(!self.props.compile_flags.iter().any(|s| s.starts_with("--emit")));
1704+
rustc.args(&["--emit", "metadata"]);
1705+
}
1706+
17001707
if !is_rustdoc {
17011708
if self.config.target == "wasm32-unknown-unknown" {
17021709
// rustc.arg("-g"); // get any backtrace at all on errors

0 commit comments

Comments
 (0)