@@ -15079,10 +15079,43 @@ def test_embind_negative_enum_values(self):
15079
15079
15080
15080
@crossplatform
15081
15081
def test_no_extra_output(self):
15082
+ # Run this build command first to warm the cache (since caching can produce stdout).
15082
15083
self.run_process([EMCC, '-c', test_file('hello_world.c')])
15083
15084
output = self.run_process([EMCC, '-c', test_file('hello_world.c')], stdout=PIPE, stderr=STDOUT).stdout
15084
15085
self.assertEqual(output, '')
15085
15086
15087
+ @crossplatform
15088
+ def test_shell_cmd_with_quotes(self):
15089
+ # Run this build command first to warm the cache (since caching can produce stdout).
15090
+ self.run_process([EMCC, '-c', test_file('hello_world.c')])
15091
+
15092
+ # Verify that "emcc" is found in the PATH correctly in shell scripts (shell=True).
15093
+ # Specificaly when quotes are around the "emcc" command itself.
15094
+ # See https://github.com/microsoft/terminal/issues/15212
15095
+ file = test_file('hello_world.c')
15096
+ emcc = os.path.splitext(EMCC)[0]
15097
+ cmd = f'"{emcc}" -c "{file}"'
15098
+ print('running cmd:', cmd)
15099
+ proc = subprocess.run(cmd, capture_output=True, text=True, shell=True, check=True)
15100
+ # Also verify the no extra output is produced (simillar to test_no_extra_output
15101
+ # above).
15102
+ self.assertEqual(proc.stdout, '')
15103
+ self.assertEqual(proc.stderr, '')
15104
+
15105
+ # Same again but without only filename part of `emcc` command
15106
+ old_path = os.environ['PATH']
15107
+ new_path = old_path + os.pathsep + os.path.dirname(EMCC)
15108
+ cmd = f'"emcc" -c "{file}"'
15109
+ print('running cmd:', cmd)
15110
+ with env_modify({'PATH': new_path}):
15111
+ proc = subprocess.run(cmd, capture_output=True, text=True, shell=True, check=True)
15112
+ # There is currently a bug in the windows .bar files that leads to stdout
15113
+ # not being empty in this case.
15114
+ # See https://github.com/emscripten-core/emscripten/pull/25416
15115
+ if not WINDOWS:
15116
+ self.assertEqual(proc.stdout, '')
15117
+ self.assertEqual(proc.stderr, '')
15118
+
15086
15119
def test_browser_too_old(self):
15087
15120
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMIN_CHROME_VERSION=10'])
15088
15121
self.assertContained('emcc: error: MIN_CHROME_VERSION older than 74 is not supported', err)
0 commit comments