From a82cf0a068f1b2f1f8830059fc5a7bd59675729c Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Tue, 14 Aug 2018 10:10:00 -0400 Subject: [PATCH] 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/rfSAXdyi Signed-off-by: Cleber Rosa --- Makefile | 9 ++-- requirements-selftests.txt | 4 -- requirements-travis.txt | 3 -- selftests/checkall | 2 +- selftests/cyclical_deps | 91 -------------------------------------- 5 files changed, 4 insertions(+), 105 deletions(-) delete mode 100755 selftests/cyclical_deps diff --git a/Makefile b/Makefile index 0bb3b0d1..9a0b66e2 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/requirements-selftests.txt b/requirements-selftests.txt index 651f5643..12318ac8 100644 --- a/requirements-selftests.txt +++ b/requirements-selftests.txt @@ -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 diff --git a/requirements-travis.txt b/requirements-travis.txt index cca07f97..e735df10 100644 --- a/requirements-travis.txt +++ b/requirements-travis.txt @@ -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 diff --git a/selftests/checkall b/selftests/checkall index 4b2f50e7..06c272dc 100755 --- a/selftests/checkall +++ b/selftests/checkall @@ -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' diff --git a/selftests/cyclical_deps b/selftests/cyclical_deps deleted file mode 100755 index 0525f2a0..00000000 --- a/selftests/cyclical_deps +++ /dev/null @@ -1,91 +0,0 @@ -#!/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 ' - -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) -- GitLab