Provide local paths for file tests. (#2830)

The intent of this change is that instead of paths looking like `explorer/testdata/foo/bar.carbon` (repo-relative), they're now just `bar.carbon` (local). The consequence is that paths should be a bit more durable in various environments, and just paths should be shorter and easier to read.

The explorer's prelude is an exception to this since it comes from data, rather than being the test target. Due to the change in approaches, it needs the regex again.

Uses #2829
This commit is contained in:
Jon Ross-Perkins
2023-05-18 10:20:51 -07:00
committed by GitHub
parent 3c15882f4e
commit 6b7a522b3f
495 changed files with 701 additions and 641 deletions
@@ -10,7 +10,7 @@ package ExplorerTest api;
// used.
fn Recurse(x: i32, do_recurse: bool) -> auto {
if (do_recurse) {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/auto_return/fail_direct_recurse.carbon:[[@LINE+1]]: Function calls itself, but has a deduced return type
// CHECK:STDERR: COMPILATION ERROR: fail_direct_recurse.carbon:[[@LINE+1]]: Function calls itself, but has a deduced return type
Recurse(x, false);
}
return x;
@@ -10,7 +10,7 @@ fn ComputeSum(x: i32, y: i32) -> auto {
if (x == 0) {
return x;
} else if (y == 0) {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/auto_return/fail_multiple_returns.carbon:[[@LINE+1]]: Only one return is allowed in a function with an `auto` return type.
// CHECK:STDERR: COMPILATION ERROR: fail_multiple_returns.carbon:[[@LINE+1]]: Only one return is allowed in a function with an `auto` return type.
return y;
} else {
return x + y;
@@ -7,7 +7,7 @@
package ExplorerTest api;
fn NoReturn() -> auto {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/auto_return/fail_no_return.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
// CHECK:STDERR: COMPILATION ERROR: fail_no_return.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
}
fn Main() {
@@ -7,7 +7,7 @@
package ExplorerTest api;
// This declaration is not allowed.
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/auto_return/fail_separate_decl.carbon:[[@LINE+1]]: Function declaration has deduced return type but no body
// CHECK:STDERR: COMPILATION ERROR: fail_separate_decl.carbon:[[@LINE+1]]: Function declaration has deduced return type but no body
fn ComputeSum(x: i32, y: i32) -> auto;
fn Main() -> i32 {
+1 -1
View File
@@ -9,6 +9,6 @@ package ExplorerTest api;
fn F() -> i32;
fn Main() -> i32 {
// CHECK:STDERR: RUNTIME ERROR: explorer/testdata/function/fail_call_undefined.carbon:[[@LINE+1]]: attempt to call function `F` that has not been defined
// CHECK:STDERR: RUNTIME ERROR: fail_call_undefined.carbon:[[@LINE+1]]: attempt to call function `F` that has not been defined
return F();
}
+1 -1
View File
@@ -11,6 +11,6 @@ fn f(x: i32, y: i32) -> i32 { return x + y; }
fn Main() -> i32 {
var xy: (i32, i32) = (1, 2);
// should fail to type-check
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_call_with_tuple.carbon:[[@LINE+1]]: wrong number of arguments in function call, expected 2 but got 1
// CHECK:STDERR: COMPILATION ERROR: fail_call_with_tuple.carbon:[[@LINE+1]]: wrong number of arguments in function call, expected 2 but got 1
return f(xy);
}
+1 -1
View File
@@ -6,7 +6,7 @@
package ExplorerTest api;
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_invalid_fnty.carbon:[[@LINE+2]]: type error in `-`:
// CHECK:STDERR: COMPILATION ERROR: fail_invalid_fnty.carbon:[[@LINE+2]]: type error in `-`:
// CHECK:STDERR: could not find implementation of interface Negate for bool
fn f(g: __Fn(-true) -> true) {
}
@@ -8,5 +8,5 @@ package ExplorerTest api;
fn Main(i: i32) -> i32 {
return 0;
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_main_with_parameters.carbon:[[@LINE+1]]: `Main` must not take any parameters
// CHECK:STDERR: COMPILATION ERROR: fail_main_with_parameters.carbon:[[@LINE+1]]: `Main` must not take any parameters
}
+1 -1
View File
@@ -9,7 +9,7 @@ package ExplorerTest api;
fn Main() -> i32 {
var x: i32 = 0;
match(0) {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_match_no_return.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
// CHECK:STDERR: COMPILATION ERROR: fail_match_no_return.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
case 1 => { x = 1; }
case _: auto => { x = 2; }
}
@@ -9,7 +9,7 @@ package ExplorerTest api;
fn Main() -> i32 {
var x: i32 = 0;
match (0) {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_match_partial_return.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
// CHECK:STDERR: COMPILATION ERROR: fail_match_partial_return.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
case 1 => { x = 1; }
case _: auto => { return 0; }
}
@@ -11,5 +11,5 @@ fn Main() -> i32 {
match (n) {
case 1 => { return 0; }
}
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_non_exhaustive_match.carbon:[[@LINE+1]]: non-exhaustive match may allow control-flow to reach the end of a function that provides a `->` return type
// CHECK:STDERR: COMPILATION ERROR: fail_non_exhaustive_match.carbon:[[@LINE+1]]: non-exhaustive match may allow control-flow to reach the end of a function that provides a `->` return type
}
+1 -1
View File
@@ -7,7 +7,7 @@
package ExplorerTest api;
// 42 cannot be used as the type of a parameter.
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_parameter_type.carbon:[[@LINE+1]]: type error in type of name binding: 'i32' is not implicitly convertible to 'type'
// CHECK:STDERR: COMPILATION ERROR: fail_parameter_type.carbon:[[@LINE+1]]: type error in type of name binding: 'i32' is not implicitly convertible to 'type'
fn f(x: 42) -> i32 {
return x - 1;
}
+1 -1
View File
@@ -6,7 +6,7 @@
package ExplorerTest api;
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_parameter_type_only.carbon:[[@LINE+1]]: An irrefutable pattern is required, but `i32` is refutable.
// CHECK:STDERR: COMPILATION ERROR: fail_parameter_type_only.carbon:[[@LINE+1]]: An irrefutable pattern is required, but `i32` is refutable.
fn f(x: i32, i32) {}
fn Main() -> i32 {
@@ -7,7 +7,7 @@
package ExplorerTest api;
fn T() -> type {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_recurse_before_typecheck.carbon:[[@LINE+1]]: attempt to call function `T` that has not been fully type-checked
// CHECK:STDERR: COMPILATION ERROR: fail_recurse_before_typecheck.carbon:[[@LINE+1]]: attempt to call function `T` that has not been fully type-checked
var v: T() = 0;
return i32;
}
@@ -6,7 +6,7 @@
package ExplorerTest api;
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_recurse_in_return_type.carbon:[[@LINE+1]]: 'T' is not usable until after it has been completely declared
// CHECK:STDERR: COMPILATION ERROR: fail_recurse_in_return_type.carbon:[[@LINE+1]]: 'T' is not usable until after it has been completely declared
fn T() -> T() { return i32; }
fn Main() -> i32 {
@@ -7,7 +7,7 @@
package EmptyIdentifier impl;
fn apply[T:! type, U:! type](f: T, EmptyIdentifier: U) {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_return_call_has_invalid_body.carbon:[[@LINE+1]]: only arrays and tuples can be indexed, found bool
// CHECK:STDERR: COMPILATION ERROR: fail_return_call_has_invalid_body.carbon:[[@LINE+1]]: only arrays and tuples can be indexed, found bool
match (true[true]) {}
}
+1 -1
View File
@@ -11,7 +11,7 @@ fn test() -> i32 {
}
fn Main() -> i32 {
// CHECK:STDERR: COMPILATION ERROR: explorer/testdata/function/fail_var_type_is_call.carbon:[[@LINE+1]]: type error in type of name binding: 'i32' is not implicitly convertible to 'type'
// CHECK:STDERR: COMPILATION ERROR: fail_var_type_is_call.carbon:[[@LINE+1]]: type error in type of name binding: 'i32' is not implicitly convertible to 'type'
var x: test() = 1;
return 0;
}