tests/test-check-config.t
author Augie Fackler <augie@google.com>
Tue, 20 Jun 2017 09:45:02 -0400
changeset 32940 75be14993fda
parent 32851 cb6436e051ca
child 33116 6c113a7dec52
permissions -rw-r--r--
cleanup: use $PYTHON to run python in many more tests Spotted one of these, then wrote a check-code rule that caught them all. It will be the next change.

#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' |
  >   $PYTHON contrib/check-config.py
              limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
  
  conflict on profiling.showmin: ('with', '0.05') != ('with', '0.005')