Skip to content

Commit

Permalink
Revise tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Aug 18, 2024
1 parent 4472431 commit 8b5b56d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,13 +1692,33 @@ def test_module_stdin(self):
def test_module_stdout_stderr(self):
self.set_setting('FORCE_FILESYSTEM')
create_file('pre.js', '''
let stdout = [];
let stderr = [];

Module['stdout'] = (char) => stdout.push(char);
Module['stderr'] = (char) => stderr.push(char);
Module['postRun'] = () => {
assert(stderr.length === 0, 'stderr should be empty. \\n' +
'stderr: \\n' + stderr);
assert(UTF8ArrayToString(stdout, 0).startsWith('hello, world!'), 'stdout should start with the famous greeting. \\n' +
'stdout: \\n' + stdout);
}
''')
self.emcc_args += ['--pre-js', 'pre.js']
self.do_runf('hello_world.c')

# @also_with_noderawfs # NODERAWFS doesn't use library_tty.js for stdio streams
@crossplatform
def test_module_print_printerr(self):
self.set_setting('FORCE_FILESYSTEM')
create_file('pre.js', '''
let stdout = '';
let stderr = '';

Module['print'] = (text) => stdout += text;
Module['printErr'] = (text) => stderr += text;
Module['postRun'] = () => {
assert(stderr == '', 'stderr should be empty. \\n' +
assert(stderr === '', 'stderr should be empty. \\n' +
'stderr: \\n' + stderr);
assert(stdout.startsWith('hello, world!'), 'stdout should start with the famous greeting. \\n' +
'stdout: \\n' + stdout);
Expand Down

0 comments on commit 8b5b56d

Please sign in to comment.