summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-09-24 11:47:13 +0200
committerAnna Henningsen <anna@addaleax.net>2018-10-04 09:20:22 -0700
commitd0fc382c4b18a7021d0a93194bc4b304ed6f7d6f (patch)
tree268023ca916df2842ebc4123313954e95772eaad /test
parentc7405fe9cb91124d966235467d6a9148e6bc9bd5 (diff)
downloadandroid-node-v8-d0fc382c4b18a7021d0a93194bc4b304ed6f7d6f.tar.gz
android-node-v8-d0fc382c4b18a7021d0a93194bc4b304ed6f7d6f.tar.bz2
android-node-v8-d0fc382c4b18a7021d0a93194bc4b304ed6f7d6f.zip
tools: allow input for TTY tests
Since faking TTY input is not otherwise fake-able, we need support in the test runner for it. PR-URL: https://github.com/nodejs/node/pull/23053 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/pseudo-tty/testcfg.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/test/pseudo-tty/testcfg.py b/test/pseudo-tty/testcfg.py
index 41a536104d..9207898445 100644
--- a/test/pseudo-tty/testcfg.py
+++ b/test/pseudo-tty/testcfg.py
@@ -35,10 +35,11 @@ FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
class TTYTestCase(test.TestCase):
- def __init__(self, path, file, expected, arch, mode, context, config):
+ def __init__(self, path, file, expected, input, arch, mode, context, config):
super(TTYTestCase, self).__init__(context, path, arch, mode)
self.file = file
self.expected = expected
+ self.input = input
self.config = config
self.arch = arch
self.mode = mode
@@ -104,12 +105,16 @@ class TTYTestCase(test.TestCase):
+ open(self.expected).read())
def RunCommand(self, command, env):
+ input = None
+ if self.input is not None and exists(self.input):
+ input = open(self.input).read()
full_command = self.context.processor(command)
output = test.Execute(full_command,
self.context,
self.context.GetTimeout(self.mode),
env,
- True)
+ faketty=True,
+ input=input)
return test.TestOutput(self,
full_command,
output,
@@ -139,11 +144,12 @@ class TTYTestConfiguration(test.TestConfiguration):
if self.Contains(path, test):
file_prefix = join(self.root, reduce(join, test[1:], ""))
file_path = file_prefix + ".js"
+ input_path = file_prefix + ".in"
output_path = file_prefix + ".out"
if not exists(output_path):
raise Exception("Could not find %s" % output_path)
result.append(TTYTestCase(test, file_path, output_path,
- arch, mode, self.context, self))
+ input_path, arch, mode, self.context, self))
return result
def GetBuildRequirements(self):