Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failed to detect flavor if compiler path include white spaces #240

Merged
merged 12 commits into from
Apr 23, 2024
Prev Previous commit
Next Next commit
ruff --select=SIM300 pylib/gyp/common_test.py
  • Loading branch information
toyobayashi committed Apr 2, 2024
commit 1bae115df863d03503591275b90a5786ec95ca8c
14 changes: 7 additions & 7 deletions pylib/gyp/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,23 @@ def mock_run(env, defines_stdout, expected_cmd):
["/opt/wasi-sdk/bin/clang"]
)
assert { "__wasm__": "1", "__wasi__": "1" } == defines2
assert "wasi" == flavor2
assert flavor2 == "wasi"

[defines3, flavor3] = mock_run(
{ "CC_target": "/opt/wasi-sdk/bin/clang --target=wasm32" },
"#define __wasm__ 1\n",
["/opt/wasi-sdk/bin/clang", "--target=wasm32"]
)
assert { "__wasm__": "1" } == defines3
assert "wasm" == flavor3
assert flavor3 == "wasm"

[defines4, flavor4] = mock_run(
{ "CC_target": "/emsdk/upstream/emscripten/emcc" },
"#define __EMSCRIPTEN__ 1\n",
["/emsdk/upstream/emscripten/emcc"]
)
assert { "__EMSCRIPTEN__": "1" } == defines4
assert "emscripten" == flavor4
assert flavor4 == "emscripten"

# Test path which include white space
[defines5, flavor5] = mock_run(
Expand All @@ -154,18 +154,18 @@ def mock_run(env, defines_stdout, expected_cmd):
"__wasi__": "1",
"_REENTRANT": "1"
} == defines5
assert "wasi" == flavor5
assert flavor5 == "wasi"

original_platform = os.sep
original_sep = os.sep
os.sep = "\\"
[defines6, flavor6] = mock_run(
{ "CC_target": "\"C:\\Program Files\\wasi-sdk\\clang.exe\"" },
"#define __wasm__ 1\n#define __wasi__ 1\n",
["C:/Program Files/wasi-sdk/clang.exe"]
)
os.sep = original_platform
os.sep = original_sep
assert { "__wasm__": "1", "__wasi__": "1" } == defines6
assert "wasi" == flavor6
assert flavor6 == "wasi"

if __name__ == "__main__":
unittest.main()
Loading