tests/helpers-testrepo.sh
author Matt Harbison <matt_harbison@yahoo.com>
Sun, 22 Aug 2021 17:59:21 -0400
branchstable
changeset 47866 4162f6b40f2c
parent 37475 152f1b47e0ad
permissions -rw-r--r--
windows: degrade to py2 behavior when reading a non-symlink as a symlink While waiting for the push to hg-committed in WSL to complete, I ran a `phabimport` from Windows and got this traceback: $ hg phabimport 11313 ** Unknown exception encountered with possibly-broken third-party extension "mercurial_keyring" (version N/A) ** which supports versions unknown of Mercurial. ** Please disable "mercurial_keyring" and try your action again. ** If that fixes the bug please report it to https://foss.heptapod.net/mercurial/mercurial_keyring/issues ** Python 3.9.5 (default, May 6 2021, 17:29:31) [MSC v.1928 64 bit (AMD64)] ** Mercurial Distributed SCM (version 5.9rc1+hg32.0e2f5733563d) ** Extensions loaded: absorb, blackbox, evolve 10.3.3, extdiff, fastannotate, fix, mercurial_keyring, mq, phabblocker 20210126, phabricator, rebase, show, strip, topic 0.22.3 Traceback (most recent call last): File "mercurial.lock", line 279, in _trylock File "mercurial.vfs", line 202, in makelock File "mercurial.util", line 2147, in makelock FileExistsError: [WinError 183] Cannot create a file when that file already exists: b'hp-omen:78348' -> b'C:\\Users\\Matt\\hg/.hg/store/lock' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 24, in <module> File "mercurial.dispatch", line 144, in run File "mercurial.dispatch", line 250, in dispatch File "mercurial.dispatch", line 294, in _rundispatch File "mercurial.dispatch", line 470, in _runcatch File "mercurial.dispatch", line 480, in _callcatch File "mercurial.scmutil", line 153, in callcatch File "mercurial.dispatch", line 460, in _runcatchfunc File "mercurial.dispatch", line 1273, in _dispatch File "mercurial.dispatch", line 918, in runcommand File "mercurial.dispatch", line 1285, in _runcommand File "mercurial.dispatch", line 1271, in <lambda> File "mercurial.util", line 1886, in check File "mercurial.util", line 1886, in check File "hgext.mq", line 4239, in mqcommand File "mercurial.util", line 1886, in check File "mercurial.util", line 1886, in check File "hgext.phabricator", line 314, in inner File "hgext.phabricator", line 2222, in phabimport File "hgext.phabricator", line 2123, in readpatch File "hgext.phabricator", line 2199, in _write File "mercurial.localrepo", line 2956, in lock File "mercurial.localrepo", line 2918, in _lock File "mercurial.lock", line 152, in trylock File "mercurial.lock", line 283, in _trylock File "mercurial.lock", line 314, in _readlock File "mercurial.vfs", line 221, in readlock File "mercurial.util", line 2163, in readlock File "mercurial.windows", line 619, in readlink ValueError: not a symbolic link Both exceptions look accurate (the file exists, and the Windows side can't read WSL side symlinks). I didn't try to reproduce this entirely within the Windows side, but we can do better than a cryptic stacktrace. With this change, the same scenario results in this abort: abort: C:\Users\Matt\hg/.hg/store/lock: The file cannot be accessed by the system When both the `push` and `phabimport` are done on the Windows side, it prints a message about waiting for the lock, and successfully applies the patch after the push completes. I'm not sure if there's enough info to be able to convert the abort into the wait scenario. As it stands now, we don't support symlinks on Windows, which requires either a UAC Administrator level process or an opt-in in developer mode, and there are several places where the new symlink on Windows support in py3 was explicitly disabled in order to get tests to pass quicker. Differential Revision: https://phab.mercurial-scm.org/D11333
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33206
45d6e2767a93 tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents: 33205
diff changeset
     1
# In most cases, the mercurial repository can be read by the bundled hg, but
45d6e2767a93 tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents: 33205
diff changeset
     2
# that isn't always true because third-party extensions may change the store
45d6e2767a93 tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents: 33205
diff changeset
     3
# format, for example. In which case, the system hg installation is used.
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff changeset
     4
#
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     5
# 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
     6
# 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
     7
# repository.
29219
3c9066ed557c tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff changeset
     8
#
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
     9
# 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
    10
# 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
    11
# the system installation.
37342
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33206
diff changeset
    12
37475
152f1b47e0ad tests: quote variable passed to shell test command
Yuya Nishihara <yuya@tcha.org>
parents: 37342
diff changeset
    13
if [ -n "$HGTESTEXTRAEXTENSIONS" ]; then
37342
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33206
diff changeset
    14
    for extension in $HGTESTEXTRAEXTENSIONS; do
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33206
diff changeset
    15
        extraoptions="$extraoptions --config extensions.$extension=!"
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33206
diff changeset
    16
    done
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33206
diff changeset
    17
fi
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33206
diff changeset
    18
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    19
syshg () {
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    20
    (
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    21
        syshgenv
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    22
        exec hg "$@"
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    23
    )
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    24
}
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    25
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    26
# 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
    27
# 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
    28
syshgenv () {
33126
98e2c78e309c tests: more completely restore the environment in syshgenv
Adam Simpkins <simpkins@fb.com>
parents: 33125
diff changeset
    29
    . "$HGTEST_RESTOREENV"
33116
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    30
    HGPLAIN=1
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    31
    export HGPLAIN
6c113a7dec52 tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents: 29219
diff changeset
    32
}
33125
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    33
33205
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    34
# The test-repo is a live hg repository which may have evolution markers
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    35
# created, e.g. when a ~/.hgrc enabled evolution.
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    36
#
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    37
# Tests may be run using a custom HGRCPATH, which do not enable evolution
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    38
# markers by default.
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    39
#
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    40
# If test-repo includes evolution markers, and we do not enable evolution
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    41
# markers, hg will occasionally complain when it notices them, which disrupts
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    42
# tests resulting in sporadic failures.
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    43
#
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    44
# Since we aren't performing any write operations on the test-repo, there's
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    45
# no harm in telling hg that we support evolution markers, which is what the
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    46
# following lines for the hgrc file do:
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    47
cat >> "$HGRCPATH" << EOF
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    48
[experimental]
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    49
evolution = createmarkers
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    50
EOF
2d7300cf3f3f tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents: 33204
diff changeset
    51
33206
45d6e2767a93 tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents: 33205
diff changeset
    52
# Use the system hg command if the bundled hg can't read the repository with
45d6e2767a93 tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents: 33205
diff changeset
    53
# no warning nor error.
45d6e2767a93 tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents: 33205
diff changeset
    54
if [ -n "`hg id -R "$TESTDIR/.." 2>&1 >/dev/null`" ]; then
33204
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    55
    alias testrepohg=syshg
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    56
    alias testrepohgenv=syshgenv
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    57
else
37342
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33206
diff changeset
    58
    alias testrepohg="hg $extraoptions"
33204
ddd65b4f3ae6 tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents: 33126
diff changeset
    59
    alias testrepohgenv=:
33125
acfce52518c4 tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents: 33116
diff changeset
    60
fi