-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Cache the fact that sanity checks were performed for subprocesses #6124
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7926,6 +7926,11 @@ def test_wasm_backend(self): | |
| if old == '1': return # already the default | ||
| try: | ||
| os.environ['EMCC_WASM_BACKEND'] = '1' | ||
| if EMCC_SKIP_SANITY_CHECK_NAME in os.environ: | ||
| # Cached sanity check result was for different configuration | ||
| del os.environ[EMCC_SKIP_SANITY_CHECK_NAME] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's usually better to skip the test with a message than to modify the environment. in any case, though, I don't think we need to check sanity here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I understand, we already skip this test if no environment modification (that was in place before this PR) is required. :) As you already noted, we don't need to perform checks before every test case. I redo sanity check for this particular test case because here we artificially changed the condition on which sanity check control flow depends (in fact, I don't handle very well another input: the |
||
| check_sanity(force=True) | ||
|
|
||
| for args in [[], ['-O1'], ['-O2'], ['-O3'], ['-Os'], ['-Oz']]: | ||
| print(args) | ||
| run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp')] + args) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,13 +29,17 @@ def setUpClass(self): | |
| print('WARNING: This will modify %s, and in theory can break it although it should be restored properly. A backup will be saved in %s_backup' % (EM_CONFIG, EM_CONFIG)) | ||
| print() | ||
|
|
||
| os.environ[EMCC_SKIP_SANITY_CHECK_NAME] = '-1' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -1?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, this |
||
| assert os.path.exists(CONFIG_FILE), 'To run these tests, we need a (working!) %s file to already exist' % EM_CONFIG | ||
| assert not os.environ.get('EMCC_DEBUG'), 'do not run sanity checks in debug mode!' | ||
| assert not os.environ.get('EMCC_WASM_BACKEND'), 'do not force wasm backend either way in sanity checks!' | ||
|
|
||
| @classmethod | ||
| def tearDownClass(self): | ||
| super(RunnerCore, self).tearDownClass() | ||
| if EMCC_SKIP_SANITY_CHECK_NAME in os.environ: | ||
| del os.environ[EMCC_SKIP_SANITY_CHECK_NAME] | ||
| check_sanity(force=True) | ||
|
|
||
| def setUp(self): | ||
| wipe() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -483,11 +483,16 @@ def get_emscripten_version(path): | |
| def generate_sanity(): | ||
| return EMSCRIPTEN_VERSION + '|' + LLVM_ROOT + '|' + get_clang_version() + ('_wasm' if Settings.WASM_BACKEND else '') | ||
|
|
||
| EMCC_SKIP_SANITY_CHECK_NAME = 'EMCC_SKIP_SANITY_CHECK' | ||
|
|
||
| def check_sanity(force=False): | ||
| ToolchainProfiler.enter_block('sanity') | ||
| try: | ||
| if os.environ.get('EMCC_SKIP_SANITY_CHECK') == '1': | ||
| if os.environ.get(EMCC_SKIP_SANITY_CHECK_NAME) == '1': | ||
| return | ||
| if EMCC_SKIP_SANITY_CHECK_NAME not in os.environ: | ||
| os.environ[EMCC_SKIP_SANITY_CHECK_NAME] = '1' | ||
|
|
||
| reason = None | ||
| if not CONFIG_FILE: | ||
| return # config stored directly in EM_CONFIG => skip sanity checks | ||
|
|
@@ -1497,6 +1502,9 @@ def has_substr(array, substr): | |
|
|
||
| @staticmethod | ||
| def configure(args, stdout=None, stderr=None, env=None): | ||
| # Check once and cache results | ||
| check_sanity() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these also seem unnecessary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, according to comments, |
||
|
|
||
| if not args: | ||
| return | ||
| if env is None: | ||
|
|
@@ -1523,6 +1531,9 @@ def configure(args, stdout=None, stderr=None, env=None): | |
|
|
||
| @staticmethod | ||
| def make(args, stdout=None, stderr=None, env=None): | ||
| # Check once and cache results | ||
| check_sanity() | ||
|
|
||
| if env is None: | ||
| env = Building.get_building_env() | ||
| if not args: | ||
|
|
||
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.
Doing this for each test is more than we need, I think. We can just do it once at the very beginning, at the top level?
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.
Oops, I probably put it in the wrong place. I thought to place it to the global setup function.