Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v7.15 and / vs. \ troubles in Mojo::(File|Home) on MS Windows #1031

Closed
kmx opened this issue Jan 10, 2017 · 6 comments
Closed

v7.15 and / vs. \ troubles in Mojo::(File|Home) on MS Windows #1031

kmx opened this issue Jan 10, 2017 · 6 comments

Comments

@kmx
Copy link
Contributor

kmx commented Jan 10, 2017

  • Mojolicious version: 7.15+ latest master d69f603
  • Perl version: 5.22.2 (strawberry perl)
  • Operating system: MS Windows 10

Steps to reproduce the behavior

t/mojo/home.t + t/mojo/file.t fail during dmake test

Expected behavior

tests should pass

Actual behavior

The failure details:

t/mojo/file.t .............................. 1/?
#   Failed test 'right files'
#   at t/mojo/file.t line 115.
#     Structures begin differing at:
#          $got->[0] = 't\mojo\lib\Mojo/BaseTest/Base1.pm'
#     $expected->[0] = 't\mojo\lib\Mojo\BaseTest\Base1.pm'

#   Failed test 'right files'
#   at t/mojo/file.t line 119.
#     Structures begin differing at:
#          $got->[0] = 't\mojo\lib\Mojo/.hidden.txt'
#     $expected->[0] = 't\mojo\lib\Mojo\.hidden.txt'
# Looks like you failed 2 tests of 41.
t/mojo/file.t .............................. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/41 subtests
t/mojo/headers.t ........................... ok
t/mojo/home.t .............................. 1/?
#   Failed test 'right path detected'
#   at t/mojo/home.t line 24.
#     Structures begin differing at:
#          $got->[4] = 'My'
#     $expected->[4] = Does not exist

#   Failed test 'right path detected'
#   at t/mojo/home.t line 32.
#     Structures begin differing at:
#          $got->[4] = 'lib'
#     $expected->[4] = Does not exist

#   Failed test 'right path detected'
#   at t/mojo/home.t line 40.
#     Structures begin differing at:
#          $got->[4] = 'blib'
#     $expected->[4] = Does not exist

#   Failed test 'right path detected'
#   at t/mojo/home.t line 45.
#     Structures begin differing at:
#          $got->[0] = 'd:'
#     $expected->[0] = 'D:'
# Looks like you failed 4 tests of 8.
t/mojo/home.t .............................. Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/8 subtests

My analysis

The possible pacth is here https://github.com/kmx/mojo/commit/53636e85c7975c055e8af5c2d887110bcce9cf3b but in this case I am not 100% sure whether the chosen workarounds are the best ones.

There are basically 2 separate issues:

  1. troubles with Mojo::Home::detect (this one is important/serious)
  2. tweaks to properly handle mixture of / and \ in tests

Ad Mojo::Home::detect - the trouble is that on MS Windows the %INC might contain very strange things. Here is for example a fraction of what I see:

  "Mojolicious/Sessions.pm"               => "D:\\git\\mojo-fork\\blib\\lib/Mojolicious/Sessions.pm",
  "Mojolicious/Static.pm"                 => "D:\\git\\mojo-fork\\blib\\lib/Mojolicious/Static.pm",
  "Mojolicious/Types.pm"                  => "D:\\git\\mojo-fork\\blib\\lib/Mojolicious/Types.pm",
  "Mojolicious/Validator.pm"              => "D:\\git\\mojo-fork\\blib\\lib/Mojolicious/Validator.pm",
  "Mojolicious/Validator/Validation.pm"   => "D:\\git\\mojo-fork\\blib\\lib/Mojolicious/Validator/Validation.pm",
  "mro.pm"                                => "d:/strawberry32/perl/lib/mro.pm",
  "My/Class.pm"                           => bless(do{\(my $o = "D:\\git\\mojo-fork\\does_not_exist_3\\blib\\My\\Class.pm")}, "Mojo::File"),
  "Net/SSLeay.pm"                         => "d:/strawberry32/perl/site/lib/Net/SSLeay.pm",
  "overload.pm"                           => "d:/strawberry32/perl/lib/overload.pm",
  "overloading.pm"                        => "d:/strawberry32/perl/lib/overloading.pm",
  "parent.pm"                             => "d:/strawberry32/perl/site/lib/parent.pm",
  "PerlIO.pm"                             => "d:/strawberry32/perl/lib/PerlIO.pm",
  "Pod/Escapes.pm"                        => "d:/strawberry32/perl/lib/Pod/Escapes.pm",

here I am proposing forcefully replacing \ with / - see https://github.com/kmx/mojo/commit/53636e85c7975c055e8af5c2d887110bcce9cf3b#diff-52d3ad944c9afec616d8ccbcc2f1ce2eR15

The rest are mostly inconsistencies like getcwd returning:

d:\git\mojo-fork> perl -MCwd -E "say getcwd"
d:/git/mojo-fork

But rel2abs:

d:\git\mojo-fork> perl -MCwd -MFile::Spec::Functions=rel2abs -E "say rel2abs(getcwd)"
D:\git\mojo-fork

And $File::Find::name containing things like t\mojo\lib\Mojo/BaseTest/Base1.pm

And in some case I even got upper/lower case drive letter mismatch like D:\git\mojo-fork vs d:\git\mojo-fork.

Simply a big mess which I decided to "solve" by applying canonpath at several places (mostly in *.t files where it is IMHO not a big deal but also at 2 places in Mojo::File)

@kraih
Copy link
Member

kraih commented Jan 10, 2017

Wow, what a mess.

@kraih kraih closed this as completed in b4400a6 Jan 10, 2017
@kraih
Copy link
Member

kraih commented Jan 10, 2017

Thanks again for the analysis. No idea if that's the right fix, but at least it works for now and doesn't require API changes.

@kraih
Copy link
Member

kraih commented Jan 10, 2017

Honestly, i'm happy we can get away without losing too much performance. 😆

@kmx
Copy link
Contributor Author

kmx commented Jan 11, 2017

Hi,

it seems like you have forgotten to patch sub list_tree like this:

-  return Mojo::Collection->new(map { $self->new($_) } sort keys %files);
+  return Mojo::Collection->new(map { $self->new(canonpath($_)) } sort keys %files);

You have instead applied exactly the same change to sub list - which is IMO a good idea as well.

@kraih
Copy link
Member

kraih commented Jan 11, 2017

Looks like i mixed up list and list_tree. 😭

@kraih
Copy link
Member

kraih commented Jan 11, 2017

@kmx Does this regex work too? 76b4e30 From what i understand backslash and slash are only mixed up if the @INC part contains backslashes, while the package name part always contains slashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants