Debian Codegraph @

tests/test-check-code.t

raw
1 #require test-repo
2
3 $ . "$TESTDIR/helpers-testrepo.sh"
4 $ check_code="$TESTDIR"/../contrib/check-code.py
5 $ cd "$TESTDIR"/..
6
7 New errors are not allowed. Warnings are strongly discouraged.
8 (The writing "no-che?k-code" is for not skipping this file when checking.)
9
10 $ testrepohg locate \
11 > -X contrib/python-zstandard \
12 > -X hgext/fsmonitor/pywatchman \
13 > -X mercurial/thirdparty \
14 > -X mercurial/pythoncapi_compat.h \
15 > | sed 's-\\-/-g' | "$check_code" --warnings --per-file=0 - || false
16 Skipping contrib/automation/hgautomation/__init__.py it has no-che?k-code (glob)
17 Skipping contrib/automation/hgautomation/aws.py it has no-che?k-code (glob)
18 Skipping contrib/automation/hgautomation/cli.py it has no-che?k-code (glob)
19 Skipping contrib/automation/hgautomation/linux.py it has no-che?k-code (glob)
20 Skipping contrib/automation/hgautomation/pypi.py it has no-che?k-code (glob)
21 Skipping contrib/automation/hgautomation/ssh.py it has no-che?k-code (glob)
22 Skipping contrib/automation/hgautomation/try_server.py it has no-che?k-code (glob)
23 Skipping contrib/automation/hgautomation/windows.py it has no-che?k-code (glob)
24 Skipping contrib/automation/hgautomation/winrm.py it has no-che?k-code (glob)
25 Skipping contrib/fuzz/FuzzedDataProvider.h it has no-che?k-code (glob)
26 Skipping contrib/fuzz/standalone_fuzz_target_runner.cc it has no-che?k-code (glob)
27 Skipping contrib/packaging/hgpackaging/cli.py it has no-che?k-code (glob)
28 Skipping contrib/packaging/hgpackaging/downloads.py it has no-che?k-code (glob)
29 Skipping contrib/packaging/hgpackaging/inno.py it has no-che?k-code (glob)
30 Skipping contrib/packaging/hgpackaging/pyoxidizer.py it has no-che?k-code (glob)
31 Skipping contrib/packaging/hgpackaging/util.py it has no-che?k-code (glob)
32 Skipping contrib/packaging/hgpackaging/wix.py it has no-che?k-code (glob)
33 Skipping hgext/fsmonitor/__init__.py it has no-che?k-code (glob)
34 Skipping i18n/polib.py it has no-che?k-code (glob)
35 Skipping mercurial/statprof.py it has no-che?k-code (glob)
36 Skipping tests/testlib/badserverext.py it has no-che?k-code (glob)
37
38 @commands in debugcommands.py should be in alphabetical order.
39
40 >>> import re
41 >>> commands = []
42 >>> with open('mercurial/debugcommands.py', 'rb') as fh:
43 ... for line in fh:
44 ... m = re.match(br"^@command\('([a-z]+)", line)
45 ... if m:
46 ... commands.append(m.group(1))
47 >>> scommands = list(sorted(commands))
48 >>> for i, command in enumerate(scommands):
49 ... if command != commands[i]:
50 ... print('commands in debugcommands.py not sorted; first differing '
51 ... 'command is %s; expected %s' % (commands[i], command))
52 ... break
53
54 Prevent adding new files in the root directory accidentally.
55
56 $ testrepohg files 'glob:*'
57 .arcconfig
58 .clang-format
59 .editorconfig
60 .flake8
61 .gitattributes
62 .hgignore
63 .hgsigs
64 .hgtags
65 .jshintrc
66 CONTRIBUTING.md
67 CONTRIBUTORS
68 COPYING
69 MANIFEST.in
70 Makefile
71 README.rst
72 hg
73 hgeditor
74 hgweb.cgi
75 pyproject.toml
76 rustfmt.toml
77 setup.py
78
79 Prevent adding modules which could be shadowed by ancient .so/.dylib.
80
81 $ testrepohg files \
82 > mercurial/base85.py \
83 > mercurial/bdiff.py \
84 > mercurial/diffhelpers.py \
85 > mercurial/mpatch.py \
86 > mercurial/osutil.py \
87 > mercurial/parsers.py \
88 > mercurial/zstd.py
89 [1]
90
91 Keep python3 tests sorted:
92 $ sort < contrib/python3-whitelist > $TESTTMP/py3sorted
93 $ cmp contrib/python3-whitelist $TESTTMP/py3sorted || echo 'Please sort passing tests!'
94
95 Keep Windows line endings in check
96
97 $ testrepohg files 'set:eol(dos)'
98 contrib/packaging/build-windows-wheels.bat
99 contrib/packaging/wix/COPYING.rtf
100 contrib/vs2022-settings.json
101 contrib/win32/hg.bat
102 contrib/win32/mercurial.ini