xonsh/tests/bin/checkargv0.xsh
David Strobach dfcce2b4d0 Add test for subprocess argv[0]
The test needs access to procfs, so it only runs on Linux.
2020-08-05 15:15:02 +02:00

25 lines
494 B
Text
Executable file

#!/usr/bin/env xonsh
res = True
script = """import os
path = "/proc/{}/cmdline".format(os.getpid())
with open(path, "r") as f:
lines = f.read().split("\x00")
print(lines[0])"""
def check(python):
argv0 = $(@(python) -c @(script)).rstrip()
if argv0 == python:
return True
print("Unexpected argv[0]: {} != {}".format(argv0, python))
return False
python = "python"
res &= check(python)
python = $(which -s python)
res &= check(python)
if res:
print("OK")