mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-06 18:24:36 +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 os
|
||||
import sys
|
||||
@@ -8,7 +6,7 @@ import sys
|
||||
def send(data):
|
||||
dataStr = json.dumps(data)
|
||||
try:
|
||||
sys.stdout.write("Content-Length: {}\r\n\r\n{}".format(len(dataStr), dataStr))
|
||||
sys.stdout.buffer.write(f"Content-Length: {len(dataStr)}\r\n\r\n{dataStr}".encode('utf-8'))
|
||||
sys.stdout.flush()
|
||||
except IOError:
|
||||
# stdout closed, time to quit
|
||||
|
||||
Reference in New Issue
Block a user