[PATCH 1 of 6] tests: add test coverage for check-config

Gregory Szorc gregory.szorc at gmail.com
Thu Jun 15 18:18:11 UTC 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1497548799 25200
#      Thu Jun 15 10:46:39 2017 -0700
# Node ID e3ea064b4065c6b1a047b0ba88c61278e62a967b
# Parent  3abba5bc34546951b11b1bd3f5e5c77b90d950d1
tests: add test coverage for check-config

We didn't have explicit test coverage before. I broke check-config.py
as part of writing patches and was lucky I realized it.

diff --git a/tests/test-check-config.t b/tests/test-check-config.t
--- a/tests/test-check-config.t
+++ b/tests/test-check-config.t
@@ -1,8 +1,34 @@
 #require test-repo
 
   $ . "$TESTDIR/helpers-testrepo.sh"
+
+Sanity check check-config.py
+
+  $ cat > testfile.py << EOF
+  > # Good
+  > foo = ui.config('ui', 'username')
+  > # Missing
+  > foo = ui.config('ui', 'doesnotexist')
+  > # Missing different type
+  > foo = ui.configint('ui', 'missingint')
+  > # Missing with default value
+  > foo = ui.configbool('ui', 'missingbool1', default=True)
+  > foo = ui.configbool('ui', 'missingbool2', False)
+  > EOF
+
+  $ cat > files << EOF
+  > mercurial/help/config.txt
+  > $TESTTMP/testfile.py
+  > EOF
+
   $ cd "$TESTDIR"/..
 
+  $ python contrib/check-config.py < $TESTTMP/files
+  undocumented: ui.doesnotexist (str)
+  undocumented: ui.missingbool1 (bool) [True]
+  undocumented: ui.missingbool2 (bool)
+  undocumented: ui.missingint (int)
+
 New errors are not allowed. Warnings are strongly discouraged.
 
   $ hg files "set:(**.py or **.txt) - tests/**" | sed 's|\\|/|g' |


More information about the Mercurial-devel mailing list