Skip to content

Commit b318d20

Browse files
committed
Add test for bat file quoting issue. NFC
See microsoft/terminal#15212
1 parent ec54193 commit b318d20

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/test_other.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15079,10 +15079,43 @@ def test_embind_negative_enum_values(self):
1507915079

1508015080
@crossplatform
1508115081
def test_no_extra_output(self):
15082+
# Run this build command first to warm the cache (since caching can produce stdout).
1508215083
self.run_process([EMCC, '-c', test_file('hello_world.c')])
1508315084
output = self.run_process([EMCC, '-c', test_file('hello_world.c')], stdout=PIPE, stderr=STDOUT).stdout
1508415085
self.assertEqual(output, '')
1508515086

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+
1508615119
def test_browser_too_old(self):
1508715120
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMIN_CHROME_VERSION=10'])
1508815121
self.assertContained('emcc: error: MIN_CHROME_VERSION older than 74 is not supported', err)

0 commit comments

Comments
 (0)