Yes - I had started off by checking most of those things. (That was how line 71 became line 76 ;-)
Everything looked fine, except that $cleaned was not defined.
It was actually quite some time before I looked at the test script itself and noticed the $^O override.

File/Spec.pm contains very little code - and it certainly seems to be inviting this override that t/01-basic.t uses.
So I decided to investigate some basic behaviour of File::Spec, without any reference to Path::Class. I used this script:
# fake_os.pl BEGIN { $^O = 'Unix'; } use strict; use warnings; use File::Spec; my $x = File::Spec->catfile('a', 'b', 'c'); print $x;
I find that on both perl-5.32 and 5.34, this script outputs 'a/b/c' as expected.
If I comment out the BEGIN block, then the script outputs 'a\b\c' as expected - on both perl-5.32 and perl-5.34. What is odd is that if I simply load Test::Harness, then on both perl-5.32 and 5.34 I always get 'a\b\c' even when the BEGIN block is included:
C:\_32\pscrpt\file-spec>perl fake_os.pl a/b/c C:\_32\pscrpt\file-spec>perl -MTest::Harness fake_os.pl a\b\c
I think that demonstrates that there might be some fragility around overriding $^O, though it doesn't really explain much about the behaviour of t/01-basic.t.

I think it's a pity that File::Spec invites users to mess with the path formatting by fiddling with $^O.
Surely it would be better if there was a function to call or an environment variable to set ... or something else that doesn't involve fiddling with $^O.

I think I might just file bug reports against both perl (based on the demo of the Test::Harness interference) and Path::Class ... and see where it all ends up.

I've just tried my fake_os.pl on Ubuntu with $^O = 'Win32'; and it just ignores that and gives the Unix style 'a/b/c' (on both perl-5.32 and 5.36).(I think that's intended behaviour.)
I totally buggered that up. I can get Win32 path formatting with fake_os.pl on Ubuntu if I specify $^O = 'MSWin32' .
Again, it doesn't work if the Test::Harness is loaded.
I think I'm just fiddling about with a heap of rubbish ...

Update: Forgot to mention that I did hack File::Spec on Windows perl-5.34 such that 'Unix' was hard coded in, and $^O didn't need to be altered. In that case the t/01-basic.t script ran fine and passed all tests.
To me, that shows that the problem with t/01-basic.t is not that 'Unix' formatting is being selected - it's because $^O is being messed with.
I'll post again with links to relevant bug reports once they have been filed.
Thanks for the interest that has been shown.

Cheers,
Rob

In reply to Re^2: Is it ever legitimate to override $^O ? -- Cwd and File::Spec by syphilis
in thread Is it ever legitimate to override $^O ? by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.