Patchwork tests: confirm that a badly documented extension doesn't cause a crash

login
register
mail settings
Submitter Simon Farnsworth
Date Feb. 11, 2016, 2:43 p.m.
Message ID <1a53db18927270c9156a.1455201791@devvm631.lla1.facebook.com>
Download mbox | patch
Permalink /patch/13119/
State Superseded
Commit 550097d01ca3573626ae2eebe6c63b53f6084cde
Headers show

Comments

Simon Farnsworth - Feb. 11, 2016, 2:43 p.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1455201149 28800
#      Thu Feb 11 06:32:29 2016 -0800
# Node ID 1a53db18927270c9156aac0f712acc3b399b1ea5
# Parent  ab0871393d3e0827645371b3d764c268c7ebde94
tests: confirm that a badly documented extension doesn't cause a crash

An external extension whose docstring doesn't conform to Mercurial standards
used to cause crashes. Test that we omit such extensions when you do a
keyword search.
Sean Farley - Feb. 11, 2016, 8:09 p.m.
Simon Farnsworth <simonfar@fb.com> writes:

> # HG changeset patch
> # User Simon Farnsworth <simonfar@fb.com>
> # Date 1455201149 28800
> #      Thu Feb 11 06:32:29 2016 -0800
> # Node ID 1a53db18927270c9156aac0f712acc3b399b1ea5
> # Parent  ab0871393d3e0827645371b3d764c268c7ebde94
> tests: confirm that a badly documented extension doesn't cause a crash
>
> An external extension whose docstring doesn't conform to Mercurial standards
> used to cause crashes. Test that we omit such extensions when you do a
> keyword search.

Thanks for the follow-up :-) Yuya, look good to you?
Pierre-Yves David - Feb. 12, 2016, 1:46 p.m.
On 02/11/2016 02:43 PM, Simon Farnsworth wrote:
> # HG changeset patch
> # User Simon Farnsworth <simonfar@fb.com>
> # Date 1455201149 28800
> #      Thu Feb 11 06:32:29 2016 -0800
> # Node ID 1a53db18927270c9156aac0f712acc3b399b1ea5
> # Parent  ab0871393d3e0827645371b3d764c268c7ebde94
> tests: confirm that a badly documented extension doesn't cause a crash
>
> An external extension whose docstring doesn't conform to Mercurial standards
> used to cause crashes. Test that we omit such extensions when you do a
> keyword search.


Thanks for following up with a test case!

> diff --git a/tests/test-baddocs-extension.t b/tests/test-baddocs-extension.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-baddocs-extension.t
> @@ -0,0 +1,24 @@

However, adding a whole new file for such trivial thing is discouraged. 
Can you add it to an existing file?

Details on this policy here:

https://www.mercurial-scm.org/wiki/WritingTests#Be_careful_with_new_test_scripts.21

Also, please mention the issue number in your test "documentation" so 
that people can easily get more context on where this test is coming from.

Cheers

Patch

diff --git a/tests/test-baddocs-extension.t b/tests/test-baddocs-extension.t
new file mode 100644
--- /dev/null
+++ b/tests/test-baddocs-extension.t
@@ -0,0 +1,24 @@ 
+  $ cat >badext.py <<EOF
+  > """
+  > badext is bad
+  > """
+  > from mercurial import extensions, copies
+  > testedwith = 'internal'
+  > 
+  > def pathcopieswrapper(orig, x, y, match=None):
+  >     func = lambda: orig(x, y, match=None)
+  >     return func()
+  > 
+  > def extsetup(ui):
+  >     extensions.wrapfunction(copies, 'pathcopies', pathcopieswrapper)
+  > EOF
+  $ abspath=`pwd`/badext.py
+  $ cat <<EOF >> $HGRCPATH
+  > [extensions]
+  > badext = $abspath
+  > EOF
+
+  $ hg help --keyword badext
+  Topics:
+  
+   extensions Using Additional Features