tests/test-check-help.t
author Yuya Nishihara <yuya@tcha.org>
Wed, 25 Jan 2017 22:39:17 +0900
changeset 30880 b6c051cd1231
child 31498 a248bbfa0bc7
permissions -rw-r--r--
help: test if "hg help TOPIC" reference is valid It's quite easy to make a reference invalid by mistake.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30880
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     1
#require test-repo
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     2
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     3
  $ . "$TESTDIR/helpers-testrepo.sh"
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     4
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     5
  $ cat <<'EOF' > scanhelptopics.py
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     6
  > from __future__ import absolute_import, print_function
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     7
  > import re
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     8
  > import sys
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     9
  > topics = set()
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    10
  > topicre = re.compile(r':hg:`help ([a-z0-9\-.]+)`')
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    11
  > for fname in sys.argv:
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    12
  >     with open(fname) as f:
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    13
  >         topics.update(m.group(1) for m in topicre.finditer(f.read()))
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    14
  > for s in sorted(topics):
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    15
  >     print(s)
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    16
  > EOF
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    17
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    18
  $ cd "$TESTDIR"/..
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    19
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    20
Check if ":hg:`help TOPIC`" is valid:
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    21
(use "xargs -n1 -t" to see which help commands are executed)
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    22
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    23
  $ hg files 'glob:{hgext,mercurial}/**/*.py' \
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    24
  > | xargs python "$TESTTMP/scanhelptopics.py" \
b6c051cd1231 help: test if "hg help TOPIC" reference is valid
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    25
  > | xargs -n1 hg help > /dev/null