@@ -49,128 +49,18 @@ working, so you may have to wait for us to address 5C-specific
49
49
problems arising from your 3C pull request and/or we may ask you to
50
50
make specific changes to your pull request to accommodate 5C's code.
51
51
52
- ## Testing
53
-
54
- 3C has a regression test suite located in ` clang/test/3C ` . At the
55
- appropriate time during development of a pull request, please run it
56
- and correct any failures. (For example, it may not make sense to run
57
- it on a draft pull request containing an unfinished demonstration of
58
- an idea.) The easiest way to run it is to run the following in your
59
- build directory:
60
-
61
- ```
62
- ninja check-3c
63
- ```
64
-
65
- This command will build everything needed that hasn't already been
66
- built, run the test suite, report success or failure (exit 0 or 1, so
67
- you can use it in scripts), and display some information about any
68
- failures, which may or may not be enough for you to understand what
69
- went wrong.
70
-
71
- For deeper troubleshooting, run the following in your build directory
72
- to build all dependencies of the test suite:
73
-
74
- ```
75
- ninja check-3c-deps
76
- ```
77
-
78
- Then run the following in the ` clang/test/3C ` directory:
79
-
80
- ```
81
- llvm-lit -vv TEST.c
82
- ```
83
-
84
- where ` TEST.c ` is the path of the test you want to run (you can also
85
- specify more than one test). This assumes you've put the ` bin `
86
- subdirectory of your build directory on your ` $PATH ` or arranged some
87
- other means of running ` llvm-lit ` from there. The first ` -v ` makes
88
- ` llvm-lit ` display the stdout and stderr of failed tests; the second
89
- makes it display the ` RUN ` commands as they execute so you can tell
90
- which one failed.
91
-
92
- Every ` .c ` file under ` clang/test/3C ` is a test file. There are a few
93
- in subdirectories, so ` *.c ` will not pick up all of them; instead you
94
- can use ` llvm-lit -vv . ` to specify all test files under the current
95
- directory.
96
-
97
- ### Diagnostic verification
98
-
99
- 3C supports the standard Clang diagnostic verifier
100
- ([ ` VerifyDiagnosticConsumer ` ] ( https://clang.llvm.org/doxygen/classclang_1_1VerifyDiagnosticConsumer.html#details ) )
101
- for testing errors and warnings reported by 3C via its main ` DiagnosticsEngine ` .
102
- (Some 3C errors and warnings are reported via other means and cannot be tested
103
- this way; the best solution we have for them right now is to ` grep ` the stderr
104
- of 3C.) Diagnostic verification can be enabled via the usual ` -Xclang -verify `
105
- compiler option; other diagnostic verification options (`-Xclang
106
- -verify=PREFIX`, etc.) should also work as normal. These must be passed as
107
- _ compiler_ options, not ` 3c ` options; for example, if you are using ` -- ` on the
108
- ` 3c ` command line, these options must be passed _ after_ the ` -- ` .
109
-
110
- Some notes about diagnostic verification in the context of 3C:
111
-
112
- * Parsing of the source files uses some of the compiler logic and thus may
113
- generate compiler warnings, just as if you ran ` clang ` on the code. These are
114
- sent to the diagnostic verifier along with diagnostics generated by 3C's
115
- analysis. If you find it distracting to have to include the compiler warnings
116
- in the set of expected diagnostics for a test, you can turn them off via the
117
- ` -Wno-everything ` compiler option (which does not affect diagnostics generated
118
- by 3C's analysis).
119
-
120
- * The ` 3c ` tool works in several passes, where each pass runs on all translation
121
- units: first ` 3c ` parses the source files, then it runs several passes of
122
- analysis. If a pass encounters at least one error, ` 3c ` exits at the end of
123
- that pass. Diagnostic verification does not change the _ point_ at which ` 3c `
124
- exits, but it changes the exit _ code_ to indicate the result of verification
125
- rather than the presence of errors. The verification includes the diagnostics
126
- from all passes up to the point at which ` 3c ` exits (i.e., the same
127
- diagnostics that would be displayed if verification were not used). However,
128
- an error that doesn't go via the main ` DiagnosticsEngine ` will cause an
129
- unsuccessful exit code regardless of diagnostic verification. (This is
130
- typically the behavior you want for a test.)
131
-
132
- * Diagnostic verification is independent for each translation unit, so in tests
133
- with multiple translation units, you'll have to be careful that preprocessing
134
- of each translation unit sees the correct set of ` expected-* ` directives for
135
- the diagnostics generated for that translation unit (or an
136
- ` expected-no-diagnostics ` directive if that translation unit generates no
137
- diagnostics, even if other translation units do generate diagnostics). Be
138
- warned that since which translation unit generated a given diagnostic isn't
139
- visible to a normal user, we don't put much work into coming up with sensible
140
- rules for this, but it should at least be deterministic for testing.
141
-
142
- Note that some 3C tests use diagnostic verification on calls to ` clang ` rather
143
- than ` 3c ` , so if you see ` expected-* ` directives in a test, you can look at the
144
- ` RUN ` commands to see which command has ` -Xclang -verify ` and is using the
145
- directives. If you want to verify diagnostics of more than one ` RUN ` command in
146
- the same test, you can use different directive prefixes (`-Xclang
147
- -verify=PREFIX`).
148
-
149
- ## Coding guidelines
150
-
151
- Please follow [ LLVM coding
152
- standards] ( https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly )
153
- in your code. Specifically:
154
-
155
- * The maximum length of a line: 80 chars
156
-
157
- * All comments should start with a Capital letter.
158
-
159
- * All Local variables, including fields and parameters, should start
160
- with a Capital letter (similar to PascalCase). Short names are
161
- preferred.
162
-
163
- * A space between the conditional keyword and ` ( ` i.e., ` if ( ` ,
164
- ` while ( ` , ``for (` etc.
165
-
166
- * Space after the type name, i.e., ` Type *K ` _ not_ ` Type* K ` .
167
-
168
- * Space before and after ` : ` in iterators, i.e., ` for (auto &k : List) `
169
-
170
- Our goal is that all files should be formatted with ` clang-format ` and
171
- pass ` clang-tidy ` ([ more information] ( clang-tidy.md ) ), and nonempty
172
- files should have a final newline (surprisingly, ` clang-format ` cannot
173
- enforce this). However, until we have better automation, we decided it
174
- isn't reasonable to require contributors to manually run these tools
175
- and fix style nits in each change; instead, we periodically run the
176
- tools on the entire 3C codebase.
52
+ At the appropriate time during development of a pull request, please
53
+ run the [ regression tests] ( development.md#regression-tests ) and
54
+ correct any failures. (For example, it may not make sense to do this
55
+ on a draft pull request containing an unfinished demonstration of an
56
+ idea.) All regression tests must pass (or be disabled if appropriate)
57
+ before your pull request can be merged. If you're changing behavior
58
+ (as opposed to just cleaning up the code), we'll typically require you
59
+ to add or update enough tests to exercise the important behavior
60
+ changes (i.e., those tests fail before your code change and pass after
61
+ it). If there's a concern that your change might affect other cases
62
+ that are not adequately tested yet, we may ask you to add tests for
63
+ those cases as well.
64
+
65
+ See the [ developer's guide] ( development.md ) for additional information
66
+ that may be helpful as you work on 3C.
0 commit comments