Skip to content

Commit

Permalink
Add testcase for stdin under NODERAWFS
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Nov 9, 2022
1 parent 120ff40 commit 19a437d
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand All @@ -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.
Expand Down

0 comments on commit 19a437d

Please sign in to comment.