Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
915 changes: 915 additions & 0 deletions test/browser_common.py

Large diffs are not rendered by default.

896 changes: 8 additions & 888 deletions test/common.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion test/parallel_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
import unittest

import browser_common
import common
from common import errlog

Expand Down Expand Up @@ -124,7 +125,7 @@ def run(self, result):
worker_id_lock = manager.Lock()
with multiprocessing.Pool(
processes=use_cores,
initializer=common.init_worker,
initializer=browser_common.init_worker,
initargs=(worker_id_counter, worker_id_lock),
) as pool:
if python_multiprocessing_structures_are_buggy():
Expand Down
13 changes: 7 additions & 6 deletions test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, __rootpath__)

import browser_common
import common
import jsrun
import parallel_testsuite
Expand Down Expand Up @@ -509,9 +510,9 @@ def parse_args():


def configure():
common.EMTEST_BROWSER = os.getenv('EMTEST_BROWSER')
common.EMTEST_BROWSER_AUTO_CONFIG = os.getenv('EMTEST_BROWSER_AUTO_CONFIG')
common.EMTEST_HEADLESS = int(os.getenv('EMTEST_HEADLESS', '0'))
browser_common.EMTEST_BROWSER = os.getenv('EMTEST_BROWSER')
browser_common.EMTEST_BROWSER_AUTO_CONFIG = os.getenv('EMTEST_BROWSER_AUTO_CONFIG')
browser_common.EMTEST_HEADLESS = int(os.getenv('EMTEST_HEADLESS', '0'))
common.EMTEST_DETECT_TEMPFILE_LEAKS = int(os.getenv('EMTEST_DETECT_TEMPFILE_LEAKS', '0'))
common.EMTEST_ALL_ENGINES = int(os.getenv('EMTEST_ALL_ENGINES', '0'))
common.EMTEST_SKIP_SLOW = int(os.getenv('EMTEST_SKIP_SLOW', '0'))
Expand All @@ -526,7 +527,7 @@ def configure():
assert 'PARALLEL_SUITE_EMCC_CORES' not in os.environ, 'use EMTEST_CORES rather than PARALLEL_SUITE_EMCC_CORES'
parallel_testsuite.NUM_CORES = os.environ.get('EMTEST_CORES') or os.environ.get('EMCC_CORES')

common.configure_test_browser()
browser_common.configure_test_browser()


def cleanup_emscripten_temp():
Expand Down Expand Up @@ -582,8 +583,8 @@ def set_env(name, option_value):
# Remove any old test files before starting the run
cleanup_emscripten_temp()
utils.delete_file(common.flaky_tests_log_filename)
utils.delete_file(common.browser_spawn_lock_filename)
utils.delete_file(f'{common.browser_spawn_lock_filename}_counter')
utils.delete_file(browser_common.browser_spawn_lock_filename)
utils.delete_file(f'{browser_common.browser_spawn_lock_filename}_counter')
if options.force_browser_process_termination or os.getenv('EMTEST_FORCE_BROWSER_PROCESS_TERMINATION'):
config = common.get_browser_config()

Expand Down
37 changes: 20 additions & 17 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@
from urllib.request import urlopen

