Skip to content

Commit e87bec6

Browse files
authored
llvm-reduce: Make some error messages more consistent (#133563)
The coding standards states that error messages should start with a lowercase. Also use WithColor, and add missing test coverage for the failed to write to output file case.
1 parent 1e62a35 commit e87bec6

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# RUN: export LSAN_OPTIONS=detect_leaks=0
22
# RUN: not llvm-reduce --test=%s.NotAFileInTestingDir %p/Inputs/test-output-format.ll 2>&1 | FileCheck -DFILENAME=%s.NotAFileInTestingDir --strict-whitespace %s
33

4-
# CHECK: Error running interesting-ness test: {{(Executable "[[FILENAME]]" doesn't exist$)?(program not executable$)?}}
4+
# CHECK: error: running interesting-ness test: {{(Executable "[[FILENAME]]" doesn't exist$)?(program not executable$)?}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Python on an empty file will always succeed as interesting
2+
# RUN: touch %t
3+
4+
# Fail on attempt to write output to a directory
5+
# RUN: not llvm-reduce --delta-passes=instructions -o %p/Inputs --test %python --test-arg %t %p/Inputs/test-output-format.ll 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
6+
7+
# CHECK: error: opening output file: [[MSG]]

llvm/tools/llvm-reduce/TestRunner.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ int TestRunner::run(StringRef Filename) const {
4545
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
4646

4747
if (Result < 0) {
48-
Error E = make_error<StringError>("Error running interesting-ness test: " +
49-
ErrMsg,
50-
inconvertibleErrorCode());
48+
Error E = make_error<StringError>(
49+
"running interesting-ness test: " + ErrMsg, inconvertibleErrorCode());
5150
WithColor::error(errs(), ToolName) << toString(std::move(E)) << '\n';
5251
exit(1);
5352
}
@@ -61,7 +60,8 @@ void TestRunner::writeOutput(StringRef Message) {
6160
EmitBitcode && !Program->isMIR() ? sys::fs::OF_None
6261
: sys::fs::OF_Text);
6362
if (EC) {
64-
errs() << "Error opening output file: " << EC.message() << "!\n";
63+
WithColor::error(errs(), ToolName)
64+
<< "opening output file: " << EC.message() << '\n';
6565
exit(1);
6666
}
6767

0 commit comments

Comments
 (0)