Skip to content

[Utils] add update-verify-tests.py #97369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clang/test/utils/update-verify-tests/Inputs/duplicate-diag.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
void foo() {
// expected-error@+1{{use of undeclared identifier 'a'}}
a = 2; a = 2;
b = 2; b = 2;
// expected-error@+1 3{{use of undeclared identifier 'c'}}
c = 2; c = 2;
// expected-error 2{{asdf}}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
void foo() {
// expected-error@+1 2{{use of undeclared identifier 'a'}}
a = 2; a = 2;
// expected-error@+1 2{{use of undeclared identifier 'b'}}
b = 2; b = 2;
// expected-error@+1 2{{use of undeclared identifier 'c'}}
c = 2; c = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
void foo() {
// expected-error@+1 2 {{use of undeclared identifier 'a'}}
a = 2; a = 2; b = 2; b = 2; c = 2;
// expected-error@+1 2 {{asdf}}
d = 2;
e = 2; f = 2; // expected-error 2 {{use of undeclared identifier 'e'}}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void foo() {
// expected-error@+3 {{use of undeclared identifier 'c'}}
// expected-error@+2 2 {{use of undeclared identifier 'b'}}
// expected-error@+1 2 {{use of undeclared identifier 'a'}}
a = 2; a = 2; b = 2; b = 2; c = 2;
// expected-error@+1 {{use of undeclared identifier 'd'}}
d = 2;
// expected-error@+1 {{use of undeclared identifier 'f'}}
e = 2; f = 2; // expected-error {{use of undeclared identifier 'e'}}
}

11 changes: 11 additions & 0 deletions clang/test/utils/update-verify-tests/Inputs/leave-existing-diags.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void foo() {
a = 2;
// expected-error@-1{{use of undeclared identifier 'a'}}
b = 2;// expected-error{{use of undeclared identifier 'b'}}
c = 2;
// expected-error@5{{use of undeclared identifier 'c'}}
d = 2; // expected-error-re{{use of {{.*}} identifier 'd'}}

e = 2; // error to trigger mismatch
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
void foo() {
a = 2;
// expected-error@-1{{use of undeclared identifier 'a'}}
b = 2;// expected-error{{use of undeclared identifier 'b'}}
c = 2;
// expected-error@5{{use of undeclared identifier 'c'}}
d = 2; // expected-error-re{{use of {{.*}} identifier 'd'}}

// expected-error@+1{{use of undeclared identifier 'e'}}
e = 2; // error to trigger mismatch
}

6 changes: 6 additions & 0 deletions clang/test/utils/update-verify-tests/Inputs/multiple-errors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void foo() {
a = 2;
b = 2;

c = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
void foo() {
// expected-error@+1{{use of undeclared identifier 'a'}}
a = 2;
// expected-error@+1{{use of undeclared identifier 'b'}}
b = 2;

// expected-error@+1{{use of undeclared identifier 'c'}}
c = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
void foo() {
a = 2; b = 2; c = 2;
}

void bar() {
x = 2; y = 2; z = 2;
// expected-error@-1{{use of undeclared identifier 'x'}}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
void foo() {
// expected-error@+3{{use of undeclared identifier 'c'}}
// expected-error@+2{{use of undeclared identifier 'b'}}
// expected-error@+1{{use of undeclared identifier 'a'}}
a = 2; b = 2; c = 2;
}

void bar() {
x = 2; y = 2; z = 2;
// expected-error@-1{{use of undeclared identifier 'x'}}
// expected-error@-2{{use of undeclared identifier 'y'}}
// expected-error@-3{{use of undeclared identifier 'z'}}
}
3 changes: 3 additions & 0 deletions clang/test/utils/update-verify-tests/Inputs/no-checks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void foo() {
bar = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void foo() {
// expected-error@+1{{use of undeclared identifier 'bar'}}
bar = 2;
}
5 changes: 5 additions & 0 deletions clang/test/utils/update-verify-tests/Inputs/no-diags.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void foo() {
// expected-error@+1{{asdf}}
int a = 2;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// expected-no-diagnostics
void foo() {
int a = 2;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// expected-no-diagnostics
void foo() {
a = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void foo() {
// expected-error@+1{{use of undeclared identifier 'a'}}
a = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void foo() {
a = 2; // check-error{{asdf}}
// expected-error@-1{ignored}}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void foo() {
a = 2; // check-error{{use of undeclared identifier 'a'}}
// expected-error@-1{ignored}}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void foo() {
bar = 2; // expected-error {{asdf}}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void foo() {
bar = 2; // expected-error {{use of undeclared identifier 'bar'}}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void foo() {
// expected-error@+1{{asdf}}
bar = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void foo() {
// expected-error@+1{{use of undeclared identifier 'bar'}}
bar = 2;
}
4 changes: 4 additions & 0 deletions clang/test/utils/update-verify-tests/duplicate-diag.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUN: cp %S/Inputs/duplicate-diag.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/duplicate-diag.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c

3 changes: 3 additions & 0 deletions clang/test/utils/update-verify-tests/infer-indentation.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RUN: cp %S/Inputs/infer-indentation.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/infer-indentation.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUN: cp %S/Inputs/leave-existing-diags.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/leave-existing-diags.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c

25 changes: 25 additions & 0 deletions clang/test/utils/update-verify-tests/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import lit.util

# python 2.7 backwards compatibility
try:
from shlex import quote as shell_quote
except ImportError:
from pipes import quote as shell_quote

if config.standalone_build:
# These tests require the update-verify-tests.py script from the clang
# source tree, so skip these tests if we are doing standalone builds.
config.unsupported = True
else:
config.suffixes = [".test"]

script_path = os.path.join(
config.clang_src_dir, "utils", "update-verify-tests.py"
)
python = shell_quote(config.python_executable)
config.substitutions.append(
(
"%update-verify-tests",
"%s %s" % (python, shell_quote(script_path)),
)
)
3 changes: 3 additions & 0 deletions clang/test/utils/update-verify-tests/multiple-errors.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RUN: cp %S/Inputs/multiple-errors.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/multiple-errors.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RUN: cp %S/Inputs/multiple-missing-errors-same-line.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/multiple-missing-errors-same-line.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c
3 changes: 3 additions & 0 deletions clang/test/utils/update-verify-tests/no-checks.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RUN: cp %S/Inputs/no-checks.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/no-checks.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c
4 changes: 4 additions & 0 deletions clang/test/utils/update-verify-tests/no-diags.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUN: cp %S/Inputs/no-diags.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/no-diags.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c

4 changes: 4 additions & 0 deletions clang/test/utils/update-verify-tests/no-expected-diags.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUN: cp %S/Inputs/no-expected-diags.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/no-expected-diags.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c

4 changes: 4 additions & 0 deletions clang/test/utils/update-verify-tests/non-default-prefix.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUN: cp %S/Inputs/non-default-prefix.c %t.c && not %clang_cc1 -verify=check %t.c 2>&1 | %update-verify-tests --prefix check
# RUN: diff -u %S/Inputs/non-default-prefix.c.expected %t.c
# RUN: %clang_cc1 -verify=check %t.c

4 changes: 4 additions & 0 deletions clang/test/utils/update-verify-tests/update-same-line.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RUN: cp %S/Inputs/update-same-line.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/update-same-line.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c

3 changes: 3 additions & 0 deletions clang/test/utils/update-verify-tests/update-single-check.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RUN: cp %S/Inputs/update-single-check.c %t.c && not %clang_cc1 -verify %t.c 2>&1 | %update-verify-tests
# RUN: diff -u %S/Inputs/update-single-check.c.expected %t.c
# RUN: %clang_cc1 -verify %t.c
Loading
Loading