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.
diff --git a/llvm/test/tools/llvm-reduce/fail-execute-test.test b/llvm/test/tools/llvm-reduce/fail-execute-test.test
index f60107f..1b3266e 100644
--- a/llvm/test/tools/llvm-reduce/fail-execute-test.test
+++ b/llvm/test/tools/llvm-reduce/fail-execute-test.test
@@ -1,4 +1,4 @@
# RUN: export LSAN_OPTIONS=detect_leaks=0
# RUN: not llvm-reduce --test=%s.NotAFileInTestingDir %p/Inputs/test-output-format.ll 2>&1 | FileCheck -DFILENAME=%s.NotAFileInTestingDir --strict-whitespace %s
-# CHECK: Error running interesting-ness test: {{(Executable "[[FILENAME]]" doesn't exist$)?(program not executable$)?}}
+# CHECK: error: running interesting-ness test: {{(Executable "[[FILENAME]]" doesn't exist$)?(program not executable$)?}}
diff --git a/llvm/test/tools/llvm-reduce/fail-output-file.test b/llvm/test/tools/llvm-reduce/fail-output-file.test
new file mode 100644
index 0000000..7696570
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/fail-output-file.test
@@ -0,0 +1,7 @@
+# Python on an empty file will always succeed as interesting
+# RUN: touch %t
+
+# Fail on attempt to write output to a directory
+# 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
+
+# CHECK: error: opening output file: [[MSG]]
diff --git a/llvm/tools/llvm-reduce/TestRunner.cpp b/llvm/tools/llvm-reduce/TestRunner.cpp
index aac5c4a..ad9f925 100644
--- a/llvm/tools/llvm-reduce/TestRunner.cpp
+++ b/llvm/tools/llvm-reduce/TestRunner.cpp
@@ -45,9 +45,8 @@
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
if (Result < 0) {
- Error E = make_error<StringError>("Error running interesting-ness test: " +
- ErrMsg,
- inconvertibleErrorCode());
+ Error E = make_error<StringError>(
+ "running interesting-ness test: " + ErrMsg, inconvertibleErrorCode());
WithColor::error(errs(), ToolName) << toString(std::move(E)) << '\n';
exit(1);
}
@@ -61,7 +60,8 @@
EmitBitcode && !Program->isMIR() ? sys::fs::OF_None
: sys::fs::OF_Text);
if (EC) {
- errs() << "Error opening output file: " << EC.message() << "!\n";
+ WithColor::error(errs(), ToolName)
+ << "opening output file: " << EC.message() << '\n';
exit(1);
}