# HG changeset patch # User Sean Farley # Date 1511938198 28800 # Node ID e01f599181604f26fb8d10fe7effc70a0e548e02 # Parent 45c8f33fc7d8b6843ec41ce4ce0c9ee10b5cbe46 tests: add pyflakes check to the test suite This is a large patch since we're copying over Mercurial's helpers-testrepo.sh and a slightly modified version of pyflakes.t diff -r 45c8f33fc7d8 -r e01f59918160 tests/helpers-testrepo.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/helpers-testrepo.sh Tue Nov 28 22:49:58 2017 -0800 @@ -0,0 +1,53 @@ +# In most cases, the mercurial repository can be read by the bundled hg, but +# that isn't always true because third-party extensions may change the store +# format, for example. In which case, the system hg installation is used. +# +# We want to use the hg version being tested when interacting with the test +# repository, and the system hg when interacting with the mercurial source code +# repository. +# +# The mercurial source repository was typically orignally cloned with the +# system mercurial installation, and may require extensions or settings from +# the system installation. +syshg () { + ( + syshgenv + exec hg "$@" + ) +} + +# Revert the environment so that running "hg" runs the system hg +# rather than the test hg installation. +syshgenv () { + . "$HGTEST_RESTOREENV" + HGPLAIN=1 + export HGPLAIN +} + +# The test-repo is a live hg repository which may have evolution markers +# created, e.g. when a ~/.hgrc enabled evolution. +# +# Tests may be run using a custom HGRCPATH, which do not enable evolution +# markers by default. +# +# If test-repo includes evolution markers, and we do not enable evolution +# markers, hg will occasionally complain when it notices them, which disrupts +# tests resulting in sporadic failures. +# +# Since we aren't performing any write operations on the test-repo, there's +# no harm in telling hg that we support evolution markers, which is what the +# following lines for the hgrc file do: +cat >> "$HGRCPATH" << EOF +[experimental] +evolution = createmarkers +EOF + +# Use the system hg command if the bundled hg can't read the repository with +# no warning nor error. +if [ -n "`hg id -R "$TESTDIR/.." 2>&1 >/dev/null`" ]; then + alias testrepohg=syshg + alias testrepohgenv=syshgenv +else + alias testrepohg=hg + alias testrepohgenv=: +fi diff -r 45c8f33fc7d8 -r e01f59918160 tests/test-check-pyflakes.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-check-pyflakes.t Tue Nov 28 22:49:58 2017 -0800 @@ -0,0 +1,19 @@ +#require test-repo pyflakes hg10 + + $ . "$TESTDIR/helpers-testrepo.sh" + +run pyflakes on all tracked files ending in .py or without a file ending +(skipping binary file random-seed) + + $ cat > test.py < print(undefinedname) + > EOF + $ pyflakes test.py 2>/dev/null + test.py:1: undefined name 'undefinedname' + [1] + $ cd "`dirname "$TESTDIR"`" + + $ testrepohg locate 'set:**.py or grep("^#!.*python")' \ + > -X tests/ \ + > 2>/dev/null \ + > | xargs pyflakes 2>/dev/null