Skip to content

Commit b1745b6

Browse files
Convert the rest of the tests managed by the "test updating programs" to
3c-regtest. Made needed enhancements to the 3c-regtest tools: - Add support for the rest of the RUN scripts. - Add support for RUN scripts with blank lines in the middle, as used by the common-testgenerator script. A few tests are failing verification, i.e., their existing RUN scripts didn't match the ones generated by the test updating programs. To investigate.
1 parent 17f60c0 commit b1745b6

File tree

276 files changed

+406
-2332
lines changed

Some content is hidden

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

276 files changed

+406
-2332
lines changed

clang/test/3C/3c-regtest-unconvert.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,25 @@
3030
with open(argobj.test_file) as f:
3131
lines = f.readlines()
3232

33-
m = re.search(r"\A// RUN: %S/3c-regtest\.py (.*) %s -t %t --clang '%clang'\n\Z", lines[0])
34-
if m is None:
35-
sys.exit('The first line of %s is not a canonical 3c-regtest.py RUN line.' % argobj.test_file)
36-
test_type_flags_joined = m.group(1)
37-
38-
# FUTURE: Will we need to handle quoting?
39-
test_type_flags = test_type_flags_joined.split(' ')
40-
# XXX: This just exits on error. We'd like to add a more meaningful message, but
41-
# the default Python version on gamera (2.7.18) is too old to support
42-
# exit_on_error=False.
43-
test_type_argobj = script_generator.parser.parse_args(test_type_flags + [argobj.test_file])
44-
45-
run_lines = ['// RUN: %s\n' % cmd for cmd in script_generator.generate_commands(test_type_argobj)]
46-
new_lines = run_lines + lines[1:]
33+
new_lines = []
34+
for l in lines:
35+
if '3c-regtest' in l:
36+
m = re.search(r"\A// RUN: %S/3c-regtest\.py (.*) %s -t %t --clang '%clang'\n\Z", l)
37+
if m is None:
38+
sys.exit('Non-canonical 3c-regtest RUN line: %s' % l) # XXX Trailing newline
39+
test_type_flags_joined = m.group(1)
40+
41+
# FUTURE: Will we need to handle quoting?
42+
test_type_flags = test_type_flags_joined.split(' ')
43+
# XXX: This just exits on error. We'd like to add a more meaningful message, but
44+
# the default Python version on gamera (2.7.18) is too old to support
45+
# exit_on_error=False.
46+
test_type_argobj = script_generator.parser.parse_args(test_type_flags + [argobj.test_file])
47+
48+
run_lines = [('// RUN: %s\n' % cmd if cmd != '' else '\n')
49+
for cmd in script_generator.generate_commands(test_type_argobj)]
50+
new_lines.extend(run_lines)
51+
else:
52+
new_lines.append(l)
53+
4754
sys.stdout.write(''.join(new_lines))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Usage: ./3c-regtest-verify-all-conversions.sh BASE_TREEISH
3+
#
4+
# BASE_TREEISH has the original versions of the tests to compare to. Typically,
5+
# it would be origin/test-command-refactoring.verify-base .
6+
#
7+
# This takes a little while, so you may want to redirect the output to a file
8+
# and view it later
9+
10+
set -e
11+
set -o pipefail
12+
base_commit="$1"
13+
git rev-parse "$base_commit^{tree}" &>/dev/null || { echo >&2 'Invalid base tree'; exit 1; }
14+
15+
for f in $(git grep --files-with-matches '3c-regtest' *.c); do
16+
./3c-regtest-unconvert.py $f | {
17+
diff --label $f.orig --label $f.unconvert -u <(git show "$base_commit":./$f) - || [ $? == 1 ]
18+
}
19+
done

clang/test/3C/3c-regtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
('#_MARKER_#', '%')
6767
]
6868

69-
commands = script_generator.generate_commands(argobj)
69+
commands = [cmd for cmd in script_generator.generate_commands(argobj) if cmd != '']
7070
commands = lit.TestRunner.applySubstitutions(commands, substitutions)
7171

7272
class FakeTestConfig:

clang/test/3C/3d-allocation.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// RUN: 3c -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
2-
// RUN: 3c -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
3-
// RUN: 3c -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
4-
// RUN: 3c -output-postfix=checked -alltypes %s
5-
// RUN: 3c -alltypes %S/3d-allocation.checked.c -- | count 0
6-
// RUN: rm %S/3d-allocation.checked.c
1+
// RUN: %S/3c-regtest.py --predefined-script common %s -t %t --clang '%clang'
72

83
#include <stdio.h>
94
#include <stdlib.h>

clang/test/3C/alloc_type_param.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// RUN: 3c -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
2-
// RUN: 3c -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
3-
// RUN: 3c -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
4-
// RUN: 3c -output-postfix=checked -alltypes %s
5-
// RUN: 3c -alltypes %S/alloc_type_param.checked.c -- | count 0
6-
// RUN: rm %S/alloc_type_param.checked.c
1+
// RUN: %S/3c-regtest.py --predefined-script common %s -t %t --clang '%clang'
72