import common
from common import (
from browser_common import (
CHROMIUM_BASED_BROWSERS,
EMRUN,
WEBIDL_BINDER,
BrowserCore,
HttpServerThread,
Reporting,
RunnerCore,
browser_should_skip_feature,
copytree,
create_file,
ensure_dir,
find_browser_test_file,
get_browser,
get_safari_version,
has_browser,
is_chrome,
is_firefox,
is_safari,
)
from common import (
EMRUN,
WEBIDL_BINDER,
RunnerCore,
copytree,
create_file,
ensure_dir,
path_from_root,
read_file,
test_file,
Expand Down Expand Up @@ -177,7 +180,7 @@ def shell_with_script(shell_file, output_file, replacement):


def is_swiftshader(_):
return is_chrome() and '--use-gl=swiftshader' in common.EMTEST_BROWSER
return is_chrome() and '--use-gl=swiftshader' in get_browser()


no_swiftshader = skip_if_simple('not compatible with swiftshader', is_swiftshader)
Expand Down Expand Up @@ -232,7 +235,7 @@ def decorator(f):
@wraps(f)
def decorated(self, *args, **kwargs):
if should_skip == 'error':
raise Exception(f'This test requires a browser that supports {feature.name} but your browser {common.EMTEST_BROWSER} does not support this. Run with {skip_env_var}=1 or EMTEST_AUTOSKIP=1 to skip this test automatically.')
raise Exception(f'This test requires a browser that supports {feature.name} but your browser {get_browser()} does not support this. Run with {skip_env_var}=1 or EMTEST_AUTOSKIP=1 to skip this test automatically.')
elif should_skip:
self.skip_exec = message
f(self, *args, **kwargs)
Expand Down Expand Up @@ -265,7 +268,7 @@ class browser(BrowserCore):
def setUpClass(cls):
super().setUpClass()
cls.browser_timeout = 60
if common.EMTEST_BROWSER != 'node':
if get_browser() != 'node':
print()
print('Running the browser tests. Make sure the browser allows popups from localhost.')
print()
Expand All @@ -275,7 +278,7 @@ def proxy_to_worker(self):

def require_jspi(self):
if not is_chrome():
self.skipTest(f'Current browser ({common.EMTEST_BROWSER}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')
self.skipTest(f'Current browser ({get_browser()}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')
super().require_jspi()

def post_manual_reftest(self):
Expand Down Expand Up @@ -3351,7 +3354,7 @@ def test_cocos2d_hello(self):
})
def test_async(self, opt, args):
if is_jspi(args) and not is_chrome():
self.skipTest(f'Current browser ({common.EMTEST_BROWSER}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')
self.skipTest(f'Current browser ({get_browser()}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')

self.btest_exit('test_async.c', cflags=[opt, '-g2'] + args)

Expand Down Expand Up @@ -5045,7 +5048,7 @@ def test_embind_with_pthreads(self):
})
def test_embind(self, args):
if is_jspi(args) and not is_chrome():
self.skipTest(f'Current browser ({common.EMTEST_BROWSER}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')
self.skipTest(f'Current browser ({get_browser()}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')
if is_jspi(args) and self.is_wasm64():
self.skipTest('_emval_await fails')

Expand Down Expand Up @@ -5728,9 +5731,9 @@ def test_no_browser(self):
self.run_process([EMCC, test_file('test_emrun.c'), '--emrun', '-o', 'hello_world.html'])
proc = subprocess.Popen([EMRUN, '--no-browser', '.', '--port=3333'], stdout=PIPE)
try:
if common.EMTEST_BROWSER:
if get_browser():
print('Starting browser')
browser_cmd = shlex.split(common.EMTEST_BROWSER)
browser_cmd = shlex.split(get_browser())
browser = subprocess.Popen(browser_cmd + ['http://localhost:3333/hello_world.html'])
try:
while True:
Expand Down Expand Up @@ -5769,11 +5772,11 @@ def test_emrun(self):
'--log-stdout', self.in_dir('stdout.txt'),
'--log-stderr', self.in_dir('stderr.txt')]

if common.EMTEST_BROWSER is not None:
if get_browser() is not None:
# If EMTEST_BROWSER carried command line arguments to pass to the browser,
# (e.g. "firefox -profile /path/to/foo") those can't be passed via emrun,
# so strip them out.
browser_cmd = shlex.split(common.EMTEST_BROWSER)
browser_cmd = shlex.split(get_browser())
browser_path = browser_cmd[0]
args_base += ['--browser', browser_path]
if len(browser_cmd) > 1:
Expand Down
3 changes: 2 additions & 1 deletion test/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
if __name__ == '__main__':
raise Exception('do not run this file directly; do something like: test/runner.py interactive')

from common import BrowserCore, create_file, test_file
from browser_common import BrowserCore
from common import create_file, test_file
from decorators import also_with_minimal_runtime, parameterized

from tools.utils import WINDOWS
Expand Down
2 changes: 1 addition & 1 deletion test/test_posixtest_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
parallel.
"""

from common import BrowserCore
from browser_common import BrowserCore


class posixtest_browser(BrowserCore):
Expand Down
3 changes: 2 additions & 1 deletion test/test_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import clang_native
import common
from common import NON_ZERO, PYTHON, BrowserCore, create_file, read_file
from browser_common import BrowserCore
from common import NON_ZERO, PYTHON, create_file, read_file
from decorators import (
crossplatform,
no_windows,
Expand Down