From 6ebbb66d30c3147cf63f50009fc383df617b6dae Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 30 Sep 2025 11:40:49 -0700 Subject: [PATCH] Add test for bat file quoting issue. NFC See https://github.com/microsoft/terminal/issues/15212 --- test/test_other.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test_other.py b/test/test_other.py index ee91e23835d1a..20b93ea941e08 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -15079,10 +15079,33 @@ def test_embind_negative_enum_values(self): @crossplatform def test_no_extra_output(self): + # Run this build command first to warm the cache (since caching can produce stdout). self.run_process([EMCC, '-c', test_file('hello_world.c')]) output = self.run_process([EMCC, '-c', test_file('hello_world.c')], stdout=PIPE, stderr=STDOUT).stdout self.assertEqual(output, '') + @crossplatform + def test_shell_cmd_with_quotes(self): + file = test_file('hello_world.c') + # Run this build command first to warm the cache (since caching can produce stdout). + self.run_process([EMCC, '-c', file]) + + # Verify that "emcc" is found in the PATH correctly in shell scripts (shell=True). + # (Specifically when quotes are around the "emcc" command itself). + # See https://github.com/microsoft/terminal/issues/15212 + old_path = os.environ['PATH'] + new_path = old_path + os.pathsep + os.path.dirname(EMCC) + cmd = f'"emcc" -c "{file}"' + print('running cmd:', cmd) + with env_modify({'PATH': new_path}): + proc = subprocess.run(cmd, capture_output=True, text=True, shell=True, check=True) + # There is currently a bug in the windows .bat files that leads to stdout + # not being empty in this case. + # See https://github.com/emscripten-core/emscripten/pull/25416 + if not WINDOWS: + self.assertEqual(proc.stdout, '') + self.assertEqual(proc.stderr, '') + def test_browser_too_old(self): err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMIN_CHROME_VERSION=10']) self.assertContained('emcc: error: MIN_CHROME_VERSION older than 74 is not supported', err)