sapling/eden/scm/tests/test-fb-ext-sshaskpass.py
Muir Manders 44343769f8 collapse edenscm.mercurial package into edenscm
Summary:
We want to rename away from "mercurial". Rather than rename the "mercurial" Python package, we opted to just collapse it into the parent "edenscm" package. This is also a step towards further organizing we want to do around the new project name.

To ease the transition wrt hotfixes, we now replace "edenscm.mercurial" with "mercurial" to fix imports within base64-python extensions.

Reviewed By: sggutier

Differential Revision: D38943169

fbshipit-source-id: 03fa18079c51e2f7fac05d65b127095da3ab7c99
2022-08-24 13:45:53 -07:00

56 lines
1.3 KiB
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
import os
import signal
import sys
from edenscm import error
# Make sure we use sshaskpass.py in this repo, unaffected by PYTHONPATH
from edenscm.ext import sshaskpass
from hghave import require
require(["py2"])
if not sys.platform.startswith("linux"):
sys.stderr.write("this test only supports linux\n")
sys.exit(80)
# stdin, stderr have to be tty to run test
pid, master = os.forkpty()
if pid:
# parent, test some I/O
os.write(master, "(input)\n")
with os.fdopen(master, "r") as f:
sys.stdout.write("pty receives: %r" % f.read())
os.waitpid(pid, 0)
sys.exit(0)
sigterm = getattr(signal, "SIGTERM", None)
if sigterm:
def catchterm(*args):
raise error.SignalInterrupt
signal.signal(sigterm, catchterm)
# child, start a ttyserver and do some I/O
ttysrvpid, sockpath = sshaskpass._startttyserver()
try:
r, w = sshaskpass._receivefds(sockpath)
with os.fdopen(r) as f:
line = f.readline()
os.write(w, "client receives: " + line)
finally:
sshaskpass._killprocess(ttysrvpid)
os.unlink(sockpath)