Skip to content

Commit ab2c9dc

Browse files
authored
Update the file_test readme with API and fail_ notes. (#3793)
Also a minor example update.
1 parent d939262 commit ab2c9dc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

testing/file_test/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ A typical implementation will look like:
3333
```
3434
#include "my_library.h"
3535
36-
#include "llvm/ADT/StringExtras.h"
3736
#include "testing/file_test/file_test_base.h"
3837
3938
namespace Carbon::Testing {
@@ -47,8 +46,8 @@ class MyFileTest : public FileTestBase {
4746
auto Run(const llvm::SmallVector<llvm::StringRef>& test_args,
4847
const llvm::SmallVector<TestFile>& test_files,
4948
llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr)
50-
-> ErrorOr<bool> override {
51-
MyFunctionality(test_args, stdout, stderr);
49+
-> ErrorOr<RunResult> override {
50+
return MyFunctionality(test_args, stdout, stderr);
5251
}
5352
5453
// Provides arguments which are used in tests that don't provide ARGS.
@@ -65,6 +64,17 @@ CARBON_FILE_TEST_FACTORY(MyFileTest);
6564
} // namespace Carbon::Testing
6665
```
6766

67+
## Filename `fail_` prefixes
68+
69+
When a run fails, information about what pieces failed are returned on
70+
`RunResult`. This affects whether a `fail_` prefix on the file is required,
71+
including in combination with split-file tests (using the `// --- <filename>`
72+
comment marker).
73+
74+
The main test file and any split-files must have a `fail_` prefix if and only if
75+
they have an associated error. An exception is that the main test file may omit
76+
`fail_` when it contains split-files that have a `fail_` prefix.
77+
6878
## Comment markers
6979

7080
Settings in files are provided in comments, similar to `FileCheck` syntax.

0 commit comments

Comments
 (0)