Patchwork [3,of,3] help: test if "hg help TOPIC" reference is valid

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 5, 2017, 10:27 a.m.
Message ID <68e58570e474a8137ceb.1486290470@mimosa>
Download mbox | patch
Permalink /patch/18330/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 5, 2017, 10:27 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1485351557 -32400
#      Wed Jan 25 22:39:17 2017 +0900
# Node ID 68e58570e474a8137cebae3139875a44b1e05577
# Parent  184a7119f45bc0e9c3850ca01be27e5265f57346
help: test if "hg help TOPIC" reference is valid

It's quite easy to make a reference invalid by mistake.
Augie Fackler - Feb. 6, 2017, 3:27 a.m.
Nice, queued these.

> On Feb 5, 2017, at 5:27 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1485351557 -32400
> #      Wed Jan 25 22:39:17 2017 +0900
> # Node ID 68e58570e474a8137cebae3139875a44b1e05577
> # Parent  184a7119f45bc0e9c3850ca01be27e5265f57346
> help: test if "hg help TOPIC" reference is valid
> 
> It's quite easy to make a reference invalid by mistake.
> 
> diff --git a/tests/test-check-help.t b/tests/test-check-help.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-check-help.t
> @@ -0,0 +1,25 @@
> +#require test-repo
> +
> +  $ . "$TESTDIR/helpers-testrepo.sh"
> +
> +  $ cat <<'EOF' > scanhelptopics.py
> +  > from __future__ import absolute_import, print_function
> +  > import re
> +  > import sys
> +  > topics = set()
> +  > topicre = re.compile(r':hg:`help ([a-z0-9\-.]+)`')
> +  > for fname in sys.argv:
> +  >     with open(fname) as f:
> +  >         topics.update(m.group(1) for m in topicre.finditer(f.read()))
> +  > for s in sorted(topics):
> +  >     print(s)
> +  > EOF
> +
> +  $ cd "$TESTDIR"/..
> +
> +Check if ":hg:`help TOPIC`" is valid:
> +(use "xargs -n1 -t" to see which help commands are executed)
> +
> +  $ hg files 'glob:{hgext,mercurial}/**/*.py' \
> +  > | xargs python "$TESTTMP/scanhelptopics.py" \
> +  > | xargs -n1 hg help > /dev/null
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/tests/test-check-help.t b/tests/test-check-help.t
new file mode 100644
--- /dev/null
+++ b/tests/test-check-help.t
@@ -0,0 +1,25 @@ 
+#require test-repo
+
+  $ . "$TESTDIR/helpers-testrepo.sh"
+
+  $ cat <<'EOF' > scanhelptopics.py
+  > from __future__ import absolute_import, print_function
+  > import re
+  > import sys
+  > topics = set()
+  > topicre = re.compile(r':hg:`help ([a-z0-9\-.]+)`')
+  > for fname in sys.argv:
+  >     with open(fname) as f:
+  >         topics.update(m.group(1) for m in topicre.finditer(f.read()))
+  > for s in sorted(topics):
+  >     print(s)
+  > EOF
+
+  $ cd "$TESTDIR"/..
+
+Check if ":hg:`help TOPIC`" is valid:
+(use "xargs -n1 -t" to see which help commands are executed)
+
+  $ hg files 'glob:{hgext,mercurial}/**/*.py' \
+  > | xargs python "$TESTTMP/scanhelptopics.py" \
+  > | xargs -n1 hg help > /dev/null