Skip to content

Commit 910439e

Browse files
committed
---
yaml --- r: 272847 b: refs/heads/beta c: 21fb3ce h: refs/heads/master i: 272845: e1b9be8 272843: 589e984 272839: 868c46c 272831: 57e693e
1 parent fd3ec76 commit 910439e

File tree

107 files changed

+3024
-1128
lines changed

Some content is hidden

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

107 files changed

+3024
-1128
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 938c8c18c406fc650c7c2c895aca3fb320ecbf18
26+
refs/heads/beta: 21fb3ce71b39133cc24b40de82e3214dd603cd61
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/COMPILER_TESTS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,43 @@ whole, instead of just a few lines inside the test.
4242
* `ignore-test` always ignores the test
4343
* `ignore-lldb` and `ignore-gdb` will skip the debuginfo tests
4444
* `min-{gdb,lldb}-version`
45+
* `should-fail` indicates that the test should fail; used for "meta testing",
46+
where we test the compiletest program itself to check that it will generate
47+
errors in appropriate scenarios. This header is ignored for pretty-printer tests.
48+
49+
## Revisions
50+
51+
Certain classes of tests support "revisions" (as of the time of this
52+
writing, this includes run-pass, compile-fail, run-fail, and
53+
incremental, though incremental tests are somewhat
54+
different). Revisions allow a single test file to be used for multiple
55+
tests. This is done by adding a special header at the top of the file:
56+
57+
```
58+
// revisions: foo bar baz
59+
```
60+
61+
This will result in the test being compiled (and tested) three times,
62+
once with `--cfg foo`, once with `--cfg bar`, and once with `--cfg
63+
baz`. You can therefore use `#[cfg(foo)]` etc within the test to tweak
64+
each of these results.
65+
66+
You can also customize headers and expected error messages to a particular
67+
revision. To do this, add `[foo]` (or `bar`, `baz`, etc) after the `//`
68+
comment, like so:
69+
70+
```
71+
// A flag to pass in only for cfg `foo`:
72+
//[foo]compile-flags: -Z verbose
73+
74+
#[cfg(foo)]
75+
fn test_foo() {
76+
let x: usize = 32_u32; //[foo]~ ERROR mismatched types
77+
}
78+
```
79+
80+
Note that not all headers have meaning when customized too a revision.
81+
For example, the `ignore-test` header (and all "ignore" headers)
82+
currently only apply to the test as a whole, not to particular
83+
revisions. The only headers that are intended to really work when
84+
customized to a revision are error patterns and compiler flags.

branches/beta/mk/cfg/i686-pc-windows-gnu.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ CFG_GNU_TRIPLE_i686-pc-windows-gnu := i686-w64-mingw32
2525
CFG_THIRD_PARTY_OBJECTS_i686-pc-windows-gnu := crt2.o dllcrt2.o
2626
CFG_INSTALLED_OBJECTS_i686-pc-windows-gnu := crt2.o dllcrt2.o rsbegin.o rsend.o
2727
CFG_RUSTRT_HAS_STARTUP_OBJS_i686-pc-windows-gnu := 1
28-
# FIXME(#31030) - there's not a great reason to disable jemalloc here
29-
CFG_DISABLE_JEMALLOC_i686-pc-windows-gnu := 1

branches/beta/mk/cfg/x86_64-pc-windows-gnu.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ CFG_GNU_TRIPLE_x86_64-pc-windows-gnu := x86_64-w64-mingw32
2525
CFG_THIRD_PARTY_OBJECTS_x86_64-pc-windows-gnu := crt2.o dllcrt2.o
2626
CFG_INSTALLED_OBJECTS_x86_64-pc-windows-gnu := crt2.o dllcrt2.o rsbegin.o rsend.o
2727
CFG_RUSTRT_HAS_STARTUP_OBJS_x86_64-pc-windows-gnu := 1
28-
# FIXME(#31030) - there's not a great reason to disable jemalloc here
29-
CFG_DISABLE_JEMALLOC_x86_64-pc-windows-gnu := 1

branches/beta/src/bootstrap/build/sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn check(build: &mut Build) {
7979
}
8080

