-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add test runner option --log-test-environment #25843
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
Open
juj
wants to merge
4
commits into
emscripten-core:main
Choose a base branch
from
juj:log_test_environment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−3
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,13 +19,16 @@ | |
|
|
||
| import argparse | ||
| import atexit | ||
| import datetime | ||
| import fnmatch | ||
| import glob | ||
| import logging | ||
| import math | ||
| import operator | ||
| import os | ||
| import random | ||
| import re | ||
| import subprocess | ||
| import sys | ||
| import time | ||
| import unittest | ||
|
|
@@ -44,7 +47,7 @@ | |
| from common import errlog | ||
| from single_line_runner import SingleLineTestRunner | ||
|
|
||
| from tools import colored_logger, config, shared, utils | ||
| from tools import building, colored_logger, config, shared, utils | ||
|
|
||
| logger = logging.getLogger("runner") | ||
|
|
||
|
|
@@ -506,6 +509,7 @@ def parse_args(): | |
| 'Useful when combined with --failfast') | ||
| parser.add_argument('--force64', action='store_true') | ||
| parser.add_argument('--crossplatform-only', action='store_true') | ||
| parser.add_argument('--log-test-environment', action='store_true', help='Prints out detailed information about the current environment. Useful for adding more info to CI test runs.') | ||
| parser.add_argument('--force-browser-process-termination', action='store_true', help='If true, a fail-safe method is used to ensure that all browser processes are terminated before and after the test suite run. Note that this option will terminate all browser processes, not just those launched by the harness, so will result in loss of all open browsing sessions.') | ||
| parser.add_argument('--repeat', type=int, default=1, | ||
| help='Repeat each test N times (default: 1).') | ||
|
|
@@ -563,6 +567,95 @@ def cleanup_emscripten_temp(): | |
| pass | ||
|
|
||
|
|
||
| def print_repository_info(directory, repository_name): | ||
| current_commit = utils.run_process(['git', 'show', '--no-patch'], cwd=directory, stdout=subprocess.PIPE, text=True).stdout.strip() | ||
| print(f'\n{repository_name} {current_commit}\n') | ||
| local_changes = utils.run_process(['git', 'diff'], cwd=directory, stdout=subprocess.PIPE, text=True).stdout.strip() | ||
| if local_changes: | ||
| print(f'\n{local_changes}\n') | ||
|
|
||
|
|
||
| def log_test_environment(): | ||
| """Print detailed information about the current test environment. Useful for | ||
| logging test run configuration in a CI.""" | ||
| print('======================== Test Setup ========================') | ||
| print(f'Test time: {datetime.datetime.now(datetime.timezone.utc).strftime("%A, %B %d, %Y %H:%M:%S %Z")}') | ||
| print(f'Python: "{sys.executable}". Version: {sys.version}') | ||
| print(f'Emscripten test runner path: "{os.path.realpath(__file__)}"') | ||
|
|
||
| if os.path.isdir(os.path.join(__rootpath__, '.git')): | ||
| print(f'\nEmscripten repository: "{__rootpath__}"') | ||
|
|
||
| emscripten_version = utils.path_from_root('emscripten-version.txt') | ||
| if os.path.isfile(emscripten_version): | ||
| print(f'emscripten-version.txt: {utils.EMSCRIPTEN_VERSION}') | ||
|
|
||
| if os.path.isdir(os.path.join(__rootpath__, '.git')): | ||
| print_repository_info(__rootpath__, 'Emscripten') | ||
|
|
||
| print(f'EM_CONFIG: "{config.EM_CONFIG}"') | ||
| if os.path.isfile(config.EM_CONFIG): | ||
| print(f'\n{utils.read_file(config.EM_CONFIG).strip()}\n') | ||
|
|
||
| node_js_version = utils.run_process(config.NODE_JS + ['--version'], stdout=subprocess.PIPE, text=True).stdout.strip() | ||
| print(f'NODE_JS: {config.NODE_JS}. Version: {node_js_version}') | ||
|
|
||
| print(f'BINARYEN_ROOT: {config.BINARYEN_ROOT}') | ||
| wasm_opt_version = building.get_binaryen_version(building.get_binaryen_bin()).strip() | ||
| print(f'wasm-opt version: {wasm_opt_version}') | ||
juj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| binaryen_git_dir = config.BINARYEN_ROOT | ||
| # Detect emsdk directory structure (build root vs source root) | ||
| if re.match(r'main_.*_64bit_binaryen', os.path.basename(binaryen_git_dir)): | ||
| binaryen_git_dir = os.path.realpath(os.path.join(binaryen_git_dir, '..', 'main')) | ||
| if os.path.isdir(os.path.join(binaryen_git_dir, '.git')): | ||
| print(f'Binaryen git directory: "{binaryen_git_dir}"') | ||
| print_repository_info(binaryen_git_dir, 'Binaryen') | ||
|
|
||
| print(f'LLVM_ROOT: {config.LLVM_ROOT}') | ||
|
|
||
| # Find LLVM git directory in emsdk aware fashion | ||
| def find_llvm_git_root(dir): | ||
| while True: | ||
| if os.path.isdir(os.path.join(dir, ".git")): | ||
| return dir | ||
| if os.path.isdir(os.path.join(dir, "src", ".git")): | ||
| return os.path.join(dir, "src") | ||
| if os.path.dirname(dir) == dir: | ||
| return None | ||
| dir = os.path.dirname(dir) | ||
|
|
||
| llvm_git_root = find_llvm_git_root(config.LLVM_ROOT) | ||
| if llvm_git_root: | ||
| print(f'LLVM git directory: "{llvm_git_root}"') | ||
| print_repository_info(llvm_git_root, 'LLVM') | ||
|
|
||
| clang_version = utils.run_process([shared.CLANG_CC, '--version'], stdout=subprocess.PIPE, text=True).stdout.strip() | ||
| print(f'Clang: "{shared.CLANG_CC}"\n{clang_version}\n') | ||
|
Collaborator
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. We have
Collaborator
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. That too parses the output - it would be preferable to print the raw output here. |
||
|
|
||
| print(f'EMTEST_BROWSER: {browser_common.EMTEST_BROWSER}') | ||
| if browser_common.is_firefox(): | ||
| print(f'Firefox version: {browser_common.get_firefox_version()}') | ||
| else: | ||
| print('Not detected as a Firefox browser') | ||
| if browser_common.is_safari(): | ||
| print(f'Safari version: {browser_common.get_safari_version()}') | ||
| else: | ||
| print('Not detected as a Safari browser') | ||
| if browser_common.is_chrome(): | ||
| print(f'Browser is Chrome.') | ||
| else: | ||
| print('Not detected as a Chrome browser') | ||
|
|
||
| emsdk_dir = os.getenv('EMSDK') | ||
| print(f'\nEMSDK: "{emsdk_dir}"') | ||
| if emsdk_dir: | ||
| if os.path.isdir(os.path.join(emsdk_dir, '.git')): | ||
| print_repository_info(emsdk_dir, 'Emsdk') | ||
|
|
||
| print('==================== End of Test Setup =====================') | ||
|
|
||
|
|
||
| def main(): | ||
| options = parse_args() | ||
|
|
||
|
|
@@ -606,6 +699,9 @@ def set_env(name, option_value): | |
|
|
||
| browser_common.init(options.force_browser_process_termination) | ||
|
|
||
| if options.log_test_environment: | ||
| log_test_environment() | ||
|
|
||
| def prepend_default(arg): | ||
| if arg.startswith('test_'): | ||
| return default_core_test_mode + '.' + arg | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We already have this available via
utils.get_node_version()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.
There's
shared.get_node_version(), but that parses the output. I think it's better in this case to output the raw version string as emitted byNODE_JS --version.