[PATCH 1 of 7] tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1 of 7] tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments

FUJIWARA Katsunori-2
# HG changeset patch
# User FUJIWARA Katsunori <[hidden email]>
# Date 1550417245 -32400
#      Mon Feb 18 00:27:25 2019 +0900
# Node ID b618569414e7d2db2c1d31a17c15bda3b8830901
# Parent  6704696141b85f4a5b6b13171548085cae4dafe5
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r b618569414e7
# EXP-Topic tests-fix-check-code-errors
tests: use NO_CHECK_EOF as heredoc limit mark to omit checking code fragments

This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.

"primes.py" embedded in test-highlight.t causes an error of
check-commit.py below:

    don't use .next(), use next(...)

But changing embedded primes.py is painful, because it is committed in
test script, and affects hash IDs. On the other hand, primes.py itself
is never executed in test script.

Therefore, this patch uses NO_CHECK_EOF as heredoc limit mark in order
to omit any checking on this code fragments.

diff --git a/tests/test-highlight.t b/tests/test-highlight.t
--- a/tests/test-highlight.t
+++ b/tests/test-highlight.t
@@ -19,7 +19,7 @@
 
 create random Python file to exercise Pygments
 
-  $ cat <<EOF > primes.py
+  $ cat <<NO_CHECK_EOF > primes.py
   > """Fun with generators. Corresponding Haskell implementation:
   >
   > primes = 2 : sieve [3, 5..]
@@ -51,7 +51,7 @@ create random Python file to exercise Py
   >         n = 10
   >     p = primes()
   >     print("The first %d primes: %s" % (n, list(itertools.islice(p, n))))
-  > EOF
+  > NO_CHECK_EOF
   $ echo >> primes.py  # to test html markup with an empty line just before EOF
   $ hg ci -Ama
   adding primes.py
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 2 of 7] tests: define class in modern style to avoid check-code.py error

FUJIWARA Katsunori-2
# HG changeset patch
# User FUJIWARA Katsunori <[hidden email]>
# Date 1550417245 -32400
#      Mon Feb 18 00:27:25 2019 +0900
# Node ID 308243c661d7fb232997d290dfd861b95e36f090
# Parent  b618569414e7d2db2c1d31a17c15bda3b8830901
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r 308243c661d7
# EXP-Topic tests-fix-check-code-errors
tests: define class in modern style to avoid check-code.py error

This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.

diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -855,7 +855,7 @@ preoutgoing hook can prevent outgoing ch
   > def printtags(ui, repo, **args):
   >     ui.write(b'[%s]\n' % b', '.join(sorted(repo.tags())))
   >
-  > class container:
+  > class container(object):
   >     unreachable = 1
   > EOF
 
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 3 of 7] tests: bulk change to avoid "unneeded trailing ', ' ..." error of check-code.py

FUJIWARA Katsunori-2
In reply to this post by FUJIWARA Katsunori-2
# HG changeset patch
# User FUJIWARA Katsunori <[hidden email]>
# Date 1550417245 -32400
#      Mon Feb 18 00:27:25 2019 +0900
# Node ID d294202804a296c3f03e1c013886c5c1f174be6c
# Parent  308243c661d7fb232997d290dfd861b95e36f090
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r d294202804a2
# EXP-Topic tests-fix-check-code-errors
tests: bulk change to avoid "unneeded trailing ',' ..." error of check-code.py

This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.

"trailing ','" at the end of command option list in the code fragment
of test-bundle2-format.t is still left as it is, in order to follow
the style of command definitions in Mercurial core.

diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
--- a/tests/test-bundle2-format.t
+++ b/tests/test-bundle2-format.t
@@ -82,7 +82,8 @@ Create an extension to test bundle2 API
   >           (b'', b'genraise', False, b'includes a part that raise an exception during generation'),
   >           (b'', b'timeout', False, b'emulate a timeout during bundle generation'),
   >           (b'r', b'rev', [], b'includes those changeset in the bundle'),
-  >           (b'', b'compress', b'', b'compress the stream'),],
+  >           (b'', b'compress', b'', b'compress the stream'),
+  >          ],
   >          b'[OUTPUTFILE]')
   > def cmdbundle2(ui, repo, path=None, **opts):
   >     """write a bundle2 container on standard output"""
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -569,7 +569,7 @@ iterable in addbranchrevs()
   > extensions.loadall(myui)
   > extensions.populateui(myui)
   > repo = hg.repository(myui, b'a')
-  > hg.clone(myui, {}, repo, dest=b"ua", branch=[b"stable",])
+  > hg.clone(myui, {}, repo, dest=b"ua", branch=[b"stable"])
   > EOF
 
   $ "$PYTHON" branchclone.py
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 4 of 7] tests: replace imported module to avoid check-code.py error

FUJIWARA Katsunori-2
In reply to this post by FUJIWARA Katsunori-2
# HG changeset patch
# User FUJIWARA Katsunori <[hidden email]>
# Date 1550417245 -32400
#      Mon Feb 18 00:27:25 2019 +0900
# Node ID c1c8ae482985411a899cced234c2ef07d508c356
# Parent  d294202804a296c3f03e1c013886c5c1f174be6c
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r c1c8ae482985
# EXP-Topic tests-fix-check-code-errors
tests: replace imported module to avoid check-code.py error

This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -290,7 +290,7 @@ hg status -A:
 
   $ hg status -A -Tpickle > pickle
   >>> from __future__ import print_function
-  >>> import pickle
+  >>> from mercurial.util import pickle
   >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb")))
   >>> for s, p in data: print("%s %s" % (s, p))
   ! deleted
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 5 of 7] tests: bulk changes to avoid "omit superfluous pass" check-code.py error

FUJIWARA Katsunori-2
In reply to this post by FUJIWARA Katsunori-2
# HG changeset patch
# User FUJIWARA Katsunori <[hidden email]>
# Date 1550417245 -32400
#      Mon Feb 18 00:27:25 2019 +0900
# Node ID 617e8b6f8721d3f9ba351c614a47dfd287505704
# Parent  c1c8ae482985411a899cced234c2ef07d508c356
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r 617e8b6f8721
# EXP-Topic tests-fix-check-code-errors
tests: bulk changes to avoid "omit superfluous pass" check-code.py error

This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.

diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -688,13 +688,11 @@ hide outer repo
   > @command(b'debugfoobar', [], b'hg debugfoobar')
   > def debugfoobar(ui, repo, *args, **opts):
   >     "yet another debug command"
-  >     pass
   > @command(b'foo', [], b'hg foo')
   > def foo(ui, repo, *args, **opts):
   >     """yet another foo command
   >     This command has been DEPRECATED since forever.
   >     """
-  >     pass
   > EOF
   $ debugpath=`pwd`/debugextension.py
   $ echo "debugextension = $debugpath" >> $HGRCPATH
@@ -964,7 +962,6 @@ Test help topic with same name as extens
   > @command(b'multirevs', [], b'ARG', norepo=True)
   > def multirevs(ui, repo, arg, *args, **opts):
   >     """multirevs command"""
-  >     pass
   > EOF
   $ echo "multirevs = multirevs.py" >> $HGRCPATH
 
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -825,7 +825,6 @@ this is a section and erroring out weird
   > @command(b'hashelp', [], b'hg hashelp', norepo=True)
   > def hashelp(ui, *args, **kwargs):
   >     """Extension command's help"""
-  >     pass
   >
   > def uisetup(ui):
   >     ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 6 of 7] tests: replace "naked except clause" to avoid check-code.py error

FUJIWARA Katsunori-2
In reply to this post by FUJIWARA Katsunori-2
# HG changeset patch
# User FUJIWARA Katsunori <[hidden email]>
# Date 1550417245 -32400
#      Mon Feb 18 00:27:25 2019 +0900
# Node ID 4f1714df74136e8b46a35810e2e46a7d25b243a8
# Parent  617e8b6f8721d3f9ba351c614a47dfd287505704
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r 4f1714df7413
# EXP-Topic tests-fix-check-code-errors
tests: replace "naked except clause" to avoid check-code.py error

This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.

diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -38,7 +38,7 @@
   > def fakegetusers(ui, group):
   >     try:
   >         return acl._getusersorig(ui, group)
-  >     except:
+  >     except BaseException:
   >         return [b"fred", b"betty"]
   > acl._getusersorig = acl._getusers
   > acl._getusers = fakegetusers
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 7 of 7] tests: bulk changes to avoid whitespace errors of check-code.py

FUJIWARA Katsunori-2
In reply to this post by FUJIWARA Katsunori-2
# HG changeset patch
# User FUJIWARA Katsunori <[hidden email]>
# Date 1550417245 -32400
#      Mon Feb 18 00:27:25 2019 +0900
# Node ID 2f6a1d093864a07557a439d6c8fa0f583bc6a4ce
# Parent  4f1714df74136e8b46a35810e2e46a7d25b243a8
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r 2f6a1d093864
# EXP-Topic tests-fix-check-code-errors
tests: bulk changes to avoid whitespace errors of check-code.py

