Skip to content

Commit 62e2b2f

Browse files
committed
Auto merge of #33228 - nikomatsakis:compiletest-gut, r=acrichto
Move auxiliary directories to live with the tests This is a step for enabling testing of cross-crate incremental compilation. The idea is that instead of having a central auxiliary directory, when you have a `// aux-build:foo.rs` annotation in the test `run-pass/bar.rs`, it will look in (e.g.) `run-pass/aux/foo.rs`. In general, it looks for an `aux` directory in the same directory as the test. We also ignore the `aux` directories when enumerating the set of tests. As part of this PR, also refactor `runtest.rs` to use methods on a context, which means we can stop passing around context everywhere. r? @alexcrichton
2 parents 0cb9bc5 + 7070124 commit 62e2b2f

File tree

371 files changed

+2769
-2004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

371 files changed

+2769
-2004
lines changed

mk/tests.mk

-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
622622
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
623623
--rustdoc-path $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
624624
--llvm-filecheck $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin/FileCheck \
625-
--aux-base $$(S)src/test/auxiliary/ \
626625
--stage-id stage$(1)-$(2) \
627626
--target $(2) \
628627
--host $(3) \

src/bootstrap/build/check.rs

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ pub fn compiletest(build: &Build,
7070
cmd.arg("--rustc-path").arg(build.compiler_path(compiler));
7171
cmd.arg("--rustdoc-path").arg(build.rustdoc(compiler));
7272
cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
73-
cmd.arg("--aux-base").arg(build.src.join("src/test/auxiliary"));
7473
cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
7574
cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
7675
cmd.arg("--mode").arg(mode);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2012-2015 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+
#![crate_type = "lib"]
12+
13+
struct Struct(u32);
14+
15+
#[inline(never)]
16+
pub fn foo<T>(x: T) -> (T, u32, i8) {
17+
let (x, Struct(y)) = bar(x);
18+
(x, y, 2)
19+
}
20+
21+
#[inline(never)]
22+
fn bar<T>(x: T) -> (T, Struct) {
23+
let _ = not_exported_and_not_generic(0);
24+
(x, Struct(1))
25+
}
26+
27+
// These should not contribute to the codegen items of other crates.
28+
#[inline(never)]
29+
pub fn exported_but_not_generic(x: i32) -> i64 {
30+
x as i64
31+
}
32+
33+
#[inline(never)]
34+
fn not_exported_and_not_generic(x: u32) -> u64 {
35+
x as u64
36+
}
37+

src/test/auxiliary/no_std_crate.rs renamed to src/test/compile-fail/auxiliary/macro_reexport_1.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![no_std]
12-
13-
pub fn foo() {}
11+
#![crate_type = "dylib"]
12+
#[macro_export]
13+
macro_rules! reexported {
14+
() => ( 3 )
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2014 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+
#![feature(associated_consts)]
12+
13+
pub use self::sub::{Bar, Baz};
14+
15+
pub trait Trait {
16+
fn foo(&self);
17+
type Assoc;
18+
const CONST: u32;
19+
}
20+
21+
struct Foo;
22+
23+
impl Foo {
24+
pub fn new() {}
25+
26+
pub const C: u32 = 0;
27+
}
28+
29+
mod sub {
30+
pub struct Bar;
31+
32+
impl Bar {
33+
pub fn new() {}
34+
}
35+
36+
pub enum Baz {}
37+
38+
impl Baz {
39+
pub fn new() {}
40+
}
41+
}

src/test/compile-fail/issue-21146.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
// error-pattern: expected item, found `parse_error`
12-
include!("../auxiliary/issue-21146-inc.rs");
12+
include!("auxiliary/issue-21146-inc.rs");
1313
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2015 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+
// force-host
12+
13+
#![feature(plugin_registrar, rustc_private)]
14+
#![feature(box_syntax)]
15+
16+
#[macro_use] extern crate rustc;
17+
extern crate rustc_plugin;
18+
extern crate syntax;
19+
20+
use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
21+
use rustc_plugin::Registry;
22+
use rustc::hir;
23+
use syntax::attr;
24+
25+
declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]");
26+
27+
struct Pass;
28+
29+
impl LintPass for Pass {
30+
fn get_lints(&self) -> LintArray {
31+
lint_array!(CRATE_NOT_OKAY)
32+
}
33+
}
34+
35+
impl LateLintPass for Pass {
36+
fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
37+
if !attr::contains_name(&krate.attrs, "crate_okay") {
38+
cx.span_lint(CRATE_NOT_OKAY, krate.span,
39+
"crate is not marked with #![crate_okay]");
40+
}
41+
}
42+
}
43+
44+
#[plugin_registrar]
45+
pub fn plugin_registrar(reg: &mut Registry) {
46+
reg.register_late_lint_pass(box Pass as LateLintPassObject);
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2014 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+
// force-host
12+
13+
#![feature(plugin_registrar)]
14+
#![feature(box_syntax, rustc_private)]
15+
16+
// Load rustc as a plugin to get macros
17+
#[macro_use]
18+
extern crate rustc;
19+
extern crate rustc_plugin;
20+
21+
use rustc::hir;
22+
use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
23+
use rustc_plugin::Registry;
24+
25+
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
26+
27+
declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'");
28+
29+
struct Pass;
30+
31+
impl LintPass for Pass {
32+
fn get_lints(&self) -> LintArray {
33+
lint_array!(TEST_LINT, PLEASE_LINT)
34+
}
35+
}
36+
37+
impl LateLintPass for Pass {
38+
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
39+
match &*it.name.as_str() {
40+
"lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
41+
"pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
42+
_ => {}
43+
}
44+
}
45+
}
46+
47+
#[plugin_registrar]
48+
pub fn plugin_registrar(reg: &mut Registry) {
49+
reg.register_late_lint_pass(box Pass as LateLintPassObject);
50+
reg.register_lint_group("lint_me", vec![TEST_LINT, PLEASE_LINT]);
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2014 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+
// force-host
12+
13+
#![feature(plugin_registrar)]
14+
#![feature(box_syntax, rustc_private)]
15+
16+
extern crate syntax;
17+
18+
// Load rustc as a plugin to get macros
19+
#[macro_use]
20+
extern crate rustc;
21+
extern crate rustc_plugin;
22+
23+
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
24+
EarlyLintPassObject, LintArray};
25+
use rustc_plugin::Registry;
26+
use syntax::ast;
27+
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
28+
29+
struct Pass;
30+
31+
impl LintPass for Pass {
32+
fn get_lints(&self) -> LintArray {
33+
lint_array!(TEST_LINT)
34+
}
35+
}
36+
37+
impl EarlyLintPass for Pass {
38+
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
39+
if it.ident.name.as_str() == "lintme" {
40+
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
41+
}
42+
}
43+
}
44+
45+
#[plugin_registrar]
46+
pub fn plugin_registrar(reg: &mut Registry) {
47+
reg.register_early_lint_pass(box Pass as EarlyLintPassObject);
48+
}

0 commit comments

Comments
 (0)