Mercurial > public > mercurial-scm > hg-stable
diff mercurial/testing/__init__.py @ 49672:8e0d823ef182 stable
testing: introduce util function to synchronize concurrent commands on files
This is an extension of mechanisms that the tests have been using for a while.
To be able to also control the execution in Rust, we introduce utility to
perform such `wait_on_file` logic based on some configuration value.
This will be used in the tests introduced in the next changesets.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Tue, 28 Feb 2023 00:01:41 +0100 |
parents | 6000f5b25c9b |
children | f4733654f144 |
line wrap: on
line diff
--- a/mercurial/testing/__init__.py Tue Feb 28 00:04:32 2023 +0100 +++ b/mercurial/testing/__init__.py Tue Feb 28 00:01:41 2023 +0100 @@ -9,6 +9,21 @@ environ = getattr(os, 'environ') +def wait_on_cfg(ui, cfg, timeout=10): + """synchronize on the `cfg` config path + + Use this to synchronize commands during race tests. + """ + full_config = b'sync.' + cfg + wait_config = full_config + b'-timeout' + sync_path = ui.config(b'devel', full_config) + if sync_path is not None: + timeout = ui.config(b'devel', wait_config) + ready_path = sync_path + b'.waiting' + write_file(ready_path) + wait_file(sync_path, timeout=timeout) + + def _timeout_factor(): """return the current modification to timeout""" default = int(environ.get('HGTEST_TIMEOUT_DEFAULT', 360))