From 8b5b56db2a1279d3150beeb6004a207acde452be Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 18 Aug 2024 16:40:03 +0200 Subject: [PATCH] Revise tests --- test/test_other.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/test_other.py b/test/test_other.py index 29b2f38126ee4..28cca5b8293f8 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -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);