-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix bootstrap.py script to not depend on tools/shared.py #24424
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
Conversation
…an be run during emsdk installation phase when no .emscripten config yet exists. Fixes emscripten-core/emsdk#1545
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder we add test for this in test_bootstrap
in test_sanify.py
Added a sanity test. It is quite convoluted to test since config.py tries its best to locate Emscripten tools via so many different means. But looks like it worked. |
# Verify that running bootstrap.py in a first-time run scenario should not | ||
# cause an exception. (A first time run scenario is before .emscripten, env. | ||
# vars nor PATH has been configured) | ||
def test_bootstrap_without_em_config(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just do @with_env_modify({'EM_CONFIG': "/path/does/not/exist"})
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - folded that to the other env. modify code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But can you literally just write this test as:
@with_env_modify({'EM_CONFIG': "/path/does/not/exist"})
def test_bootstrap_without_em_config(self):
# Verify that bootstrap works even without a valid config file.
self.run_process([shared.bat_suffix(shared.path_from_root('bootstrap'))])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(verified that that test fails as written without this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But can you literally just write this test as:
No, that doesn't work. It didn't work for me, but falsely passed the test.
That is because
Line 85 in 52815ef
path = shutil.which(tool_binary) |
Those env. removals are important to make sure to match the clean install scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, the behavior of from tools import shared
is different with
@with_env_modify({'EM_CONFIG': "/path/does/not/exist"})
versus
@with_env_modify({'EM_CONFIG': None})
It is better to test the scenario that first-time emsdk install also exercises, when there are no env. vars yet set. This way the test matches what happens on a new installation, and won't rely on EM_CONFIG pointing to a nonexistent file (emsdk doesn't do that either on first-time install)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I think its probably overkill but I get that there could be difference.
Fix bootstrap.py script to not depend on tools/shared.py so that it can be run during emsdk installation phase when no .emscripten config yet exists. Fixes emscripten-core/emsdk#1545