Răsfoiți Sursa

Filecheck: Allow empty stderr input; replace last couple errs() uses (#3588)

Tex Riddell 4 ani în urmă
părinte
comite
facf8b765a

+ 2 - 2
tools/clang/unittests/HLSLTestLib/FileCheckForTest.cpp

@@ -1333,14 +1333,14 @@ int run_main() {
     MemoryBuffer::getMemBuffer(MemoryBufferRef(StringRef(InputForStdin), "-")) :
     MemoryBuffer::getMemBuffer(MemoryBufferRef(StringRef(InputForStdin), "-")) :
     MemoryBuffer::getFile(InputFilename);
     MemoryBuffer::getFile(InputFilename);
   if (std::error_code EC = FileOrErr.getError()) {
   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';
       << "': " << EC.message() << '\n';
     return 2;
     return 2;
   }
   }
   std::unique_ptr<MemoryBuffer> &File = FileOrErr.get();
   std::unique_ptr<MemoryBuffer> &File = FileOrErr.get();
 
 
   if (File->getBufferSize() == 0 && !AllowEmptyInput) {
   if (File->getBufferSize() == 0 && !AllowEmptyInput) {
-    errs() << "FileCheck error: '" << InputFilename << "' is empty.\n";
+    test_errs << "FileCheck error: '" << InputFilename << "' is empty.\n";
     return 2;
     return 2;
   }
   }
 
 

+ 4 - 2
tools/clang/unittests/HLSLTestLib/FileCheckerTest.cpp

@@ -139,8 +139,10 @@ FileRunCommandResult FileRunCommandPart::RunFileChecker(const FileRunCommandResu
   auto args = strtok(Arguments);
   auto args = strtok(Arguments);
   for (const std::string& arg : args) {
   for (const std::string& arg : args) {
     if (arg == "%s") hasInputFilename = true;
     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));
       t.CheckPrefixes.emplace_back(arg.substr(sizeof(checkPrefixStr) - 1));
     else if (strstartswith(arg, checkPrefixesStr)) {
     else if (strstartswith(arg, checkPrefixesStr)) {
       auto prefixes = strtok(arg.substr(sizeof(checkPrefixesStr) - 1), ", ");
       auto prefixes = strtok(arg.substr(sizeof(checkPrefixesStr) - 1), ", ");