]> git.donarmstrong.com Git - perltidy.git/commitdiff
setting -global core.autocrlf false
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 26 Jan 2022 15:34:49 +0000 (07:34 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 26 Jan 2022 15:34:49 +0000 (07:34 -0800)
.github/workflows/perltest.yml
t/testwide-passthrough.t
t/testwide-passthrough.t.skip [new file with mode: 0644]
t/testwide-tidy.t
t/testwide-tidy.t.skip [new file with mode: 0644]

index 83bebeb1d69c99e0b8ebb84f39819c5fd63fa398..2c67a88ab444f22a53eb2311eca52d84f93a1129 100644 (file)
@@ -50,6 +50,11 @@ jobs:
       # display the version of perl - just for possible manual verification
       - run: perl -V
 
+      # added to avoid problems with line ending conversions in git #83 update
+      - run: |
+          git config --global core.autocrlf false
+          git config --global core.eol lf
+
       # Instal the dependencies declared by the module ...
       # There are no deps for perltidy, but this would be the command:
       # - run: cpanm --installdeps .
index adcb5a858bcd5b8a7003faf8a9e3a61f5a11978d..71a8a2924a93635b654b2d3b58355bb1880f7394 100644 (file)
@@ -9,6 +9,8 @@ use Test::More;
 BEGIN { unshift @INC, "./" }
 use Perl::Tidy;
 
+# This is off pending a good resolution of the problem with line endings.
+
 # This tests the -eos (--encode-output-strings) which was added for issue
 # git #83 to fix an issue with tidyall.
 
@@ -16,6 +18,7 @@ use Perl::Tidy;
 # through perltidy should read/write identical contents (previously only
 # file test behaved correctly)
 
+# This attempted fix did not work:
 # The original version did hex compares of source and destination streams.  To
 # just test the -eos flag, and avoid line ending issues, this version does
 # line-by-line hex tests on chomped lines.
@@ -55,8 +58,7 @@ sub test_file2file {
     my $destination_hex = unpack( 'H*', $destination_str );
     note("Comparing contents:\n  $source_hex\n  $destination_hex\n");
 
-    #ok($source_hex eq $destination_hex, 'file content compare');
-    ok( hex_compare_by_lines( $source_str, $destination_str ) );
+    ok($source_hex eq $destination_hex, 'file content compare');
 }
 
 sub test_scalar2scalar {
@@ -78,9 +80,7 @@ sub test_scalar2scalar {
     my $destination_hex = unpack( 'H*', $destination );
 
     note("Comparing contents:\n  $source_hex\n  $destination_hex\n");
-    ##ok($source_hex eq $destination_hex, 'scalar content compare');
-    ok( hex_compare_by_lines( $source, $destination ),
-        'scalar content compare' );
+    ok($source_hex eq $destination_hex, 'scalar content compare');
 }
 
 sub test_scalararray2scalararray {
@@ -105,9 +105,7 @@ sub test_scalararray2scalararray {
     my $destination_hex = unpack( 'H*', $destination_str );
 
     note("Comparing contents:\n  $source_hex\n  $destination_hex\n");
-    ##ok($source_hex eq $destination_hex, 'scalararray content compare');
-    ok( hex_compare_by_lines( $source_str, $destination_str ),
-        'scalararray content compare' );
+    ok($source_hex eq $destination_hex, 'scalararray content compare');
 }
 
 sub slurp_raw {
diff --git a/t/testwide-passthrough.t.skip b/t/testwide-passthrough.t.skip
new file mode 100644 (file)
index 0000000..74e0d90
--- /dev/null
@@ -0,0 +1,160 @@
+use strict;
+use warnings;
+use utf8;
+
+use FindBin qw($Bin);
+use File::Temp qw(tempfile);
+use Test::More;
+
+BEGIN { unshift @INC, "./" }
+use Perl::Tidy;
+
+# This is off pending a good resolution of the problem with line endings.
+
+# This tests the -eos (--encode-output-strings) which was added for issue
+# git #83 to fix an issue with tidyall.
+
+# The test file has no tidying needs but is UTF-8 encoded, so all passes
+# through perltidy should read/write identical contents (previously only
+# file test behaved correctly)
+
+# This attempted fix did not work:
+# The original version did hex compares of source and destination streams.  To
+# just test the -eos flag, and avoid line ending issues, this version does
+# line-by-line hex tests on chomped lines.
+
+plan( tests => 6 );
+
+test_all();
+
+sub test_all {
+    my $test_file = "$Bin/testwide-passthrough.pl.src";
+    test_file2file($test_file);
+    test_scalar2scalar($test_file);
+    test_scalararray2scalararray($test_file);
+}
+
+sub test_file2file {
+    my $test_file = shift;
+
+    my $tmp_file = File::Temp->new( TMPDIR => 1 );
+
+    my $source      = $test_file;
+    my $destination = $tmp_file->filename();
+
+    note("Testing file2file: '$source' => '$destination'\n");
+
+    my $tidyresult = Perl::Tidy::perltidy(
+        argv        => '-utf8',
+        source      => $source,
+        destination => $destination
+    );
+    ok( !$tidyresult, 'perltidy' );
+
+    my $source_str      = slurp_raw($source);
+    my $destination_str = slurp_raw($destination);
+
+    my $source_hex      = unpack( 'H*', $source_str );
+    my $destination_hex = unpack( 'H*', $destination_str );
+    note("Comparing contents:\n  $source_hex\n  $destination_hex\n");
+
+    ok($source_hex eq $destination_hex, 'file content compare');
+
+    # This failed on Windows
+    ## ok( hex_compare_by_lines( $source_str, $destination_str ) );
+}
+
+sub test_scalar2scalar {
+    my $testfile = shift;
+
+    my $source = slurp_raw($testfile);
+    my $destination;
+
+    note("Testing scalar2scalar\n");
+
+    my $tidyresult = Perl::Tidy::perltidy(
+        argv        => '-utf8 -eos',
+        source      => \$source,
+        destination => \$destination
+    );
+    ok( !$tidyresult, 'perltidy' );
+
+    my $source_hex      = unpack( 'H*', $source );
+    my $destination_hex = unpack( 'H*', $destination );
+
+    note("Comparing contents:\n  $source_hex\n  $destination_hex\n");
+    ok($source_hex eq $destination_hex, 'scalar content compare');
+
+    # This failed on Windows:
+    ##ok( hex_compare_by_lines( $source, $destination ), 'scalar content compare' );
+}
+
+sub test_scalararray2scalararray {
+    my $testfile = shift;
+
+    my $source      = [ lines_raw($testfile) ];
+    my $destination = [];
+
+    note("Testing scalararray2scalararray\n");
+
+    my $tidyresult = Perl::Tidy::perltidy(
+        argv        => '-utf8 -eos',
+        source      => $source,
+        destination => $destination
+    );
+    ok( !$tidyresult, 'perltidy' );
+
+    my $source_str      = join( "", @$source );
+    my $destination_str = join( "", @$destination );
+
+    my $source_hex      = unpack( 'H*', $source_str );
+    my $destination_hex = unpack( 'H*', $destination_str );
+
+    note("Comparing contents:\n  $source_hex\n  $destination_hex\n");
+    ok($source_hex eq $destination_hex, 'scalararray content compare');
+
+    # This failed on Windows
+    ##ok( hex_compare_by_lines( $source_str, $destination_str ), 'scalararray content compare' );
+}
+
+sub slurp_raw {
+    my $filename = shift;
+
+    open( TMP, '<', $filename );
+    binmode( TMP, ':raw' );
+    local $/;
+    my $contents = <TMP>;
+    close(TMP);
+
+    return $contents;
+}
+
+sub lines_raw {
+    my $filename = shift;
+
+    open( TMP, '<', $filename );
+    binmode( TMP, ':raw' );
+    my @contents = <TMP>;
+    close(TMP);
+
+    return @contents;
+}
+
+sub hex_compare_by_lines {
+    my ( $source_str, $destination_str ) = @_;
+
+    my @source      = split /^/m, $source_str;
+    my @destination = split /^/m, $destination_str;
+
+    while (@source) {
+        my $ss = pop(@source);
+        my $dd = pop(@destination);
+        chomp $ss;
+        chomp $dd;
+        $ss = unpack( 'H*', $ss );
+        $dd = unpack( 'H*', $dd );
+        last if $ss ne $dd;
+    }
+    return !@source && !@destination;
+}
+
index 01b2d7391a84e8932772feb3a4d1c7a972b7314f..7bff3f91d4dbdd2c0ca32999f945bc5c0edec53e 100644 (file)
@@ -14,10 +14,6 @@ use Perl::Tidy;
 
 # The test file is UTF-8 encoded
 
-# The original version did hex compares of source and destination streams.  To
-# just test the -eos flag, and avoid line ending issues, this version does
-# line-by-line hex tests on chomped lines.
-
 plan( tests => 6 );
 
 test_all();
@@ -54,9 +50,8 @@ sub test_file2file {
     my $destination_hex = unpack( 'H*', $destination_str );
 
     note("Comparing contents:\n  $tidy_hex\n  $destination_hex\n");
-    ##ok($tidy_hex eq $destination_hex, 'file content compare');
-    ok( hex_compare_by_lines( $tidy_str, $destination_str ),
-        'file2file content compare' );
+    ok($tidy_hex eq $destination_hex, 'file content compare');
+
 }
 
 sub test_scalar2scalar {
@@ -79,9 +74,8 @@ sub test_scalar2scalar {
     my $destination_hex = unpack( 'H*', $destination );
 
     note("Comparing contents:\n  $tidy_hex\n  $destination_hex\n");
-    ##ok($tidy_hex eq $destination_hex, 'scalar content compare');
-    ok( hex_compare_by_lines( $tidy_str, $destination ),
-        'scalar2scalar content compare' );
+    ok($tidy_hex eq $destination_hex, 'scalar content compare');
+
 }
 
 sub test_scalararray2scalararray {
@@ -105,9 +99,7 @@ sub test_scalararray2scalararray {
     my $destination_hex = unpack( 'H*', $destination_str );
 
     note("Comparing contents:\n  $tidy_hex\n  $destination_hex\n");
-    ##ok($tidy_hex eq $destination_hex, 'scalararray content compare');
-    ok( hex_compare_by_lines( $tidy_str, $destination_str ),
-        'scalararray content compare' );
+    ok($tidy_hex eq $destination_hex, 'scalararray content compare');
 }
 
 sub slurp_raw {
diff --git a/t/testwide-tidy.t.skip b/t/testwide-tidy.t.skip
new file mode 100644 (file)
index 0000000..badc011
--- /dev/null
@@ -0,0 +1,156 @@
+use strict;
+use warnings;
+use utf8;
+
+use FindBin qw($Bin);
+use File::Temp qw(tempfile);
+use Test::More;
+
+BEGIN { unshift @INC, "./" }
+use Perl::Tidy;
+
+# This tests the -eos (--encode-output-strings) which was added for issue
+# git #83 to fix an issue with tidyall.
+
+# The test file is UTF-8 encoded
+
+# This attempted fix failed under Windows
+# The original version did hex compares of source and destination streams.  To
+# just test the -eos flag, and avoid line ending issues, this version does
+# line-by-line hex tests on chomped lines.
+
+plan( tests => 6 );
+
+test_all();
+
+sub test_all {
+    my $test_file = "$Bin/testwide-tidy.pl.src";
+    my $tidy_file = "$Bin/testwide-tidy.pl.srctdy";
+    my $tidy_str  = slurp_raw($tidy_file);
+    test_file2file( $test_file, $tidy_str );
+    test_scalar2scalar( $test_file, $tidy_str );
+    test_scalararray2scalararray( $test_file, $tidy_str );
+}
+
+sub test_file2file {
+    my $test_file = shift;
+    my $tidy_str  = shift;
+    my $tidy_hex  = unpack( 'H*', $tidy_str );
+
+    my $tmp_file = File::Temp->new( TMPDIR => 1 );
+
+    my $source      = $test_file;
+    my $destination = $tmp_file->filename();
+
+    note("Testing file2file: '$source' => '$destination'\n");
+
+    my $tidyresult = Perl::Tidy::perltidy(
+        argv        => '-utf8',
+        source      => $source,
+        destination => $destination
+    );
+    ok( !$tidyresult, 'perltidy' );
+
+    my $destination_str = slurp_raw($destination);
+    my $destination_hex = unpack( 'H*', $destination_str );
+
+    note("Comparing contents:\n  $tidy_hex\n  $destination_hex\n");
+    ok($tidy_hex eq $destination_hex, 'file content compare');
+
+    # This failed on Windows
+    ##ok( hex_compare_by_lines( $tidy_str, $destination_str ), 'file2file content compare' );
+}
+
+sub test_scalar2scalar {
+    my $test_file = shift;
+    my $tidy_str  = shift;
+    my $tidy_hex  = unpack( 'H*', $tidy_str );
+
+    my $source = slurp_raw($test_file);
+    my $destination;
+
+    note("Testing scalar2scalar\n");
+
+    my $tidyresult = Perl::Tidy::perltidy(
+        argv        => '-utf8 -eos',
+        source      => \$source,
+        destination => \$destination
+    );
+    ok( !$tidyresult, 'perltidy' );
+
+    my $destination_hex = unpack( 'H*', $destination );
+
+    note("Comparing contents:\n  $tidy_hex\n  $destination_hex\n");
+    ok($tidy_hex eq $destination_hex, 'scalar content compare');
+
+    # This failed on Windows
+    ## ok( hex_compare_by_lines( $tidy_str, $destination ), 'scalar2scalar content compare' );
+}
+
+sub test_scalararray2scalararray {
+    my $test_file = shift;
+    my $tidy_str  = shift;
+    my $tidy_hex  = unpack( 'H*', $tidy_str );
+
+    my $source      = [ lines_raw($test_file) ];
+    my $destination = [];
+
+    note("Testing scalararray2scalararray\n");
+
+    my $tidyresult = Perl::Tidy::perltidy(
+        argv        => '-utf8 -eos',
+        source      => $source,
+        destination => $destination
+    );
+    ok( !$tidyresult, 'perltidy' );
+
+    my $destination_str = join( '', @$destination );
+    my $destination_hex = unpack( 'H*', $destination_str );
+
+    note("Comparing contents:\n  $tidy_hex\n  $destination_hex\n");
+    ok($tidy_hex eq $destination_hex, 'scalararray content compare');
+
+    # This failed on Windows
+    ##ok( hex_compare_by_lines( $tidy_str, $destination_str ), 'scalararray content compare' );
+}
+
+sub slurp_raw {
+    my $filename = shift;
+
+    open( TMP, '<', $filename );
+    binmode( TMP, ':raw' );
+    local $/;
+    my $contents = <TMP>;
+    close(TMP);
+
+    return $contents;
+}
+
+sub lines_raw {
+    my $filename = shift;
+
+    open( TMP, '<', $filename );
+    binmode( TMP, ':raw' );
+    my @contents = <TMP>;
+    close(TMP);
+
+    return @contents;
+}
+
+sub hex_compare_by_lines {
+    my ( $source_str, $destination_str ) = @_;
+
+    my @source      = split /^/m, $source_str;
+    my @destination = split /^/m, $destination_str;
+
+    while (@source) {
+        my $ss = pop(@source);
+        my $dd = pop(@destination);
+        chomp $ss;
+        chomp $dd;
+        $ss = unpack( 'H*', $ss );
+        $dd = unpack( 'H*', $dd );
+        last if $ss ne $dd;
+    }
+    return !@source && !@destination;
+}