mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
SKCore,SKTestSupport: adjust test server handling
The test system depended on the shebang to locate the python interpreter. However, this is not a portable system. Instead, prefer to explicitly search for the interpreter prior to the execution. This enables supporting execution of the script support on all platforms. A secondary change of the printed string is required for Windows. Python will replace `\n` with `\r\n` resulting in `\r\n` being emitted as `\r\r\n` on Windows breaking the expectations on the receiver. Adjust this by explicitly writing out a binary string to the raw underlying buffer to avoid the translation.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
@@ -93,7 +91,7 @@ while True:
|
||||
if response:
|
||||
responseStr = json.dumps(response)
|
||||
try:
|
||||
sys.stdout.write("Content-Length: {}\r\n\r\n{}".format(len(responseStr), responseStr))
|
||||
sys.stdout.buffer.write(f"Content-Length: {len(responseStr)}\r\n\r\n{responseStr}".encode('utf-8'))
|
||||
sys.stdout.flush()
|
||||
except IOError:
|
||||
# stdout closed, time to quit
|
||||
|
||||
Reference in New Issue
Block a user