From 19a437dfb9f0258d069a130af09faed8416fe627 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 9 Nov 2022 10:48:50 +0100 Subject: [PATCH] Add testcase for stdin under NODERAWFS --- test/test_other.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index d2a6339591d02..9bc8684dd7261 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12113,13 +12113,9 @@ def test_noderawfs_override_standard_streams(self): let stdout = ''; let stderr = ''; -Module['print'] = function(text) { - stdout += text; -} -Module['printErr'] = function(text) { - stderr += text; -} -Module['postRun'] = function() { +Module['print'] = (text) => stdout += text; +Module['printErr'] = (text) => stderr += text; +Module['postRun'] = () => { assert(stderr == '', 'stderr should be empty. \\n' + 'stderr: \\n' + stderr); assert(stdout.startsWith('hello, world!'), 'stdout should start with the famous greeting. \\n' + @@ -12129,6 +12125,18 @@ def test_noderawfs_override_standard_streams(self): self.emcc_args += ['--pre-js', 'pre.js'] self.do_runf(test_file('hello_world.c')) + @requires_node + def test_noderawfs_override_stdin(self): + self.set_setting('NODERAWFS') + self.set_setting('FORCE_FILESYSTEM') + self.set_setting('EXIT_RUNTIME') + create_file('pre.js', ''' +const data = 'hello, world!\\n'.split('').map(c => c.charCodeAt(0)); +Module['stdin'] = () => data.shift() || null; +''') + self.emcc_args += ['--pre-js', 'pre.js'] + self.do_runf(test_file('module/test_stdin.c'), 'hello, world!') + # WASMFS tests # TODO: This test will only work with the new file system.