beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 138 forks source link

test run_ack( '--match', 'Sue' ); fails on Windows, chokes on "stdout.log". #393

Closed ghost closed 4 years ago

ghost commented 10 years ago

On Windows (XP SP2, Strawberry 5.16.2, should not matter), t/ack-match.t failed for me with Out of memory error. This is because ack searches the stdout.log file as it is written into the build dir, during the 5th test: run_ack( '--match', 'Sue' );

This patch is a (silly) workaround, a better approach for a fix might be to tell the test instance of ack to ignore all/some .logfiles.

     --- Util.pm.original.ack-2.10  Tue Sep 24 23:35:58 2013
     +++ Util.pm    Thu Oct  3 11:33:44 2013
     @@ -178,8 +178,15 @@
          if ( is_windows() ) {
              require Win32::ShellQuote;
              # Capture stderr & stdout output into these files (only on Win32).
     -        my $catchout_file = 'stdout.log';
     -        my $catcherr_file = 'stderr.log';
     +
     +        # Put into parent of build dir, because build dir is searched by
     +        # ack tests.  Test 5 in ack-match.t:
     +        # run_ack( '--match', 'Sue' );
     +        # can fail with "Out of memory" or fill storage volume -
     +        # Test ack reads stdout.log, appending a message for every read line to
     +        # stdout.log, filling up both storage and memory.
     +        my $catchout_file = '../stdout.log';
     +        my $catcherr_file = '../stderr.log';

              open(SAVEOUT, ">&STDOUT") or die "Can't dup STDOUT: $!";
              open(SAVEERR, ">&STDERR") or die "Can't dup STDERR: $!";
     @@ -199,6 +206,8 @@
              close SAVEERR;
              @stdout = read_file($catchout_file);
              @stderr = read_file($catcherr_file);
     +        unlink $catchout_file;
     +        unlink $catcherr_file;
          }
          else {
              my ( $stdout_read, $stdout_write );
petdance commented 10 years ago

This is a bigger issue than just this test. I've run into this problem doing regular old searches with ack, where something like

ack blahblah > foo

will have ack searching the foo file for blahblah and looping infinitely over it.

petdance commented 7 years ago

Or maybe stdout.log should not get written into the current directory?