From 92fa2508c448b45752ab68b640dd92f339302161 Mon Sep 17 00:00:00 2001 From: Tex Riddell Date: Tue, 16 Mar 2021 08:22:34 -0700 Subject: [PATCH] Filecheck: Allow empty stderr input; replace last couple errs() uses (#3588) --- tools/clang/unittests/HLSLTestLib/FileCheckForTest.cpp | 4 ++-- tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/clang/unittests/HLSLTestLib/FileCheckForTest.cpp b/tools/clang/unittests/HLSLTestLib/FileCheckForTest.cpp index ea3b58d44..308d9e23d 100644 --- a/tools/clang/unittests/HLSLTestLib/FileCheckForTest.cpp +++ b/tools/clang/unittests/HLSLTestLib/FileCheckForTest.cpp @@ -1333,14 +1333,14 @@ int run_main() { MemoryBuffer::getMemBuffer(MemoryBufferRef(StringRef(InputForStdin), "-")) : MemoryBuffer::getFile(InputFilename); if (std::error_code EC = FileOrErr.getError()) { - errs() << "Could not open input file '" << InputFilename + test_errs << "Could not open input file '" << InputFilename << "': " << EC.message() << '\n'; return 2; } std::unique_ptr &File = FileOrErr.get(); if (File->getBufferSize() == 0 && !AllowEmptyInput) { - errs() << "FileCheck error: '" << InputFilename << "' is empty.\n"; + test_errs << "FileCheck error: '" << InputFilename << "' is empty.\n"; return 2; } diff --git a/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp b/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp index 87209490f..fbfb62f87 100644 --- a/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp +++ b/tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp @@ -139,8 +139,10 @@ FileRunCommandResult FileRunCommandPart::RunFileChecker(const FileRunCommandResu auto args = strtok(Arguments); for (const std::string& arg : args) { if (arg == "%s") hasInputFilename = true; - else if (arg == "-input=stderr") t.InputForStdin = Prior->StdErr; - else if (strstartswith(arg, checkPrefixStr)) + else if (arg == "-input=stderr") { + t.InputForStdin = Prior->StdErr; + t.AllowEmptyInput = true; + } else if (strstartswith(arg, checkPrefixStr)) t.CheckPrefixes.emplace_back(arg.substr(sizeof(checkPrefixStr) - 1)); else if (strstartswith(arg, checkPrefixesStr)) { auto prefixes = strtok(arg.substr(sizeof(checkPrefixesStr) - 1), ", ");