Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Aug 8, 2024
1 parent f09c161 commit f927a00
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,18 @@ def test_stdin(self, args):
os.system(f'cat in.txt | {cmd} > out.txt')
self.assertContained('abcdef\nghijkl\neof', read_file('out.txt'))

@also_with_noderawfs
@crossplatform
def test_module_stdin(self):
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!')

def test_ungetc_fscanf(self):
create_file('main.c', r'''
#include <stdio.h>
Expand Down Expand Up @@ -9762,6 +9774,7 @@ def test_ioctl(self):
# ioctl requires filesystem
self.do_other_test('test_ioctl.c', emcc_args=['-sFORCE_FILESYSTEM'])

@also_with_noderawfs
def test_ioctl_termios(self):
# ioctl requires filesystem
self.do_other_test('test_ioctl_termios.c', emcc_args=['-sFORCE_FILESYSTEM'])
Expand Down Expand Up @@ -13497,18 +13510,6 @@ 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 f927a00

Please sign in to comment.