[llvm-debuginfod-find] Fix test/behavior on Windows.
authorDaniel Thornburgh <dthorn@google.com>
Tue, 8 Nov 2022 17:51:52 +0000 (09:51 -0800)
committerDaniel Thornburgh <dthorn@google.com>
Tue, 8 Nov 2022 17:52:33 +0000 (09:52 -0800)
llvm/lib/Debuginfod/Debuginfod.cpp
llvm/test/tools/llvm-debuginfod-find/headers.test

index f20b5bc..3fde873 100644 (file)
@@ -195,6 +195,8 @@ static SmallVector<std::string, 0> getHeaders() {
   uint64_t LineNumber = 0;
   for (StringRef Line : llvm::split((*HeadersFile)->getBuffer(), '\n')) {
     LineNumber++;
+    if (!Line.empty() && Line.back() == '\r')
+      Line = Line.drop_back();
     if (!isHeader(Line)) {
       if (!all_of(Line, llvm::isSpace))
         WithColor::warning()
@@ -202,8 +204,6 @@ static SmallVector<std::string, 0> getHeaders() {
             << LineNumber << '\n';
       continue;
     }
-    if (Line.back() == '\r')
-      Line = Line.drop_back();
     Headers.emplace_back(Line);
   }
   return Headers;
index 6fe814d..aaf20d4 100644 (file)
@@ -2,13 +2,13 @@ REQUIRES: curl
 
 RUN: %python %S/Inputs/capture_req.py llvm-debuginfod-find --debuginfo 0 \
 RUN:   | FileCheck --check-prefix NO-HEADERS %s
-RUN: DEBUGINFOD_HEADERS_FILE=bad %python %S/Inputs/capture_req.py \
+RUN: env DEBUGINFOD_HEADERS_FILE=bad %python %S/Inputs/capture_req.py \
 RUN:   llvm-debuginfod-find --debuginfo 0 \
 RUN:   | FileCheck --check-prefix NO-HEADERS %s
-RUN: DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers %python %S/Inputs/capture_req.py \
+RUN: env DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers %python %S/Inputs/capture_req.py \
 RUN:   llvm-debuginfod-find --debuginfo 0 \
 RUN:   | FileCheck --check-prefix HEADERS %s
-RUN: DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers DEBUGINFOD_URLS=fake not llvm-debuginfod-find --debuginfo 0 2>&1 \
+RUN: env DEBUGINFOD_HEADERS_FILE=%S/Inputs/headers DEBUGINFOD_URLS=fake not llvm-debuginfod-find --debuginfo 0 2>&1 \
 RUN:   | FileCheck --check-prefix ERR -DHEADER_FILE=%S/Inputs/headers %s
 
 NO-HEADERS: Accept: */*