83
#include <stddef.h>
94
extern _Itype_for_any(T) void *calloc(size_t nmemb, size_t size) : itype(_Array_ptr<T>) byte_count(nmemb * size);

clang/test/3C/amper.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// RUN: 3c -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
2-
// RUN: 3c -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
3-
// RUN: 3c -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
4-
// RUN: 3c -output-postfix=checked -alltypes %s
5-
// RUN: 3c -alltypes %S/amper.checked.c -- | count 0
6-
// RUN: rm %S/amper.checked.c
1+
// RUN: %S/3c-regtest.py --predefined-script common %s -t %t --clang '%clang'
72

83
void foo(int *x) {
94
//CHECK: void foo(int *x : itype(_Ptr<int>)) {

clang/test/3C/arrboth.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
// RUN: 3c -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
2-
// RUN: 3c -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
3-
// RUN: 3c -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
4-
5-
// RUN: 3c -alltypes -output-postfix=checked %s
6-
// RUN: 3c -alltypes %S/arrboth.checked.c -- | count 0
7-
// RUN: rm %S/arrboth.checked.c
1+
// RUN: %S/3c-regtest.py --predefined-script common-testgenerator %s -t %t --clang '%clang'
82

93

104
/*********************************************************************************/

clang/test/3C/arrbothmulti1.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
// RUN: 3c -base-dir=%S -addcr -alltypes -output-postfix=checkedALL %s %S/arrbothmulti2.c
2-
// RUN: 3c -base-dir=%S -addcr -output-postfix=checkedNOALL %s %S/arrbothmulti2.c
3-
// RUN: %clang -c %S/arrbothmulti1.checkedNOALL.c %S/arrbothmulti2.checkedNOALL.c
4-
// RUN: FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" --input-file %S/arrbothmulti1.checkedNOALL.c %s
5-
// RUN: FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" --input-file %S/arrbothmulti1.checkedALL.c %s
6-
// RUN: 3c -base-dir=%S -alltypes -output-postfix=checked %S/arrbothmulti2.c %s
7-
// RUN: 3c -base-dir=%S -alltypes -output-postfix=convert_again %S/arrbothmulti1.checked.c %S/arrbothmulti2.checked.c
8-
// RUN: test ! -f %S/arrbothmulti1.checked.convert_again.c
9-
// RUN: test ! -f %S/arrbothmulti2.checked.convert_again.c
10-
// RUN: rm %S/arrbothmulti1.checkedALL.c %S/arrbothmulti2.checkedALL.c
11-
// RUN: rm %S/arrbothmulti1.checkedNOALL.c %S/arrbothmulti2.checkedNOALL.c
12-
// RUN: rm %S/arrbothmulti1.checked.c %S/arrbothmulti2.checked.c
1+
// RUN: %S/3c-regtest.py --predefined-script multi %s -t %t --clang '%clang'
132

143

154
/*********************************************************************************/

clang/test/3C/arrbothmulti2.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
// RUN: 3c -base-dir=%S -addcr -alltypes -output-postfix=checkedALL2 %S/arrbothmulti1.c %s
2-
// RUN: 3c -base-dir=%S -addcr -output-postfix=checkedNOALL2 %S/arrbothmulti1.c %s
3-
// RUN: %clang -c %S/arrbothmulti1.checkedNOALL2.c %S/arrbothmulti2.checkedNOALL2.c
4-
// RUN: FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" --input-file %S/arrbothmulti2.checkedNOALL2.c %s
5-
// RUN: FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" --input-file %S/arrbothmulti2.checkedALL2.c %s
6-
// RUN: 3c -base-dir=%S -alltypes -output-postfix=checked2 %S/arrbothmulti1.c %s
7-
// RUN: 3c -base-dir=%S -alltypes -output-postfix=convert_again %S/arrbothmulti1.checked2.c %S/arrbothmulti2.checked2.c
8-
// RUN: test ! -f %S/arrbothmulti1.checked2.convert_again.c
9-
// RUN: test ! -f %S/arrbothmulti2.checked2.convert_again.c
10-
// RUN: rm %S/arrbothmulti1.checkedALL2.c %S/arrbothmulti2.checkedALL2.c
11-
// RUN: rm %S/arrbothmulti1.checkedNOALL2.c %S/arrbothmulti2.checkedNOALL2.c
12-
// RUN: rm %S/arrbothmulti1.checked2.c %S/arrbothmulti2.checked2.c
1+
// RUN: %S/3c-regtest.py --predefined-script multi %s -t %t --clang '%clang'
132

143

154
/*********************************************************************************/

clang/test/3C/arrcallee.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
// RUN: 3c -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
2-
// RUN: 3c -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
3-
// RUN: 3c -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
4-
5-
// RUN: 3c -alltypes -output-postfix=checked %s
6-
// RUN: 3c -alltypes %S/arrcallee.checked.c -- | count 0
7-
// RUN: rm %S/arrcallee.checked.c
1+
// RUN: %S/3c-regtest.py --predefined-script common-testgenerator %s -t %t --clang '%clang'
82

93

104
/*********************************************************************************/

0 commit comments

Comments
 (0)