From c55613c79725ec89e80c0d85ed4eae6efa286692 Mon Sep 17 00:00:00 2001 From: Ed J Date: Mon, 16 Sep 2024 01:11:44 +0100 Subject: [PATCH] zap perltidy check --- MANIFEST | 4 -- README.md | 2 - cpanfile | 2 - t/0999_tidy.t | 35 ----------------- t/lib/PerlTidyCheck.pm | 87 ------------------------------------------ 5 files changed, 130 deletions(-) delete mode 100644 t/0999_tidy.t delete mode 100644 t/lib/PerlTidyCheck.pm diff --git a/MANIFEST b/MANIFEST index 283b3cb..9797ee6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2,8 +2,6 @@ Changes MANIFEST This list of files MANIFEST.SKIP -META.json Module JSON meta-data (added by MakeMaker) -META.yml Module YAML meta-data (added by MakeMaker) Makefile.PL Modern.xs README.md @@ -29,7 +27,5 @@ t/01_context.t t/02_auto_error_check.t t/02_glGetShaderInfoLog.t t/02_glew_version_accessors.t -t/0999_tidy.t -t/lib/PerlTidyCheck.pm typemap utils/generate-XS.pl diff --git a/README.md b/README.md index 108bdd0..3389c8c 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,6 @@ This module requires these other modules and libraries: ExtUtils::Constant => 0, ExtUtils::MakeMaker => 6.17, ExtUtils::MakeMaker::CPANfile => 0, - IO::All => 0, - Test::InDistDir => 0, Test::More => 0.88, not *required* but needed for currently unimplemented features: diff --git a/cpanfile b/cpanfile index 17f8e55..e09b103 100644 --- a/cpanfile +++ b/cpanfile @@ -13,6 +13,4 @@ on configure => sub { on test => sub { requires 'Test::More' => '0.88'; - requires 'IO::All' => '0.86'; - requires 'Test::InDistDir' => 0; }; diff --git a/t/0999_tidy.t b/t/0999_tidy.t deleted file mode 100644 index 5785fd8..0000000 --- a/t/0999_tidy.t +++ /dev/null @@ -1,35 +0,0 @@ -use strict; -use warnings; -use Test::InDistDir; -use Test::More 0.88; -use IO::All 0.86 -binary; -use lib "t/lib"; - -plan skip_all => "test requires Capture::Tiny and Perl::Tidy" - if !eval { require Capture::Tiny && require Perl::Tidy }; - -plan skip_all => "test skipped due to \$ENV{SKIP_TIDY_TESTS}" - if $ENV{SKIP_TIDY_TESTS}; - -run(); - -sub run { - note "set \$ENV{SKIP_TIDY_TESTS} to skip these"; - eval { report_untidied_files() }; - pass; - done_testing; -} - -sub report_untidied_files { - require PerlTidyCheck; - - return unless # - my @untidied = - PerlTidyCheck::find_untidied_files( sub { grep !/^signatures.*XS.*sig.*\.pl$|NameLists.*\.pm$/, @_ } ); - - my $report = join "", # - "found untidied files:", "\n\n", map( PerlTidyCheck::format_untidied_entry( $_ ), @untidied ), "\n"; - diag $report; - - return; -} diff --git a/t/lib/PerlTidyCheck.pm b/t/lib/PerlTidyCheck.pm deleted file mode 100644 index 895505c..0000000 --- a/t/lib/PerlTidyCheck.pm +++ /dev/null @@ -1,87 +0,0 @@ -package PerlTidyCheck; - -use strict; -use warnings; - -use IO::All -binary; -use Capture::Tiny 'capture_merged'; -use Perl::Tidy 'perltidy'; -use Test::More; - -sub format_untidied_entry { - my ( $untidied ) = @_; - - my ( $file, $diff ) = @{$untidied}; - $diff ||= ""; - - if ( $diff ) { - my @diff = split /\n/, $diff; - if ( @diff > 20 ) { - @diff = ( @diff[ 0 .. 19 ], "[... snip ...]\n" ); - $diff = join "\n", "", @diff; - } - $file = ( "-" x 78 ) . "\n$file:\n"; - $diff = $diff . ( "-" x 78 ) . "\n\n"; - } - - return "$file\n$diff"; -} - -sub find_untidied_files { - my ( $exclude_filter ) = @_; - my @perl = find_perl_files(); - @perl = $exclude_filter->( @perl ) if $exclude_filter; - my @untidied = map time_check( $_ ), @perl; - return @untidied; -} - -sub find_perl_files { grep !/\bblib\b/, grep /(^[^.]|\.(pl|PL|pm|t))$/, io( "." )->All_Files } - -sub time_check { - my ( $file ) = @_; - my $start = time; - my @res = check_tidy_status( $file ); - note sprintf "%s - $file", time - $start; - return @res; -} - -sub check_tidy_status { - my ( $file ) = @_; - - my $source = $file->all; - my $tidy = transform_source( $source ); - return if $source eq $tidy; - - return [ "$file", "" ] if !require Text::Diff; - - my $diff = Text::Diff::diff( \$source, \$tidy, { Style => 'Unified' } ); - return [ "$file", $diff ]; -} - -# from Code::TidyAll::Plugin::PerlTidy -sub transform_source { - my ( $source ) = @_; - - # perltidy reports errors in two different ways. - # Argument/profile errors are output and an error_flag is returned. - # Syntax errors are sent to errorfile or stderr, depending on the - # the setting of -se/-nse (aka --standard-error-output). These flags - # might be hidden in other bundles, e.g. -pbp. Be defensive and - # check both. - my ( $output, $error_flag, $errorfile, $stderr, $destination ); - $output = capture_merged { - $error_flag = perltidy( - source => \$source, - destination => \$destination, - stderr => \$stderr, - errorfile => \$errorfile - ); - }; - die $stderr if $stderr; - die $errorfile if $errorfile; - die $output if $error_flag; - print STDERR $output if defined $output; - return $destination; -} - -1;