# HG changeset patch # User FUJIWARA Katsunori # Date 1534994754 -32400 # Node ID ff47ba7a29030401e1fe7ccb734f2c9693ad4df7 # Parent 726cfc47f17a70c863c772b50e3645c2c1b10633 tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments This patch uses NO_CHECK_EOF as heredoc limit mark instead of EOF, in order to avoid checking all python code fragments in test-contrib-check-code.t, because almost all of them has un-recommended implementations intentionally. diff -r 726cfc47f17a -r ff47ba7a2903 tests/test-contrib-check-code.t --- a/tests/test-contrib-check-code.t Thu Aug 23 12:25:54 2018 +0900 +++ b/tests/test-contrib-check-code.t Thu Aug 23 12:25:54 2018 +0900 @@ -1,14 +1,14 @@ - $ cat > correct.py < correct.py < def toto(arg1, arg2): > del arg2 > return (5 + 6, 9) - > EOF - $ cat > wrong.py < NO_CHECK_EOF + $ cat > wrong.py < def toto( arg1, arg2): > del(arg2) > return ( 5+6, 9) - > EOF - $ cat > quote.py < NO_CHECK_EOF + $ cat > quote.py < # let's use quote in comments > (''' ( 4x5 ) > but """\\''' and finally''', @@ -16,8 +16,8 @@ > '"""', 42+1, """and > ( 4-1 ) """, "( 1+1 )\" and ") > a, '\\\\\\\\', "\\\\\\" x-2", "c-1" - > EOF - $ cat > classstyle.py < NO_CHECK_EOF + $ cat > classstyle.py < class newstyle_class(object): > pass > @@ -29,7 +29,7 @@ > > no_class = 1: > pass - > EOF + > NO_CHECK_EOF $ check_code="$TESTDIR"/../contrib/check-code.py $ "$check_code" ./wrong.py ./correct.py ./quote.py ./classstyle.py ./wrong.py:1: @@ -52,11 +52,11 @@ > class empty(): class foo() creates old style object, use class foo(object) [1] - $ cat > python3-compat.py << EOF + $ cat > python3-compat.py << NO_CHECK_EOF > foo <> bar > reduce(lambda a, b: a + b, [1, 2, 3, 4]) > dict(key=value) - > EOF + > NO_CHECK_EOF $ "$check_code" python3-compat.py python3-compat.py:1: > foo <> bar @@ -69,13 +69,13 @@ dict() is different in Py2 and 3 and is slower than {} [1] - $ cat > foo.c < foo.c < void narf() { > strcpy(foo, bar); > // strcpy_s is okay, but this comment is not > strcpy_s(foo, bar); > } - > EOF + > NO_CHECK_EOF $ "$check_code" ./foo.c ./foo.c:2: > strcpy(foo, bar); @@ -85,7 +85,7 @@ don't use //-style comments [1] - $ cat > is-op.py < is-op.py < # is-operator comparing number or string literal > x = None > y = x is 'foo' @@ -96,7 +96,7 @@ > y = x is not "foo" > y = x is not 5346 > y = x is not -6 - > EOF + > NO_CHECK_EOF $ "$check_code" ./is-op.py ./is-op.py:3: @@ -125,21 +125,21 @@ object comparison with literal [1] - $ cat > for-nolineno.py < for-nolineno.py < except: - > EOF + > NO_CHECK_EOF $ "$check_code" for-nolineno.py --nolineno for-nolineno.py:0: > except: naked except clause [1] - $ cat > warning.t < warning.t < $ function warnonly { > > } > $ diff -N aaa > $ function onwarn {} - > EOF + > NO_CHECK_EOF $ "$check_code" warning.t $ "$check_code" --warn warning.t warning.t:1: @@ -152,20 +152,20 @@ > $ function onwarn {} warning: don't use 'function', use old style [1] - $ cat > error.t < error.t < $ [ foo == bar ] - > EOF + > NO_CHECK_EOF $ "$check_code" error.t error.t:1: > $ [ foo == bar ] [ foo == bar ] is a bashism, use [ foo = bar ] instead [1] $ rm error.t - $ cat > raise-format.py < raise-format.py < raise SomeException, message > # this next line is okay > raise SomeException(arg1, arg2) - > EOF + > NO_CHECK_EOF $ "$check_code" not-existing.py raise-format.py Skipping*not-existing.py* (glob) raise-format.py:1: @@ -173,10 +173,10 @@ don't use old-style two-argument raise, use Exception(message) [1] - $ cat < tab.t + $ cat < tab.t > indent > > heredoc - > EOF + > NO_CHECK_EOF $ "$check_code" tab.t tab.t:1: > indent @@ -184,7 +184,7 @@ [1] $ rm tab.t - $ cat > rst.py < rst.py < """problematic rst text > > .. note:: @@ -213,7 +213,7 @@ > .. note:: > plus bad > """ - > EOF + > NO_CHECK_EOF $ $check_code -w rst.py rst.py:3: > .. note:: @@ -223,7 +223,7 @@ warning: add two newlines after '.. note::' [1] - $ cat > ./map-inside-gettext.py < ./map-inside-gettext.py < print(_("map inside gettext %s" % v)) > > print(_("concatenating " " by " " space %s" % v)) @@ -234,7 +234,7 @@ > > print(_( > "leading spaces inside of '(' %s" % v)) - > EOF + > NO_CHECK_EOF $ "$check_code" ./map-inside-gettext.py ./map-inside-gettext.py:1: > print(_("map inside gettext %s" % v)) @@ -256,12 +256,12 @@ web templates $ mkdir -p mercurial/templates - $ cat > mercurial/templates/example.tmpl < mercurial/templates/example.tmpl < {desc} > {desc|escape} > {desc|firstline} > {desc|websub} - > EOF + > NO_CHECK_EOF $ "$check_code" --warnings mercurial/templates/example.tmpl mercurial/templates/example.tmpl:2: @@ -271,7 +271,7 @@ 'string join across lines with no space' detection - $ cat > stringjoin.py < stringjoin.py < foo = (' foo' > 'bar foo.' > 'bar foo:' @@ -281,11 +281,11 @@ > 'bar foo+' > 'bar foo-' > 'bar') - > EOF + > NO_CHECK_EOF 'missing _() in ui message' detection - $ cat > uigettext.py < uigettext.py < ui.status("% 10s %05d % -3.2f %*s %%" > # this use '\\\\' instead of '\\', because the latter in > # heredoc on shell becomes just '\' @@ -294,11 +294,11 @@ > """ > '''.:*+-= > ''' "%-6d \n 123456 .:*+-= foobar") - > EOF + > NO_CHECK_EOF superfluous pass - $ cat > superfluous_pass.py < superfluous_pass.py < # correct examples > if foo: > pass @@ -326,7 +326,7 @@ > docstring also > means no pass""" > pass - > EOF + > NO_CHECK_EOF (Checking multiple invalid files at once examines whether caching translation table for repquote() works as expected or not. All files