beyondgrep / ack2

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

Win32: ConfigFinder tests fail for ack-2.12 #419

Closed pdl closed 10 years ago

pdl commented 10 years ago

In ack-match.t, ack-o.t, config-finder.t, noenv.t, Cannot use string (a path name which is truncated) as a HASH ref while "strict refs in use at ... App/Ack/ConfigLoader.pm line 738.

Looks to me like it originates with line 68 of ConfigFinder:

push @uniq, $path unless $seen{$path}
hoelzro commented 10 years ago

@pdl Thanks for bringing this to our attention; we've seen some of these failures via CPAN testers. Are you seeing them in Git HEAD as well?

pdl commented 10 years ago

I'm seeing failures in the dev branch, certainly. There are also also other issues (hard to say how many until they're fixed, at least one more complication with config-finder.t, and some with coloured output).

I'm on strawberry perl 5.12.3, if it matters.

pdl commented 10 years ago

On this issue, I'm still getting...

t/config-finder.t ............ C:\Documents and Settings\All Users\Application D
ata\ackrc: No such file or directory at t/config-finder.t line 87
cannot remove path when cwd is C:/DOCUME~1/LOCALA~1/LOCALS~1/Temp/YZrgq0YL_y for
 C:\DOCUME~1\LOCALA~1\LOCALS~1\Temp\YZrgq0YL_y:  at C:/strawberry/perl/lib/File/
Temp.pm line 2445
# Looks like your test exited with 2 before it could output anything.
t/config-finder.t ............ Dubious, test returned 2 (wstat 512, 0x200)
Failed 26/26 subtests

Also possibly related:

    #   Failed test 'Get back a long list of arguments'
    #   at t/noenv.t line 60.
    #     Structures begin differing at:
    #          $got->[0]{project} = Does not exist
    #     $expected->[0]{project} = '1'
    # Looks like you failed 1 test of 1.

#   Failed test 'without --noenv'
t/noenv.t .................... 1/5 #   at t/noenv.t line 75.
mMontu commented 10 years ago

I'm facing problems to update Ack on Strawberry Perl Portable 5.14.2.1. I've also tried to install it on the latest Strawberry Perl Portable, but it also doesn't works.

This is how to reproduce it on a Window box:

This is what I got here:

t/ack-filetypes.t ............ ok

    #   Failed test 'Colorizing -g output with --color should work'
    #   at t/ack-g.t line 268.
    #     Structures begin differing at:
    #          $got->[0] = 't\context.t'
    #     $expected->[0] = 't/context.t'
    # Looks like you failed 1 test of 2.

#   Failed test 'test -g with --color'
#   at t/ack-g.t line 269.
# Looks like you failed 1 test of 18.
t/ack-g.t .................... 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/18 subtests 
    (less 1 skipped subtest: 16 okay)

,

#   Failed test at t/ack-match.t line 52.
#                   'Can't use string ("C:\ProgramData\ackrc") as a HASH ref while "strict refs" in use at D:\Portable\PORTAB~1\STRAWB~2.1\data\.cpanm\work\1386980749.6580\ack-2.12\blib\lib/App/Ack/ConfigLoader.pm line 738.'
#     doesn't match '(?^:--match is illegal in project ackrcs)'
# [
#   'Can\'t use string ("C:\\ProgramData\\ackrc") as a HASH ref while "strict refs" in use at D:\\Portable\\PORTAB~1\\STRAWB~2.1\\data\\.cpanm\\work\\1386980749.6580\\ack-2.12\\blib\\lib/App/Ack/ConfigLoader.pm line 738.'
# ]

#   Failed test at t/ack-match.t line 67.
# []

#   Failed test at t/ack-match.t line 68.
# [
#   'Can\'t use string ("C:\\ProgramData\\ackrc") as a HASH ref while "strict refs" in use at D:\\Portable\\PORTAB~1\\STRAWB~2.1\\data\\.cpanm\\work\\1386980749.6580\\ack-2.12\\blib\\lib/App/Ack/ConfigLoader.pm line 738.'
# ]

#   Failed test at t/ack-match.t line 83.
# []

#   Failed test at t/ack-match.t line 84.
# [
#   'Can\'t use string ("C:\\ProgramData\\ackrc") as a HASH ref while "strict refs" in use at D:\\Portable\\PORTAB~1\\STRAWB~2.1\\data\\.cpanm\\work\\1386980749.6580\\ack-2.12\\blib\\lib/App/Ack/ConfigLoader.pm line 738.'
# ]
# Looks like you failed 5 tests of 15.
t/ack-match.t ................ 
Dubious, test returned 5 (wstat 1280, 0x500)
Failed 5/15 subtests 
t/ack-n.t .................... ok
The system cannot find the path specified.
t/ack-named-pipes.t .......... skipped: You need the 'mkfifo' command to be able to run this test

#   Failed test at t/ack-o.t line 115.
#                   'Can't use string ("C:\ProgramData\ackrc") as a HASH ref while "strict refs" in use at D:\Portable\PORTAB~1\STRAWB~2.1\data\.cpanm\work\1386980749.6580\ack-2.12\blib\lib/App/Ack/ConfigLoader.pm line 738.'
#     doesn't match '(?^:--output is illegal in project ackrcs)'
# [
#   'Can\'t use string ("C:\\ProgramData\\ackrc") as a HASH ref while "strict refs" in use at D:\\Portable\\PORTAB~1\\STRAWB~2.1\\data\\.cpanm\\work\\1386980749.6580\\ack-2.12\\blib\\lib/App/Ack/ConfigLoader.pm line 738.'
# ]

#   Failed test at t/ack-o.t line 130.
# []

#   Failed test at t/ack-o.t line 131.
# [
#   'Can\'t use string ("C:\\ProgramData\\ackrc") as a HASH ref while "strict refs" in use at D:\\Portable\\PORTAB~1\\STRAWB~2.1\\data\\.cpanm\\work\\1386980749.6580\\ack-2.12\\blib\\lib/App/Ack/ConfigLoader.pm line 738.'
# ]

#   Failed test at t/ack-o.t line 146.
# []

#   Failed test at t/ack-o.t line 147.
# [
#   'Can\'t use string ("C:\\ProgramData\\ackrc") as a HASH ref while "strict refs" in use at D:\\Portable\\PORTAB~1\\STRAWB~2.1\\data\\.cpanm\\work\\1386980749.6580\\ack-2.12\\blib\\lib/App/Ack/ConfigLoader.pm line 738.'
# ]
# Looks like you failed 5 tests of 13.
t/ack-o.t .................... 
Dubious, test returned 5 (wstat 1280, 0x500)
Failed 5/13 subtests 
t/ack-pager.t ................ skipped: You need to install IO::Pty to run this test

,

Can't use string ("C:\ProgramData\ackrc") as a HASH ref while "strict refs" in use at t/config-finder.t line 89.
cannot remove path when cwd is C:/Users/user/AppData/Local/Temp/Z02wv5pjkj for C:/Users/user/AppData/Local/Temp/Z02wv5pjkj:  at D:/Portable/PortableApps/strawberry-perl-5.18.1.1/perl/lib/File/Temp.pm line 1615.
# Looks like your test exited with 2 before it could output anything.
t/config-finder.t ............ 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 26/26 subtests 

,

#   Failed test 'Basic highlights match'
#   at t/highlighting.t line 28.
#     Structures begin differing at:
#          $got->[0] = 't\text\science-of-myth.txt'
#     $expected->[0] = 't/text/science-of-myth.txt'

#   Failed test 'Metacharacters match'
#   at t/highlighting.t line 49.
#     Structures begin differing at:
#          $got->[0] = 't\text\4th-of-july.txt'
#     $expected->[0] = 't/text/4th-of-july.txt'

#   Failed test 'Context is all good'
#   at t/highlighting.t line 70.
#     Structures begin differing at:
#          $got->[0] = 't\text\4th-of-july.txt'
#     $expected->[0] = 't/text/4th-of-july.txt'
# Looks like you failed 3 tests of 6.
t/highlighting.t ............. 
Dubious, test returned 3 (wstat 768, 0x300)
Failed 3/6 subtests 

and

#   Failed test 'without --noenv'
#   at D:/Portable/PortableApps/strawberry-perl-5.18.1.1/perl/lib/Test/Builder.pm line 252.
cannot remove path when cwd is C:/Users/user/AppData/Local/Temp/jleowsC0Ah for C:/Users/user/AppData/Local/Temp/jleowsC0Ah:  at D:/Portable/PortableApps/strawberry-perl-5.18.1.1/perl/lib/File/Temp.pm line 1615.
# Looks like you planned 5 tests but ran 1.
# Looks like you failed 1 test of 1 run.
# Looks like your test exited with 2 just after 1.
t/noenv.t .................... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 5/5 subtests 
t/process-substitution.t ..... skipped: Test unreliable on Windows.
t/r-lang-ext.t ............... ok
t/resource-iterator.t ........ ok
t/zero.t ..................... ok

Test Summary Report
-------------------
t/ack-g.t                  (Wstat: 256 Tests: 18 Failed: 1)
  Failed test:  17
  Non-zero exit status: 1
t/ack-match.t              (Wstat: 1280 Tests: 15 Failed: 5)
  Failed tests:  11-15
  Non-zero exit status: 5
t/ack-o.t                  (Wstat: 1280 Tests: 13 Failed: 5)
  Failed tests:  9-13
  Non-zero exit status: 5
t/config-finder.t          (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 26 tests but ran 0.
t/highlighting.t           (Wstat: 768 Tests: 6 Failed: 3)
  Failed tests:  2, 4, 6
  Non-zero exit status: 3
t/noenv.t                  (Wstat: 512 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 5 tests but ran 1.
Files=86, Tests=871, 338 wallclock secs ( 1.00 usr +  0.28 sys =  1.28 CPU)
Result: FAIL
Failed 6/86 test programs. 15/871 subtests failed.
dmake.exe:  Error code 255, while making 'test_classic'

Is it possible to test from HEAD via cpanm?

pdl commented 10 years ago

Hm, ok, on 2.13_06 I'm getting a slew of new errors, and also one error on Cygwin.

On Strawberry, I think this is because File::Spec::Win32::tmpdir() picks the first available not the first writable directory (it is used to pick the locations of the file created by File::Temp->new). The first three options are from %ENV. Is there any way of laundering them?

On Cygwin, the error is:

t/config-finder.t ............ 1/26 Insecure dependency in unlink while running             with -T switch at t/config-finder.t line 64.
cannot remove path when cwd is /tmp/3EdrvGpplc/foo for /tmp/3EdrvGpplc:  at /usr            /lib/perl5/5.14/File/Temp.pm line 2445
# Looks like your test exited with 2 just after 26.
t/config-finder.t ............ Dubious, test returned 2 (wstat 512, 0x200)
petdance commented 10 years ago

Are you suggesting that I just undef %ENV?

pdl commented 10 years ago

No, in fact I'm wondering if either a) TMPDIR, TEMP and TMP in ENV can be untainted safely or b) when creating new temp files we can explicitly specify a location we know to be writable t/temp or something.

petdance commented 10 years ago

I don't think there's any way that we can know anything about any known good location, ever.

pdl commented 10 years ago

So in the absence of knowing, I think there are 2 options: a) let the test die on Win32; b) guess a writable directory (like t/temp). I prefer the latter - but is that something you're comfortable with?

thekyz commented 10 years ago

Is there a workaround for current version or should i install 2.10 ? Because as of now 2.12 cannot be made on windows due to that :(

petdance commented 10 years ago

You should definitely not install 2.10 because 2.00-2.11 have a huge security hole.

run4flat commented 10 years ago

I can confirm that the latest ack from git no longer suffers from this bug on Strawberry Perl 5.18. (I can't imagine the Perl version matters, though, as I located the buggy code in the older version and it was clearly reworked in the latest one in a perl-agnostic way.)

pdl commented 10 years ago

@run4flat I've just cloned dev and run on strawberry 5.18.2 and got

t/config-finder.t ............ 1/26 Insecure dependency in unlink while running
with -T switch at t/config-finder.t line 67.
cannot remove path when cwd is C:/temp/MNBE33EDmf/foo for C:/temp/MNBE33EDmf:  a
t C:/strawberry/perl/lib/File/Temp.pm line 1616.
# Looks like your test exited with 255 just after 26.

Did you definitely checkout ack2 and not ack?

pdl commented 10 years ago

Aha! Swap the last two lines and it passes all tests!

Pull request is at https://github.com/petdance/ack2/pull/463

pdl commented 10 years ago

463 was merged and I'm getting all tests passing on the current dev branch. Hopefully Win32 users can install cleanly with cpan from the next release onwards!