This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.

This revision avoids "whitespace" errors of check-code.py below:

  - missing whitespace after ","
  - missing whitespace in expression
  - no whitespace around "=" for named parameters
  - wrong whitespace around "="

diff --git a/tests/test-bundle2-pushback.t b/tests/test-bundle2-pushback.t
--- a/tests/test-bundle2-pushback.t
+++ b/tests/test-bundle2-pushback.t
@@ -25,7 +25,8 @@
   >                   b'key': b'new-server-mark',
   >                   b'old': b'',
   >                   b'new': b'tip'}
-  >         encodedparams = [(k, pushkey.encode(v)) for (k,v) in params.items()]
+  >         encodedparams = [(k, pushkey.encode(v))
+  >                           for (k, v) in params.items()]
   >         op.reply.newpart(b'pushkey', mandatoryparams=encodedparams)
   >     else:
   >         op.reply.newpart(b'output', data=b'pushback not enabled')
diff --git a/tests/test-convert-cvs.t b/tests/test-convert-cvs.t
--- a/tests/test-convert-cvs.t
+++ b/tests/test-convert-cvs.t
@@ -11,11 +11,11 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "convert = " >> $HGRCPATH
   $ cat > cvshooks.py <<EOF
-  > def cvslog(ui,repo,hooktype,log):
-  >     ui.write(b'%s hook: %d entries\n' % (hooktype,len(log)))
+  > def cvslog(ui, repo, hooktype, log):
+  >     ui.write(b'%s hook: %d entries\n' % (hooktype, len(log)))
   >
-  > def cvschangesets(ui,repo,hooktype,changesets):
-  >     ui.write(b'%s hook: %d changesets\n' % (hooktype,len(changesets)))
+  > def cvschangesets(ui, repo, hooktype, changesets):
+  >     ui.write(b'%s hook: %d changesets\n' % (hooktype, len(changesets)))
   > EOF
   $ hookpath=`pwd`
   $ cat <<EOF >> $HGRCPATH
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -640,7 +640,7 @@ import-checker.py or so on their content
 Make sure a broken uisetup doesn't globally break hg:
   $ cat > $TESTTMP/baduisetup.py <<EOF
   > def uisetup(ui):
-  >     1/0
+  >     1 / 0
   > EOF
 
 Even though the extension fails during uisetup, hg is still basically usable:
@@ -649,7 +649,7 @@ Even though the extension fails during u
     File "*/mercurial/extensions.py", line *, in _runuisetup (glob)
       uisetup(ui)
     File "$TESTTMP/baduisetup.py", line 2, in uisetup
-      1/0
+      1 / 0
   ZeroDivisionError: * by zero (glob)
   *** failed to set up extension baduisetup: * by zero (glob)
   Mercurial Distributed SCM (version *) (glob)
diff --git a/tests/test-hgweb-no-request-uri.t b/tests/test-hgweb-no-request-uri.t
--- a/tests/test-hgweb-no-request-uri.t
+++ b/tests/test-hgweb-no-request-uri.t
@@ -62,12 +62,12 @@ should be used from d74fc8dec2b4 onward
   > output = stringio()
   > env['PATH_INFO'] = '/'
   > env['QUERY_STRING'] = 'style=atom'
-  > process(hgweb.hgweb(b'.', name = b'repo'))
+  > process(hgweb.hgweb(b'.', name=b'repo'))
   >
   > output = stringio()
   > env['PATH_INFO'] = '/file/tip/'
   > env['QUERY_STRING'] = 'style=raw'
-  > process(hgweb.hgweb(b'.', name = b'repo'))
+  > process(hgweb.hgweb(b'.', name=b'repo'))
   >
   > output = stringio()
   > env['PATH_INFO'] = '/'
diff --git a/tests/test-import-context.t b/tests/test-import-context.t
--- a/tests/test-import-context.t
+++ b/tests/test-import-context.t
@@ -12,9 +12,9 @@ Test applying context diffs
   >     count = int(pattern[0:-1])
   >     char = pattern[-1].encode('utf8') + b'\n'
   >     if not lasteol and i == len(patterns) - 1:
