[PATCH] D83759: [clangd] Port lit tests to Windows

Aleksandr Platonov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 14 04:10:41 PDT 2020


ArcsinX created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Changes:

- `background-index.test` Add Windows support.
- `dependency-output.test` Split into two tests (Windows and Posix).
- `did-change-configuration-params.test` Split into two tests (Windows and Posix).
- `test-uri-windows.test` This test did not run on Windows displite `REQUIRES: windows-gnu || windows-msvc` (replacement: `UNSUPPORTED: !(windows-gnu || windows-msvc)`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83759

Files:
  clang-tools-extra/clangd/test/background-index.test
  clang-tools-extra/clangd/test/dependency-output-posix.test
  clang-tools-extra/clangd/test/dependency-output-windows.test
  clang-tools-extra/clangd/test/dependency-output.test
  clang-tools-extra/clangd/test/did-change-configuration-params-posix.test
  clang-tools-extra/clangd/test/did-change-configuration-params-windows.test
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/test/test-uri-windows.test


Index: clang-tools-extra/clangd/test/test-uri-windows.test
===================================================================
--- clang-tools-extra/clangd/test/test-uri-windows.test
+++ clang-tools-extra/clangd/test/test-uri-windows.test
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# REQUIRES: windows-gnu || windows-msvc
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 # Test authority-less URI
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/did-change-configuration-params-windows.test
===================================================================
--- clang-tools-extra/clangd/test/did-change-configuration-params-windows.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params-windows.test
@@ -1,9 +1,9 @@
 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck -strict-whitespace %s
-# RUN: cat %t | FileCheck --check-prefix=ERR %s
-# UNSUPPORTED: windows-gnu,windows-msvc
+# RUN: FileCheck --check-prefix=ERR --input-file=%t %s
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", "foo.c"]}}}}}
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"C:\\clangd-test\\foo.c": {"workingDirectory":"C:\\clangd-test", "compilationCommand": ["clang", "-c", "foo.c"]}}}}}
 ---
 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","text":"int main() { int i; return i; }"}}}
 #      CHECK:  "method": "textDocument/publishDiagnostics",
@@ -21,7 +21,7 @@
 # CHECK-NEXT:    "version": 0
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test2", "compilationCommand": ["clang", "-c", "foo.c", "-Wall", "-Werror"]}}}}}
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"C:\\clangd-test\\foo.c": {"workingDirectory":"C:\\clangd-test2", "compilationCommand": ["clang", "-c", "foo.c", "-Wall", "-Werror"]}}}}}
 #      CHECK:  "method": "textDocument/publishDiagnostics",
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:    "diagnostics": [
@@ -53,5 +53,3 @@
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
 {"jsonrpc":"2.0","method":"exit"}
-
-
Index: clang-tools-extra/clangd/test/did-change-configuration-params-posix.test
===================================================================
--- clang-tools-extra/clangd/test/did-change-configuration-params-posix.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params-posix.test
@@ -1,5 +1,5 @@
 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck -strict-whitespace %s
-# RUN: cat %t | FileCheck --check-prefix=ERR %s
+# RUN: FileCheck --check-prefix=ERR --input-file=%t %s
 # UNSUPPORTED: windows-gnu,windows-msvc
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
@@ -53,5 +53,3 @@
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
 {"jsonrpc":"2.0","method":"exit"}
-
-
Index: clang-tools-extra/clangd/test/dependency-output-windows.test
===================================================================
--- clang-tools-extra/clangd/test/dependency-output-windows.test
+++ clang-tools-extra/clangd/test/dependency-output-windows.test
@@ -1,9 +1,9 @@
-# UNSUPPORTED: windows-gnu,windows-msvc
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c":
-{"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", "-Xclang", "--show-includes", "-Xclang", "-sys-header-deps", "foo.c"]}}}}}
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"C:\\clangd-test\\foo.c":
+{"workingDirectory":"C:\\clangd-test", "compilationCommand": ["clang", "-c", "-Xclang", "--show-includes", "-Xclang", "-sys-header-deps", "foo.c"]}}}}}
 ---
 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"cpp","version":1,"text":"int a;\n#include <stddef.h>"}}}
 #CHECK-NOT: Note: including file
Index: clang-tools-extra/clangd/test/background-index.test
===================================================================
--- clang-tools-extra/clangd/test/background-index.test
+++ clang-tools-extra/clangd/test/background-index.test
@@ -1,12 +1,12 @@
-# We need to splice paths into file:// URIs for this test.
-# UNSUPPORTED: windows-msvc
-
 # Use a copy of inputs, as we'll mutate it (as will the background index).
 # RUN: rm -rf %t
 # RUN: cp -r %S/Inputs/background-index %t
 # Need to embed the correct temp path in the actual JSON-RPC requests.
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/definition.jsonrpc
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/compile_commands.json
+# RUN: sed -i -e "s|DIRECTORY|%/t|" %t/definition.jsonrpc
+# RUN: sed -i -e "s|DIRECTORY|%/t|" %t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
+# (with the extra slash in the front), so we add it here.
+# RUN: sed -i -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %t/definition.jsonrpc
 
 # We're editing bar.cpp, which includes foo.h.
 # foo() is declared in foo.h and defined in foo.cpp.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83759.277768.patch
Type: text/x-patch
Size: 6059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200714/13935d9b/attachment.bin>


More information about the cfe-commits mailing list