8181
// Make sure musl-root is valid if specified
82-
if target.contains("musl") {
82+
if target.contains("musl") && target.contains("x86_64") {
8383
match build.config.musl_root {
8484
Some(ref root) => {
8585
if fs::metadata(root.join("lib/libc.a")).is_err() {

branches/beta/src/compiletest/compiletest.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,25 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
354354
}
355355

356356
pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn {
357+
let early_props = header::early_props(config, &testpaths.file);
358+
359+
// The `should-fail` annotation doesn't apply to pretty tests,
360+
// since we run the pretty printer across all tests by default.
361+
// If desired, we could add a `should-fail-pretty` annotation.
362+
let should_panic = match config.mode {
363+
Pretty => test::ShouldPanic::No,
364+
_ => if early_props.should_fail {
365+
test::ShouldPanic::Yes
366+
} else {
367+
test::ShouldPanic::No
368+
}
369+
};
370+
357371
test::TestDescAndFn {
358372
desc: test::TestDesc {
359373
name: make_test_name(config, testpaths),
360-
ignore: header::is_test_ignored(config, &testpaths.file),
361-
should_panic: test::ShouldPanic::No,
374+
ignore: early_props.ignore,
375+
should_panic: should_panic,
362376
},
363377
testfn: make_test_closure(config, testpaths),
364378
}

branches/beta/src/compiletest/errors.rs

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ enum WhichLine { ThisLine, FollowPrevious(usize), AdjustBackward(usize) }
3030
/// Goal is to enable tests both like: //~^^^ ERROR go up three
3131
/// and also //~^ ERROR message one for the preceding line, and
3232
/// //~| ERROR message two for that same line.
33-
// Load any test directives embedded in the file
34-
pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
33+
///
34+
/// If cfg is not None (i.e., in an incremental test), then we look
35+
/// for `//[X]~` instead, where `X` is the current `cfg`.
36+
pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<ExpectedError> {
3537
let rdr = BufReader::new(File::open(testfile).unwrap());
3638

3739
// `last_nonfollow_error` tracks the most recently seen
@@ -44,30 +46,41 @@ pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
4446
// updating it in the map callback below.)
4547
let mut last_nonfollow_error = None;
4648

47-
rdr.lines().enumerate().filter_map(|(line_no, ln)| {
48-
parse_expected(last_nonfollow_error,
49-
line_no + 1,
50-
&ln.unwrap())
51-
.map(|(which, error)| {
52-
match which {
53-
FollowPrevious(_) => {}
54-
_ => last_nonfollow_error = Some(error.line),
55-
}
56-
error
57-
})
58-
}).collect()
49+
let tag = match cfg {
50+
Some(rev) => format!("//[{}]~", rev),
51+
None => format!("//~")
52+
};
53+
54+
rdr.lines()
55+
.enumerate()
56+
.filter_map(|(line_no, ln)| {
57+
parse_expected(last_nonfollow_error,
58+
line_no + 1,
59+
&ln.unwrap(),
60+
&tag)
61+
.map(|(which, error)| {
62+
match which {
63+
FollowPrevious(_) => {}
64+
_ => last_nonfollow_error = Some(error.line),
65+
}
66+
error
67+
})
68+
})
69+
.collect()
5970
}
6071

6172
fn parse_expected(last_nonfollow_error: Option<usize>,
6273
line_num: usize,
63-
line: &str) -> Option<(WhichLine, ExpectedError)> {
64-
let start = match line.find("//~") { Some(i) => i, None => return None };
65-
let (follow, adjusts) = if line.char_at(start + 3) == '|' {
74+
line: &str,
75+
tag: &str)
76+
-> Option<(WhichLine, ExpectedError)> {
77+
let start = match line.find(tag) { Some(i) => i, None => return None };
78+
let (follow, adjusts) = if line.char_at(start + tag.len()) == '|' {
6679
(true, 0)
6780
} else {
68-
(false, line[start + 3..].chars().take_while(|c| *c == '^').count())
81+
(false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())
6982
};
70-
let kind_start = start + 3 + adjusts + (follow as usize);
83+
let kind_start = start + tag.len() + adjusts + (follow as usize);
7184
let letters = line[kind_start..].chars();
7285
let kind = letters.skip_while(|c| c.is_whitespace())
7386
.take_while(|c| !c.is_whitespace())
@@ -91,7 +104,9 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
91104
(which, line)
92105
};
93106

94-
debug!("line={} which={:?} kind={:?} msg={:?}", line_num, which, kind, msg);
107+
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
108+
line_num, tag, which, kind, msg);
109+
95110
Some((which, ExpectedError { line: line,
96111
kind: kind,
97112
msg: msg, }))

0 commit comments

Comments
 (0)