Skip to content

Commit 9ceb967

Browse files
authored
Reland "[Utils] add update-verify-tests.py" (#108630)" (#108658)
This relands commit d4f41be which was reverted by b7e585b. This version ignores differences in line endings in the diff tests to make sure the tests work as intended on Windows. Original description below: Adds a python script to automatically take output from a failed clang -verify test and update the test case(s) to expect the new behaviour.
1 parent 7836603 commit 9ceb967

36 files changed

+699
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
void foo() {
2+
// expected-error@+1{{use of undeclared identifier 'a'}}
3+
a = 2; a = 2;
4+
b = 2; b = 2;
5+
// expected-error@+1 3{{use of undeclared identifier 'c'}}
6+
c = 2; c = 2;
7+
// expected-error 2{{asdf}}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
void foo() {
2+
// expected-error@+1 2{{use of undeclared identifier 'a'}}
3+
a = 2; a = 2;
4+
// expected-error@+1 2{{use of undeclared identifier 'b'}}
5+
b = 2; b = 2;
6+
// expected-error@+1 2{{use of undeclared identifier 'c'}}
7+
c = 2; c = 2;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
void foo() {
2+
// expected-error@+1 2 {{use of undeclared identifier 'a'}}
3+
a = 2; a = 2; b = 2; b = 2; c = 2;
4+
// expected-error@+1 2 {{asdf}}
5+
d = 2;
6+
e = 2; f = 2; // expected-error 2 {{use of undeclared identifier 'e'}}
7+
}
8+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
void foo() {
2+
// expected-error@+3 {{use of undeclared identifier 'c'}}
3+
// expected-error@+2 2 {{use of undeclared identifier 'b'}}
4+
// expected-error@+1 2 {{use of undeclared identifier 'a'}}
5+
a = 2; a = 2; b = 2; b = 2; c = 2;
6+
// expected-error@+1 {{use of undeclared identifier 'd'}}
7+
d = 2;
8+
// expected-error@+1 {{use of undeclared identifier 'f'}}
9+
e = 2; f = 2; // expected-error {{use of undeclared identifier 'e'}}
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
void foo() {
2+
a = 2;
3+
// expected-error@-1{{use of undeclared identifier 'a'}}
4+
b = 2;// expected-error{{use of undeclared identifier 'b'}}
5+
c = 2;
6+
// expected-error@5{{use of undeclared identifier 'c'}}
7+
d = 2; // expected-error-re{{use of {{.*}} identifier 'd'}}
8+
9+
e = 2; // error to trigger mismatch
10+
}
11+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
void foo() {
2+
a = 2;
3+
// expected-error@-1{{use of undeclared identifier 'a'}}
4+
b = 2;// expected-error{{use of undeclared identifier 'b'}}
5+
c = 2;
6+
// expected-error@5{{use of undeclared identifier 'c'}}
7+
d = 2; // expected-error-re{{use of {{.*}} identifier 'd'}}
8+
9+
// expected-error@+1{{use of undeclared identifier 'e'}}
10+
e = 2; // error to trigger mismatch
11+
}
12+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void foo() {
2+
a = 2;
3+
b = 2;
4+
5+
c = 2;
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
void foo() {
2+
// expected-error@+1{{use of undeclared identifier 'a'}}
3+
a = 2;
4+
// expected-error@+1{{use of undeclared identifier 'b'}}
5+
b = 2;
6+
7+
// expected-error@+1{{use of undeclared identifier 'c'}}
8+
c = 2;
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
void foo() {
2+
a = 2; b = 2; c = 2;
3+
}
4+
5+
void bar() {
6+
x = 2; y = 2; z = 2;
7+
// expected-error@-1{{use of undeclared identifier 'x'}}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
void foo() {
2+
// expected-error@+3{{use of undeclared identifier 'c'}}
3+
// expected-error@+2{{use of undeclared identifier 'b'}}
4+
// expected-error@+1{{use of undeclared identifier 'a'}}
5+
a = 2; b = 2; c = 2;
6+
}
7+
8+
void bar() {
9+
x = 2; y = 2; z = 2;
10+
// expected-error@-1{{use of undeclared identifier 'x'}}
11+
// expected-error@-2{{use of undeclared identifier 'y'}}
12+
// expected-error@-3{{use of undeclared identifier 'z'}}
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
void foo() {
2+
bar = 2;
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void foo() {
2+
// expected-error@+1{{use of undeclared identifier 'bar'}}
3+
bar = 2;
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
void foo() {
2+
// expected-error@+1{{asdf}}
3+
int a = 2;
4+
}
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// expected-no-diagnostics
2+
void foo() {
3+
int a = 2;
4+
}
5+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// expected-no-diagnostics
2+
void foo() {
3+
a = 2;
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void foo() {
2+
// expected-error@+1{{use of undeclared identifier 'a'}}
3+
a = 2;
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
void foo() {
2+
a = 2; // check-error{{asdf}}
3+
// expected-error@-1{ignored}}
4+
}
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
void foo() {
2+
a = 2; // check-error{{use of undeclared identifier 'a'}}
3+
// expected-error@-1{ignored}}
4+
}
5+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void foo() {
2+
bar = 2; // expected-error {{asdf}}
3+
}
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void foo() {
2+
bar = 2; // expected-error {{use of undeclared identifier 'bar'}}
3+
}
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void foo() {
2+
// expected-error@+1{{asdf}}
3+
bar = 2;
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void foo() {
2+
// expected-error@+1{{use of undeclared identifier 'bar'}}
3+
bar = 2;
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: cp %S/Inputs/duplicate-diag.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/duplicate-diag.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
4+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# RUN: cp %S/Inputs/infer-indentation.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/infer-indentation.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: cp %S/Inputs/leave-existing-diags.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/leave-existing-diags.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
4+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import lit.util
2+
3+
# python 2.7 backwards compatibility
4+
try:
5+
from shlex import quote as shell_quote
6+
except ImportError:
7+
from pipes import quote as shell_quote
8+
9+
if config.standalone_build:
10+
# These tests require the update-verify-tests.py script from the clang
11+
# source tree, so skip these tests if we are doing standalone builds.
12+
config.unsupported = True
13+
else:
14+
config.suffixes = [".test"]
15+
16+
script_path = os.path.join(
17+
config.clang_src_dir, "utils", "update-verify-tests.py"
18+
)
19+
python = shell_quote(config.python_executable)
20+
config.substitutions.append(
21+
(
22+
"%update-verify-tests",
23+
"%s %s" % (python, shell_quote(script_path)),
24+
)
25+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# RUN: cp %S/Inputs/multiple-errors.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/multiple-errors.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# RUN: cp %S/Inputs/multiple-missing-errors-same-line.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/multiple-missing-errors-same-line.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# RUN: cp %S/Inputs/no-checks.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/no-checks.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: cp %S/Inputs/no-diags.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/no-diags.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: cp %S/Inputs/no-expected-diags.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/no-expected-diags.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: cp %S/Inputs/non-default-prefix.c %t.c && not %clang_cc1 -verify=check %t.c 2>&1 | %update-verify-tests --prefix check
2+
# RUN: diff --strip-trailing-cr %S/Inputs/non-default-prefix.c.expected %t.c
3+
# RUN: %clang_cc1 -verify=check %t.c
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: cp %S/Inputs/update-same-line.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/update-same-line.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c
4+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# RUN: cp %S/Inputs/update-single-check.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
2+
# RUN: diff --strip-trailing-cr %S/Inputs/update-single-check.c.expected %t.c
3+
# RUN: %clang_cc1 -verify %t.c

0 commit comments

Comments
 (0)