Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Core
Tor
Commits
651bbe8a
Commit
651bbe8a
authored
Sep 02, 2019
by
Nick Mathewson
🎨
Browse files
Practracker: only consider files under "src/"
parent
78307ed1
Changes
4
Hide whitespace changes
Inline
Side-by-side
changes/ticket31578
0 → 100644
View file @
651bbe8a
o Minor bugfixes (practracker):
- When running check-best-practices, only consider files in the
src subdirectory. Previously we had recursively considered
all subdirectories, which made us get confused by the
temporary directories made by "make distcheck". Fixes bug
31578; bugfix on 0.4.1.1-alpha.
scripts/maint/practracker/practracker.py
View file @
651bbe8a
...
...
@@ -195,6 +195,9 @@ def main(argv):
help
=
"Maximum lines per function"
)
parser
.
add_argument
(
"--max-dependency-violations"
,
default
=
MAX_DEP_VIOLATIONS
,
help
=
"Maximum number of dependency violations to allow"
)
parser
.
add_argument
(
"--include-dir"
,
action
=
"append"
,
default
=
[
"src"
],
help
=
"A directory (under topdir) to search for source"
)
parser
.
add_argument
(
"topdir"
,
default
=
"."
,
nargs
=
"?"
,
help
=
"Top-level directory for the tor source"
)
args
=
parser
.
parse_args
(
argv
[
1
:])
...
...
@@ -216,7 +219,7 @@ def main(argv):
filt
.
addThreshold
(
problem
.
DependencyViolationItem
(
"*"
,
int
(
args
.
max_dependency_violations
)))
# 1) Get all the .c files we care about
files_list
=
util
.
get_tor_c_files
(
TOR_TOPDIR
)
files_list
=
util
.
get_tor_c_files
(
TOR_TOPDIR
,
args
.
include_dir
)
# 2) Initialize problem vault and load an optional exceptions file so that
# we don't warn about the past
...
...
scripts/maint/practracker/test_practracker.sh
View file @
651bbe8a
...
...
@@ -25,6 +25,7 @@ DATA="${PRACTRACKER_DIR}/testdata"
run_practracker
()
{
"
${
PYTHON
:-
python
}
"
"
${
PRACTRACKER_DIR
}
/practracker.py"
\
--include-dir
""
\
--max-include-count
=
0
--max-file-size
=
0
--max-function-size
=
0
--terse
\
"
${
DATA
}
/"
"
$@
"
;
}
...
...
scripts/maint/practracker/util.py
View file @
651bbe8a
...
...
@@ -3,22 +3,28 @@ import os
# We don't want to run metrics for unittests, automatically-generated C files,
# external libraries or git leftovers.
EXCLUDE_SOURCE_DIRS
=
{
"src/test/"
,
"src/trunnel/"
,
"src/rust/"
,
"src/ext/"
,
".git/"
}
"src/ext/"
}
EXCLUDE_FILES
=
{
"orconfig.h"
}
def
_norm
(
p
):
return
os
.
path
.
normcase
(
os
.
path
.
normpath
(
p
))
def
get_tor_c_files
(
tor_topdir
):
def
get_tor_c_files
(
tor_topdir
,
include_dirs
=
None
):
"""
Return a list with the .c and .h filenames we want to get metrics of.
"""
files_list
=
[]
exclude_dirs
=
{
_norm
(
os
.
path
.
join
(
tor_topdir
,
p
))
for
p
in
EXCLUDE_SOURCE_DIRS
}
if
include_dirs
is
None
:
topdirs
=
[
tor_topdir
]
else
:
topdirs
=
[
os
.
path
.
join
(
tor_topdir
,
inc
)
for
inc
in
include_dirs
]
for
root
,
directories
,
filenames
in
os
.
walk
(
tor_topdir
):
# TO THE REVIEWER: I will fix this indentation shortly. -nm
for
topdir
in
topdirs
:
for
root
,
directories
,
filenames
in
os
.
walk
(
topdir
):
# Remove all the directories that are excluded.
directories
[:]
=
[
d
for
d
in
directories
if
_norm
(
os
.
path
.
join
(
root
,
d
))
not
in
exclude_dirs
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment