From 5a1bcf97946cc683beb0186b3a752e981370d1ab Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 7 Sep 2022 22:04:57 -0400 Subject: [PATCH] Tests: Add lint-py checker --- Makefile.in | 2 +- test_regress/t/t_dist_lint_py.pl | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 test_regress/t/t_dist_lint_py.pl diff --git a/Makefile.in b/Makefile.in index 6903e37f9..08271b047 100644 --- a/Makefile.in +++ b/Makefile.in @@ -394,7 +394,7 @@ FLAKE8_FLAGS = \ --ignore=E123,E129,E251,E402,E501,W503,W504,E701 PYLINT = pylint -PYLINT_FLAGS = --disable=R0801 +PYLINT_FLAGS = --score=n --disable=R0801 lint-py: -$(FLAKE8) $(FLAKE8_FLAGS) $(PY_PROGRAMS) diff --git a/test_regress/t/t_dist_lint_py.pl b/test_regress/t/t_dist_lint_py.pl new file mode 100755 index 000000000..b0af4f6e6 --- /dev/null +++ b/test_regress/t/t_dist_lint_py.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2022 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(dist => 1); + +my $root = ".."; + +if (!-r "$root/.git") { + skip("Not in a git repository"); +} else { + my $cmd = "cd $root && make lint-py"; + my $out = `$cmd`; + my $first; + foreach my $line (split /\n+/, $out) { + next if $line =~ /^---/; + next if $line =~ /^flake8/; + next if $line =~ /^pylint/; + print "$line\n"; + if (!defined $first) { + $first = $line; + error("lint-py failed: ", $first); + } + } +} + +ok(1); +1;