[PATCH 2 of 2 BLACKGNAROCK-V2] formatting: introduce a `test-check-format-black.t` that enforce formatting

Augie Fackler raf at durin42.com
Tue Oct 8 12:57:15 EDT 2019


queued, thanks for the cleanups.

> On Oct 7, 2019, at 14:14, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
> 
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at octobus.net>
> # Date 1570463578 14400
> #      Mon Oct 07 11:52:58 2019 -0400
> # Node ID c5294d305666f3b5de9a001c9327ec8eab97eee5
> # Parent  3c5fc04c5cbc3b146105b0e6764634c77067dbd5
> # EXP-Topic blackgnarok-bytemageddon
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c5294d305666
> formatting: introduce a `test-check-format-black.t` that enforce formatting
> 
> This should prevent use to drift away from the expect format.
> 
> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -1,4 +1,4 @@
> -from __future__ import absolute_import
> +from __future__ import absolute_import, print_function
> 
> import os
> import re
> @@ -972,3 +972,14 @@ def has_emacs():
>     # 24.4, so we allow emacs 24.4, 24.5, and 25+ (24.5 was the last
>     # 24 release)
>     return matchoutput('emacs --version', b'GNU Emacs 2(4.4|4.5|5|6|7|8|9)')
> +
> +
> +# @check('black', 'the black formatter for python')
> + at check('grey', 'grey, the fork of the black formatter for python')
> +def has_black():
> +    # use that to actual black as soon as possible
> +    # blackcmd = b'black --version'
> +    blackcmd = b'python3 $RUNTESTDIR/../contrib/grey.py --version'
> +    # version_regex = b'black, version \d'
> +    version_regex = b'grey.py, version \d'
> +    return matchoutput(blackcmd, version_regex)
> diff --git a/tests/test-check-format.t b/tests/test-check-format.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-check-format.t
> @@ -0,0 +1,7 @@
> +#require grey
> +
> +(this should use the actual black as soon as possible)
> +
> +  $ cd $RUNTESTDIR/..
> +  $ python3 contrib/grey.py -S --quiet --check --diff `hg files 'set:**.py - hgext/fsmonitor/pywatchman/** - mercurial/thirdparty/** - "contrib/python-zstandard/**" - contrib/grey.py'`
> +



More information about the Mercurial-devel mailing list