-  >         fp.write((char*count)[:-1])
+  >         fp.write((char * count)[:-1])
   >     else:
-  >         fp.write(char*count)
+  >         fp.write(char * count)
   > fp.close()
   > EOF
   $ cat > cat.py <<EOF
diff --git a/tests/test-largefiles-small-disk.t b/tests/test-largefiles-small-disk.t
--- a/tests/test-largefiles-small-disk.t
+++ b/tests/test-largefiles-small-disk.t
@@ -9,7 +9,7 @@ Test how largefiles abort in case the di
   > #
   > # this makes the original largefiles code abort:
   > _origcopyfileobj = shutil.copyfileobj
-  > def copyfileobj(fsrc, fdst, length=16*1024):
+  > def copyfileobj(fsrc, fdst, length=16 * 1024):
   >     # allow journal files (used by transaction) to be written
   >     if b'journal.' in fdst.name:
   >         return _origcopyfileobj(fsrc, fdst, length)
diff --git a/tests/test-mq-missingfiles.t b/tests/test-mq-missingfiles.t
--- a/tests/test-mq-missingfiles.t
+++ b/tests/test-mq-missingfiles.t
@@ -15,10 +15,10 @@ future qrefresh.
   >
   > f = open(path, 'wb')
   > for i in range(len(args) // 2):
-  >    count, s = args[2*i:2*i+2]
+  >    count, s = args[2 * i:2 * i + 2]
   >    count = int(count)
   >    s = encode(s)
-  >    f.write(s*count)
+  >    f.write(s * count)
   > f.close()
   > EOF
 
diff --git a/tests/test-mq-qimport.t b/tests/test-mq-qimport.t
--- a/tests/test-mq-qimport.t
+++ b/tests/test-mq-qimport.t
@@ -9,11 +9,11 @@
   > assert (len(args) % 2) == 0
   >
   > f = open(path, 'wb')
-  > for i in range(len(args)//2):
-  >    count, s = args[2*i:2*i+2]
+  > for i in range(len(args) // 2):
+  >    count, s = args[2 * i:2 * i + 2]
   >    count = int(count)
   >    s = encode(s)
-  >    f.write(s*count)
+  >    f.write(s * count)
   > f.close()
   >
   > EOF
diff --git a/tests/test-patch-offset.t b/tests/test-patch-offset.t
--- a/tests/test-patch-offset.t
+++ b/tests/test-patch-offset.t
@@ -9,7 +9,7 @@
   > for pattern in patterns:
   >     count = int(pattern[0:-1])
   >     char = pattern[-1].encode('utf8') + b'\n'
-  >     fp.write(char*count)
+  >     fp.write(char * count)
   > fp.close()
   > EOF
 
diff --git a/tests/test-purge.t b/tests/test-purge.t
--- a/tests/test-purge.t
+++ b/tests/test-purge.t
@@ -52,7 +52,7 @@ delete an untracked file
   $ "$PYTHON" <<EOF
   > import os
   > import stat
-  > f= 'untracked_file_readonly'
+  > f = 'untracked_file_readonly'
   > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
   > EOF
   $ hg purge -p
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -12,9 +12,9 @@
   >     """
   >     if 3 not in subset:
   >        if 2 in subset:
-  >            return baseset([2,2])
+  >            return baseset([2, 2])
   >        return baseset()
-  >     return baseset([3,3,2,2])
+  >     return baseset([3, 3, 2, 2])
   >
   > mercurial.revset.symbols[b'r3232'] = r3232
   > EOF
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 7 of 7] tests: bulk changes to avoid whitespace errors of check-code.py

Augie Fackler-2
On Mon, Feb 18, 2019 at 02:19:30AM +0900, FUJIWARA Katsunori wrote:

> # HG changeset patch
> # User FUJIWARA Katsunori <[hidden email]>
> # Date 1550417245 -32400
> #      Mon Feb 18 00:27:25 2019 +0900
> # Node ID 2f6a1d093864a07557a439d6c8fa0f583bc6a4ce
> # Parent  4f1714df74136e8b46a35810e2e46a7d25b243a8
> # Available At https://bitbucket.org/foozy/mercurial-wip
> #              hg pull https://bitbucket.org/foozy/mercurial-wip -r 2f6a1d093864
> # EXP-Topic tests-fix-check-code-errors
> tests: bulk changes to avoid whitespace errors of check-code.py

queued, thanks. Very nice work!
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel