Skip to content

Commit

Permalink
Fix rebase
Browse files Browse the repository at this point in the history
Update docs for custom normalization of test output
  • Loading branch information
petrochenkov committed Dec 14, 2017
1 parent c3a7d36 commit 66bd53a
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 67 deletions.
11 changes: 7 additions & 4 deletions src/test/COMPILER_TESTS.md
Expand Up @@ -133,13 +133,15 @@ Sometimes these built-in normalizations are not enough. In such cases, you
may provide custom normalization rules using the header commands, e.g.

```
// normalize-stderr-32bit: "fn() (32 bits)" -> "fn() ($PTR bits)"
// normalize-stderr-64bit: "fn() (64 bits)" -> "fn() ($PTR bits)"
// normalize-stdout-test: "foo" -> "bar"
// normalize-stderr-32bit: "fn\(\) \(32 bits\)" -> "fn\(\) \($$PTR bits\)"
// normalize-stderr-64bit: "fn\(\) \(64 bits\)" -> "fn\(\) \($$PTR bits\)"
```

This tells the test, on 32-bit platforms, whenever the compiler writes
`fn() (32 bits)` to stderr, it should be normalized to read `fn() ($PTR bits)`
instead. Similar for 64-bit.
instead. Similar for 64-bit. The replacement is performed by regexes using
default regex flavor provided by `regex` crate.

The corresponding reference file will use the normalized output to test both
32-bit and 64-bit platforms:
Expand All @@ -156,4 +158,5 @@ Please see `ui/transmute/main.rs` and `.stderr` for a concrete usage example.

Besides `normalize-stderr-32bit` and `-64bit`, one may use any target
information or stage supported by `ignore-X` here as well (e.g.
`normalize-stderr-windows`).
`normalize-stderr-windows` or simply `normalize-stderr-test` for unconditional
replacement).
File renamed without changes.
8 changes: 8 additions & 0 deletions src/test/ui/const-eval-overflow-4.stderr
@@ -1,3 +1,11 @@
warning: constant evaluation error: attempt to add with overflow
--> $DIR/const-eval-overflow-4.rs:23:13
|
23 | : [u32; (i8::MAX as i8 + 1i8) as usize]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(const_err)] on by default

error[E0080]: constant evaluation error
--> $DIR/const-eval-overflow-4.rs:23:13
|
Expand Down
42 changes: 37 additions & 5 deletions src/test/ui/const-fn-error.stderr
@@ -1,14 +1,46 @@
warning: constant evaluation error: non-constant path in constant expression
--> $DIR/const-fn-error.rs:27:19
|
27 | let a : [i32; f(X)];
| ^^^^
|
= note: #[warn(const_err)] on by default

error[E0016]: blocks in constant functions are limited to items and tail expressions
--> $DIR/const-fn-error.rs:16:19
|
16 | let mut sum = 0; //~ ERROR blocks in constant functions are limited
| ^

error[E0015]: calls in constant functions are limited to constant functions, struct and enum constructors
--> $DIR/const-fn-error.rs:17:5
|
17 | / for i in 0..x { //~ ERROR calls in constant functions
18 | | //~| ERROR constant function contains unimplemented
19 | | sum += i;
20 | | }
| |_____^

error[E0019]: constant function contains unimplemented expression type
--> $DIR/const-fn-error.rs:17:5
|
17 | / for i in 0..x { //~ ERROR calls in constant functions
18 | | //~| ERROR constant function contains unimplemented
19 | | sum += i;
20 | | }
| |_____^

error[E0080]: constant evaluation error
--> $DIR/const-fn-error.rs:20:5
--> $DIR/const-fn-error.rs:21:5
|
20 | sum //~ ERROR E0080
21 | sum //~ ERROR E0080
| ^^^ non-constant path in constant expression
|
note: for constant expression here
--> $DIR/const-fn-error.rs:26:13
--> $DIR/const-fn-error.rs:27:13
|
26 | let a : [i32; f(X)];
27 | let a : [i32; f(X)];
| ^^^^^^^^^^^

error: aborting due to previous error
error: aborting due to 4 previous errors

6 changes: 2 additions & 4 deletions src/test/ui/const-len-underflow-separate-spans.rs
Expand Up @@ -15,10 +15,8 @@
const ONE: usize = 1;
const TWO: usize = 2;
const LEN: usize = ONE - TWO;
//~^ ERROR E0080
//~| attempt to subtract with overflow
//~| NOTE attempt to subtract with overflow
//~| NOTE on by default
//~^ ERROR constant evaluation error [E0080]
//~| WARN attempt to subtract with overflow

fn main() {
let a: [i8; LEN] = unimplemented!();
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/const-len-underflow-separate-spans.stderr
@@ -1,3 +1,11 @@
warning: constant evaluation error: attempt to subtract with overflow
--> $DIR/const-len-underflow-separate-spans.rs:17:20
|
17 | const LEN: usize = ONE - TWO;
| ^^^^^^^^^
|
= note: #[warn(const_err)] on by default

error[E0080]: constant evaluation error
--> $DIR/const-len-underflow-separate-spans.rs:17:20
|
Expand Down
13 changes: 0 additions & 13 deletions src/test/ui/issue-17954.stderr

This file was deleted.

12 changes: 5 additions & 7 deletions src/test/ui/issue-18819.stderr
@@ -1,13 +1,11 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
--> $DIR/issue-18819.rs:26:13
--> $DIR/issue-18819.rs:26:5
|
21 | / fn print_x(_: &Foo<Item=bool>, extra: &str) {
22 | | println!("{}", extra);
23 | | }
| |_- defined here
21 | fn print_x(_: &Foo<Item=bool>, extra: &str) {
| ------------------------------------------- defined here
...
26 | print_x(X);
| ^ expected 2 parameters
26 | print_x(X);
| ^^^^^^^^^^ expected 2 parameters

error: aborting due to previous error

1 change: 1 addition & 0 deletions src/test/ui/issue-30255.rs
Expand Up @@ -30,3 +30,4 @@ fn h(a: &bool, b: bool, c: &S, d: &i32) -> &i32 {
panic!();
}

fn main() {}
8 changes: 3 additions & 5 deletions src/test/ui/issue-3044.stderr
@@ -1,10 +1,8 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
--> $DIR/issue-3044.rs:14:28
--> $DIR/issue-3044.rs:14:23
|
14 | needlesArr.iter().fold(|x, y| {
| ____________________________^
15 | | });
| |_____^ expected 2 parameters
14 | needlesArr.iter().fold(|x, y| {
| ^^^^ expected 2 parameters

error: aborting due to previous error

6 changes: 3 additions & 3 deletions src/test/ui/issue-4935.stderr
@@ -1,11 +1,11 @@
error[E0061]: this function takes 1 parameter but 2 parameters were supplied
--> $DIR/issue-4935.rs:15:17
--> $DIR/issue-4935.rs:15:13
|
13 | fn foo(a: usize) {}
| ------------------- defined here
| ---------------- defined here
14 | //~^ defined here
15 | fn main() { foo(5, 6) }
| ^^^^ expected 1 parameter
| ^^^^^^^^^ expected 1 parameter

error: aborting due to previous error

12 changes: 6 additions & 6 deletions src/test/ui/method-call-err-msg.stderr
@@ -1,28 +1,28 @@
error[E0061]: this function takes 0 parameters but 1 parameter was supplied
--> $DIR/method-call-err-msg.rs:25:7
--> $DIR/method-call-err-msg.rs:22:7
|
15 | fn zero(self) -> Foo { self }
| -------------------- defined here
...
25 | x.zero(0) //~ ERROR this function takes 0 parameters but 1 parameter was supplied
22 | x.zero(0) //~ ERROR this function takes 0 parameters but 1 parameter was supplied
| ^^^^ expected 0 parameters

error[E0061]: this function takes 1 parameter but 0 parameters were supplied
--> $DIR/method-call-err-msg.rs:23:7
|
17 | fn one(self, _: isize) -> Foo { self }
16 | fn one(self, _: isize) -> Foo { self }
| ----------------------------- defined here
...
23 | .one() //~ ERROR this function takes 1 parameter but 0 parameters were supplied
| ^^^ expected 1 parameter

error[E0061]: this function takes 2 parameters but 1 parameter was supplied
--> $DIR/method-call-err-msg.rs:29:7
--> $DIR/method-call-err-msg.rs:24:7
|
19 | fn two(self, _: isize, _: isize) -> Foo { self }
17 | fn two(self, _: isize, _: isize) -> Foo { self }
| --------------------------------------- defined here
...
29 | .two(0); //~ ERROR this function takes 2 parameters but 1 parameter was supplied
24 | .two(0); //~ ERROR this function takes 2 parameters but 1 parameter was supplied
| ^^^ expected 2 parameters

error[E0599]: no method named `take` found for type `Foo` in the current scope
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/mismatched_types/fn-variance-1.rs
Expand Up @@ -9,10 +9,8 @@
// except according to those terms.

fn takes_imm(x: &isize) { }
//~^ NOTE found signature

fn takes_mut(x: &mut isize) { }
//~^ NOTE found signature

fn apply<T, F>(t: T, f: F) where F: FnOnce(T) {
f(t)
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/mismatched_types/fn-variance-1.stderr
@@ -1,21 +1,21 @@
error[E0631]: type mismatch in function arguments
--> $DIR/fn-variance-1.rs:23:5
--> $DIR/fn-variance-1.rs:21:5
|
14 | fn takes_mut(x: &mut isize) { }
13 | fn takes_mut(x: &mut isize) { }
| --------------------------- found signature of `for<'r> fn(&'r mut isize) -> _`
...
23 | apply(&3, takes_mut);
21 | apply(&3, takes_mut);
| ^^^^^ expected signature of `fn(&{integer}) -> _`
|
= note: required by `apply`

error[E0631]: type mismatch in function arguments
--> $DIR/fn-variance-1.rs:29:5
--> $DIR/fn-variance-1.rs:25:5
|
11 | fn takes_imm(x: &isize) { }
| ----------------------- found signature of `for<'r> fn(&'r isize) -> _`
...
29 | apply(&mut 3, takes_imm);
25 | apply(&mut 3, takes_imm);
| ^^^^^ expected signature of `fn(&mut {integer}) -> _`
|
= note: required by `apply`
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/mismatched_types/overloaded-calls-bad.stderr
Expand Up @@ -14,9 +14,9 @@ error[E0057]: this function takes 1 parameter but 0 parameters were supplied
| ^^^ expected 1 parameter

error[E0057]: this function takes 1 parameter but 2 parameters were supplied
--> $DIR/overloaded-calls-bad.rs:44:15
--> $DIR/overloaded-calls-bad.rs:41:15
|
44 | let ans = s("burma", "shave");
41 | let ans = s("burma", "shave");
| ^^^^^^^^^^^^^^^^^^^ expected 1 parameter

error: aborting due to 3 previous errors
Expand Down
Expand Up @@ -3,8 +3,7 @@ error[E0631]: type mismatch in closure arguments
|
22 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y });
| ----------------------------- found signature of `fn(usize, isize) -> _`
23 | //~^ NOTE found signature of `fn(usize, isize)
24 | let z = call_it(3, f);
23 | let z = call_it(3, f);
| ^^^^^^^ expected signature of `fn(isize, isize) -> _`
|
= note: required by `call_it`
Expand Down
12 changes: 5 additions & 7 deletions src/test/ui/not-enough-arguments.stderr
@@ -1,13 +1,11 @@
error[E0061]: this function takes 4 parameters but 3 parameters were supplied
--> $DIR/not-enough-arguments.rs:20:7
--> $DIR/not-enough-arguments.rs:20:3
|
15 | / fn foo(a: isize, b: isize, c: isize, d:isize) {
16 | | panic!();
17 | | }
| |_- defined here
15 | fn foo(a: isize, b: isize, c: isize, d:isize) {
| --------------------------------------------- defined here
...
20 | foo(1, 2, 3);
| ^^^^^^^ expected 4 parameters
20 | foo(1, 2, 3);
| ^^^^^^^^^^^^ expected 4 parameters

error: aborting due to previous error

8 changes: 8 additions & 0 deletions src/test/ui/union/union-const-eval.stderr
@@ -1,3 +1,11 @@
warning: constant evaluation error: nonexistent struct field
--> $DIR/union-const-eval.rs:21:21
|
21 | let b: [u8; C.b]; //~ ERROR constant evaluation error
| ^^^
|
= note: #[warn(const_err)] on by default

error[E0080]: constant evaluation error
--> $DIR/union-const-eval.rs:21:21
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/variadic-ffi-3.stderr
Expand Up @@ -8,13 +8,13 @@ error[E0060]: this function takes at least 2 parameters but 0 parameters were su
| ^^^^^ expected at least 2 parameters

error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied
--> $DIR/variadic-ffi-3.rs:22:13
--> $DIR/variadic-ffi-3.rs:22:9
|
12 | fn foo(f: isize, x: u8, ...);
| ----------------------------- defined here
...
22 | foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
| ^ expected at least 2 parameters
| ^^^^^^ expected at least 2 parameters

error[E0308]: mismatched types
--> $DIR/variadic-ffi-3.rs:24:56
Expand Down

0 comments on commit 66bd53a

Please sign in to comment.