tests/helpers-testrepo.sh
author Jun Wu <quark@fb.com>
Wed, 28 Jun 2017 13:45:51 -0700
changeset 33125 acfce52518c4
parent 33116 6c113a7dec52
child 33126 98e2c78e309c
permissions -rw-r--r--
tests: do not use system hg if it does not have "files" command Ancient hg does not have "hg files" so test-check-*.t will fail with "unknown command 'files'": $ hg files hg: unknown command 'files' $ hg --version Mercurial Distributed SCM (version 2.6.2) Test "hg files" and give up using syshg if it does not have "files" command.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     1
# Invoke the system hg installation (rather than the local hg version being
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     2
# tested).
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff changeset
     3
#
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     4
# We want to use the hg version being tested when interacting with the test
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     5
# repository, and the system hg when interacting with the mercurial source code
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     6
# repository.
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff changeset
     7
#
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     8
# The mercurial source repository was typically orignally cloned with the
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     9
# system mercurial installation, and may require extensions or settings from
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    10
# the system installation.
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    11
syshg () {
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    12
    (
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    13
        syshgenv
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    14
        exec hg "$@"
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    15
    )
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    16
}
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    17
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    18
# Revert the environment so that running "hg" runs the system hg
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    19
# rather than the test hg installation.
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    20
syshgenv () {
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    21
    PATH="$ORIG_PATH"
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    22
    PYTHONPATH="$ORIG_PYTHONPATH"
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    23
    JYTHONPATH="$ORIG_JYTHONPATH"
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    24
    unset HGRCPATH
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    25
    HGPLAIN=1
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    26
    export HGPLAIN
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    27
}
33125
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    28
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    29
# Most test-check-* sourcing this file run "hg files", which is not available
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    30
# in ancient versions of hg. So we double check if "syshg files" works and
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    31
# fallback to hg bundled in the repo.
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    32
syshg files -h >/dev/null 2>/dev/null
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    33
if [ $? -ne 0 ]; then
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    34
    syshg() {
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    35
        hg "$@"
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    36
    }
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    37
    syshgenv() {
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    38
        :
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    39
    }
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    40
fi