Skip to content

Commit 00a0ec7

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

File tree

2 files changed

+34
-69
lines changed

2 files changed

+34
-69
lines changed

.circleci/config.yml

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,12 +1216,7 @@ jobs:
12161216
python: "$EMSDK_PYTHON"
12171217
- run-tests:
12181218
title: "crossplatform tests"
1219-
test_targets: "--crossplatform-only"
1220-
- upload-test-results
1221-
# Run a single websockify-based test to ensure it works on windows.
1222-
- run-tests:
1223-
title: "sockets.test_nodejs_sockets_echo*"
1224-
test_targets: "sockets.test_nodejs_sockets_echo*"
1219+
test_targets: "other.test_shell_cmd_with_quotes"
12251220
- upload-test-results
12261221

12271222
test-mac-arm64:
@@ -1251,67 +1246,4 @@ jobs:
12511246
workflows:
12521247
build-test:
12531248
jobs:
1254-
- ruff
1255-
- mypy
1256-
- vulture
1257-
- eslint
1258-
- build-docs
1259-
- build-linux
1260-
- test-sanity:
1261-
requires:
1262-
- build-linux
1263-
- test-posixtest:
1264-
requires:
1265-
- build-linux
1266-
- test-core0:
1267-
requires:
1268-
- build-linux
1269-
- test-core2:
1270-
requires:
1271-
- build-linux
1272-
- test-core3:
1273-
requires:
1274-
- build-linux
1275-
- test-wasm64-4gb:
1276-
requires:
1277-
- build-linux
1278-
- test-wasm2js1:
1279-
requires:
1280-
- build-linux
1281-
- test-other:
1282-
requires:
1283-
- build-linux
1284-
- test-modularize-instance:
1285-
requires:
1286-
- build-linux
1287-
- test-esm-integration:
1288-
requires:
1289-
- build-linux
1290-
- test-stress:
1291-
requires:
1292-
- build-linux
1293-
- test-browser-chrome
1294-
- test-browser-chrome-2gb:
1295-
requires:
1296-
- build-linux
1297-
- test-browser-chrome-wasm64:
1298-
requires:
1299-
- build-linux
1300-
- test-browser-chrome-wasm64-4gb:
1301-
requires:
1302-
- build-linux
1303-
- test-browser-firefox:
1304-
requires:
1305-
- build-linux
1306-
- test-browser-firefox-wasm64
1307-
- test-sockets-chrome:
1308-
requires:
1309-
- build-linux
1310-
- test-jsc
1311-
- test-spidermonkey
1312-
- test-node-compat
13131249
- test-windows
1314-
- test-windows-browser-firefox
1315-
- test-mac-arm64:
1316-
requires:
1317-
- build-linux

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)