提交 a82cf0a0 编写于 作者: C Cleber Rosa

Drop cyclical deps check

This check is based on a number of packages that are either Python 2
only and/or are not available on most distros.  And, pylint itself
supports this type of check.

Reference: https://trello.com/c/rfSAXdyiSigned-off-by: NCleber Rosa <crosa@redhat.com>
上级 1dfc72a9
......@@ -128,22 +128,19 @@ requirements-plugins: requirements
smokecheck: clean develop
./scripts/avocado run passtest.py
check: clean develop check_cyclical modules_boundaries
check: clean develop modules_boundaries
# Unless manually set, this is equivalent to AVOCADO_CHECK_LEVEL=0
selftests/checkall
selftests/check_tmp_dirs
check-full: clean develop check_cyclical modules_boundaries
check-full: clean develop modules_boundaries
AVOCADO_CHECK_LEVEL=2 selftests/checkall
selftests/check_tmp_dirs
selfcheck: clean check_cyclical modules_boundaries develop
selfcheck: clean modules_boundaries develop
AVOCADO_SELF_CHECK=1 selftests/checkall
selftests/check_tmp_dirs
check_cyclical:
selftests/cyclical_deps avocado
modules_boundaries:
selftests/modules_boundaries
......
......@@ -14,10 +14,6 @@ funcsigs>=0.4
# To run make check
pep8>=1.6.2
Pillow>=2.2.1
snakefood>=1.4; python_version <= '2.7'
networkx>=1.9.1; python_version <= '2.7'
pygraphviz>=1.3rc2; python_version <= '2.7'
pydot>=1.2.3; python_version <= '2.7'
aexpect>=1.0.0
psutil>=3.1.1
# six is a stevedore depedency, but we also use it directly
......
......@@ -9,9 +9,6 @@ pep8==1.6.2
requests==1.2.3
PyYAML==3.11
Pillow==2.8.1
snakefood==1.4; python_version <= '2.7'
networkx==1.9.1; python_version <= '2.7'
pygraphviz==1.3rc2; python_version <= '2.7'
mock==1.2.0; python_version <= '2.7'
aexpect==1.4.0
psutil==3.1.1
......
......@@ -167,7 +167,7 @@ results_dir_content() {
}
[ "$SKIP_RESULTSDIR_CHECK" ] || RESULTS_DIR_CONTENT="$(ls $RESULTS_DIR 2> /dev/null)"
run_rc lint 'inspekt lint --exclude=.git --enable W0101,W0102,W0404,W0611,W0612,W0622'
run_rc lint 'inspekt lint --exclude=.git --enable R0401,W0101,W0102,W0404,W0611,W0612,W0622'
# Skip checking test_utils_cpu.py due to inspektor bug
run_rc indent 'inspekt indent --exclude=.git,selftests/unit/test_utils_cpu.py'
run_rc style 'inspekt style --exclude=.git --disable E501,E265,W601,E402,E722'
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
"""
Simple script to test cyclical dependencies in modules.
Requirements:
- SnakeFood (pip install snakefood)
- NetworkX (yum/apt-get install python-networkx)
"""
__author__ = 'Ruda Moura <rmoura@redhat.com>'
import os
import sys
import subprocess
import tempfile
# it doesn't make sense to go any further on Python 3 because snakefood
# won't be available anyway. it's not fair to say this check failed, so
# let's exit successfully. the check should be performend when running
# on Python 2.
if sys.version_info[0] == 3:
sys.exit(0)
try:
import networkx as nx
except ImportError:
print("NetworkX is not installed and is required!", file=sys.stderr)
print("Please, install 'python-networkx' with yum or apt.", file=sys.stderr)
sys.exit(2)
# simple magic for using scripts within a source tree
basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if os.path.isdir(os.path.join(basedir, 'avocado')):
os.environ['PATH'] += ":" + os.path.join(basedir, 'scripts')
os.environ['PATH'] += ":" + os.path.join(basedir, 'libexec')
sys.path.append(basedir)
from avocado.utils import process
def has_snakefood():
with open(os.devnull, 'w') as null:
try:
cmd = ['sfood', '-h']
subprocess.call(cmd, stdout=null)
except Exception as detail:
print("Could not find sfood utility: %s: %s" % (cmd, detail), file=sys.stderr)
print("Did you forget to 'pip install snakefood'?", file=sys.stderr)
return False
return True
def generate_dot_file(path):
cmdline = 'sfood --internal %s | sfood-graph --remove-extensions'
output = process.system_output(cmdline % path, shell=True)
tmp = tempfile.mktemp()
with open(tmp, 'w') as sfood_file:
sfood_file.write(output)
return tmp
def cyclical_deps(path_dot):
graph = nx.DiGraph(nx.nx_agraph.read_dot(path_dot))
cycles = list(nx.simple_cycles(graph))
if cycles:
print('Found cyclical dependencies in module(s):')
for cycle in cycles:
print('*', ' <=> '.join(cycle))
return True
else:
print('No cyclical dependencies found')
print('OK')
return False
if __name__ == '__main__':
if sys.argv[1:] and has_snakefood():
dot = generate_dot_file(sys.argv[1])
has_cycles = cyclical_deps(dot)
os.remove(dot)
if has_cycles:
sys.exit(1)
else:
sys.exit(2)
sys.exit(0)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册