From d049cc23c693d1b3de4a9c908da3db5d8d1f70c2 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Mon, 1 May 2017 22:36:57 -0700 Subject: [PATCH] Notes on what e2e testing will look like. --- test_runner_e2e.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 test_runner_e2e.py diff --git a/test_runner_e2e.py b/test_runner_e2e.py new file mode 100644 index 00000000..5ea480ec --- /dev/null +++ b/test_runner_e2e.py @@ -0,0 +1,72 @@ +import shlex +from subprocess import Popen, PIPE + +# We write test files in python. The test runner collects all python files in +# the directory and executes them. The test function just creates a test object +# which specifies expected stdin/stdout. +# +# Test functions are automatically discovered; they just need to be in the +# global environment and start with `Test_`. + +class TestBuilder: + def WithFile(self, filename, contents): + """ + Writes the file contents to disk so that the language server can access it. + """ + pass + + def Send(self, stdin): + """ + Send the given message to the language server. + """ + + # Content-Length: ...\r\n + # \r\n + # { + # "jsonrpc": "2.0", + # "id": 1, + # "method": "textDocument/didOpen", + # "params": { + # ... + # } + # } + + def Expect(self, stdout): + """ + Expect a message from the language server. + """ + pass + + def SetupCommonInit(): + """ + Add initialize/initialized messages. + """ + pass + + +def Test_Outline(): + return TestBuilder() + .SetupCommonInit() + .WithFile("foo.cc", + """ + void main() {} + """ + ) + .Send({ + 'id': 1, + 'method': 'textDocument/documentSymbol', + 'params': {} + }) + .Expect({ + 'id': 1 + 'result': [ + lsSymbolInfo('void main()', (1, 1), lsSymbolKind.Function) + ] + }) + + +# Possible test runner implementation +# cmd = "x64/Release/indexer.exe --language-server" +# process = Popen(shlex.split(cmd), stdin=PIPE, stdout=PIPE) +# process.communicate('{}') +# exit_code = process.wait() \ No newline at end of file