diff --git a/.tidyallrc b/.tidyallrc index 718b4d8d..39457283 100644 --- a/.tidyallrc +++ b/.tidyallrc @@ -1,3 +1,7 @@ +[Flake8] +ignore = tests/individually-importing/* +select = **/*.py + [PerlTidy] argv = -ci=4 -bl -cti=0 ignore = **/{cmpdigest,valgrind,verify}--*.t diff --git a/Makefile b/Makefile index 649e158f..855bc55b 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,8 @@ pretest: @rm -f tests/individually-importing/*.py # To avoid stray files python scripts/gen_individual_importing_tests.py -TEST_ENV = PYTHONPATH="`pwd`:`pwd`/tests/lib" +TEST_ENV_PATH = "`pwd`:`pwd`/tests/lib" +TEST_ENV = PYTHONPATH=$(TEST_ENV_PATH) PERL5LIB=$(TEST_ENV_PATH) TEST_FILES = tests/style/*.t tests/unit-generated/*.py tests/individually-importing/*.py define RUN_TESTS diff --git a/tests/lib/Code/TidyAll/Plugin/Flake8.pm b/tests/lib/Code/TidyAll/Plugin/Flake8.pm new file mode 100644 index 00000000..14aaeb8e --- /dev/null +++ b/tests/lib/Code/TidyAll/Plugin/Flake8.pm @@ -0,0 +1,51 @@ +package Code::TidyAll::Plugin::Flake8; + +use Moo; +use String::ShellQuote qw/ shell_quote /; + +extends 'Code::TidyAll::Plugin'; + +sub validate_file +{ + my ( $self, $fn ) = @_; + my $cmd = shell_quote( 'flake8', $fn ); + if (`$cmd`) + { + die 'not valid'; + } + return; +} + +1; + +__END__ + +=head1 COPYRIGHT & LICENSE + +Copyright 2018 by Shlomi Fish + +This program is distributed under the MIT / Expat License: +L + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +=cut diff --git a/tests/style/py-flake8.t b/tests/style/py-flake8.t deleted file mode 100644 index 5bca436e..00000000 --- a/tests/style/py-flake8.t +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More; -use Test::Differences qw( eq_or_diff ); - -use File::Find::Object (); -use String::ShellQuote qw/ shell_quote /; - -if ( $^O =~ /\AMSWin/ ) -{ - plan skip_all => "command line exceeded on ms windows."; -} -else -{ - plan tests => 1; -} - -my %skip = ( - map { $_ => 1 } - qw( - ) -); - -my $tree = File::Find::Object->new( {}, '.' ); -my @filenames; -while ( my $r = $tree->next_obj ) -{ - my $fn = $r->path; - if ( $fn eq '.git' or $fn eq 'tests/individually-importing' ) - { - $tree->prune; - } - elsif ( $fn =~ /\.py\z/ and !exists( $skip{$fn} ) ) - { - push @filenames, $fn; - } -} - -my $cmd = shell_quote( 'flake8', @filenames ); - -# diag("<$cmd>"); - -# TEST -eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." ); - -__END__ - -=head1 COPYRIGHT AND LICENSE - -This file is part of Freecell Solver. It is subject to the license terms in -the COPYING.txt file found in the top-level directory of this distribution -and at http://fc-solve.shlomifish.org/docs/distro/COPYING.html . No part of -Freecell Solver, including this file, may be copied, modified, propagated, -or distributed except according to the terms contained in the COPYING file. - -Copyright (c) 2016 Shlomi Fish - -=cut -