(skip_env_var, feature, message)
| 187 | |
| 188 | |
| 189 | def skipIfFeatureNotAvailable(skip_env_var, feature, message): |
| 190 | for env_var in skip_env_var if type(skip_env_var) == list else [skip_env_var]: |
| 191 | should_skip = browser_should_skip_feature(env_var, feature) |
| 192 | if should_skip: |
| 193 | break |
| 194 | |
| 195 | def decorator(f): |
| 196 | assert callable(f) |
| 197 | |
| 198 | @wraps(f) |
| 199 | def decorated(self, *args, **kwargs): |
| 200 | if should_skip == 'error': |
| 201 | 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.') |
| 202 | elif should_skip and bool(re.search(r"MIN_.*_VERSION", os.getenv('EMCC_CFLAGS', ''))): |
| 203 | # should_skip=True, so we should skip running this test. However, user has specified a MIN_x_VERSION |
| 204 | # directive in EMCC_CFLAGS, so we cannot even try to compile this test, or otherwise emcc can |
| 205 | # error out on the MIN_x_VERSION being too old. So skip both compiling+running this test. |
| 206 | self.skipTest(message) |
| 207 | elif should_skip: |
| 208 | # Skip running this test in a browser, but do test compiling it, to get partial coverage. |
| 209 | self.skip_exec = message |
| 210 | |
| 211 | f(self, *args, **kwargs) |
| 212 | |
| 213 | return decorated |
| 214 | |
| 215 | return decorator |
| 216 | |
| 217 | |
| 218 | def webgl2_disabled(): |
no test coverage detected