# HG changeset patch # User Simon Sapin # Date 1614790854 -3600 # Node ID 78e6700ab009172adc3f92285ec019a41a230514 # Parent a6553ba1c59896ce5c4717e8b7b5314705690dd7 tests: Add `rhg` and `no-rhg` for #require and #if in .t files With this we can allow some small differences in expected output between Rust-based and Python-based code paths. Differential Revision: https://phab.mercurial-scm.org/D10096 diff -r a6553ba1c598 -r 78e6700ab009 tests/hghave.py --- a/tests/hghave.py Tue Mar 02 22:42:10 2021 +0100 +++ b/tests/hghave.py Wed Mar 03 18:00:54 2021 +0100 @@ -188,6 +188,11 @@ return 'CHGHG' in os.environ +@check("rhg", "running with rhg as 'hg'") +def has_rhg(): + return 'RHG_INSTALLED_AS_HG' in os.environ + + @check("cvs", "cvs client/server") def has_cvs(): re = br'Concurrent Versions System.*?server' diff -r a6553ba1c598 -r 78e6700ab009 tests/run-tests.py --- a/tests/run-tests.py Tue Mar 02 22:42:10 2021 +0100 +++ b/tests/run-tests.py Wed Mar 03 18:00:54 2021 +0100 @@ -3134,6 +3134,8 @@ # configure fallback and replace "hg" command by "rhg" rhgbindir = self._bindir if self.options.rhg or self.options.with_rhg: + # Affects hghave.py + osenvironb[b'RHG_INSTALLED_AS_HG'] = b'1' # Affects configuration. Alternatives would be setting configuration through # `$HGRCPATH` but some tests override that, or changing `_hgcommand` to include # `--config` but that disrupts tests that print command lines and check expected diff -r a6553ba1c598 -r 78e6700ab009 tests/test-rhg.t --- a/tests/test-rhg.t Tue Mar 02 22:42:10 2021 +0100 +++ b/tests/test-rhg.t Wed Mar 03 18:00:54 2021 +0100 @@ -1,15 +1,4 @@ -#require rust - -Define an rhg function that will only run if rhg exists - $ RHG="$RUNTESTDIR/../rust/target/release/rhg" - $ rhg() { - > if [ -f "$RHG" ]; then - > "$RHG" "$@" - > else - > echo "skipped: Cannot find rhg. Try to run cargo build in rust/rhg." - > exit 80 - > fi - > } +#require rhg $ NO_FALLBACK="env RHG_ON_UNSUPPORTED=abort" @@ -169,8 +158,8 @@ unsupported feature: `rhg cat` without `--rev` / `-r` [252] - $ rhg cat original --config rhg.fallback-executable="$RHG" - Blocking recursive fallback. The 'rhg.fallback-executable = */rust/target/release/rhg' config points to `rhg` itself. (glob) + $ rhg cat original --config rhg.fallback-executable=rhg + Blocking recursive fallback. The 'rhg.fallback-executable = rhg' config points to `rhg` itself. unsupported feature: `rhg cat` without `--rev` / `-r` [252]