Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Last active December 4, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j1n3l0/10fb2140409d0e648cf85409985c41ab to your computer and use it in GitHub Desktop.
Save j1n3l0/10fb2140409d0e648cf85409985c41ab to your computer and use it in GitHub Desktop.
yath vs prove (on Mac OS)
use Test2::V0;
use File::Temp;
use Redis;
use Test::RedisServer;
my $test_server = Test::RedisServer->new(
tmpdir => File::Temp->newdir( CLEANUP => 1, DIR => '.' ),
conf => { port => 9000 },
) || bail_out('Failed to start test redis server');
subtest 'Redis' => sub {
ok( lives { Redis->new( $test_server->connect_info ) },
'should instantiate a new instance',
) || diag $@;
};
done_testing();
=head1 QUESTION
On a Mac, why does the above test pass under C<prove> but not under C<yath>?
bash-3.2$ yath test
( STDERR ) job 1 Path length (107) is longer than maximum supported length (104) and will be truncated at /Users/nonyiah/.plenv/versions/5.32.0/lib/perl5/5.32.0/darwin-2level/Socket.pm line 872.
[ FAIL ] job 1 +~Redis
[ FAIL ] job 1 + should instantiate a new instance
( DIAG ) job 1 | Failed test 'should instantiate a new instance'
( DIAG ) job 1 | at t/00-basic.t line 7.
( DIAG ) job 1 | Could not connect to Redis server at /private/var/folders/_w/q9blb5897bz8510mt67v55180000gn/T/yath-83688-1HyUfm/tmp/KFRqzT/AVWNivZCQm/redis.sock: No such file or directory at t/00-basic.t line 6.
job 1 ^
( DIAG ) job 1 Failed test 'Redis'
( DIAG ) job 1 at t/00-basic.t line 9.
( DIAG ) job 1 Seeded srand with seed '20201113' from local date.
( FAILED ) job 1 t/00-basic.t
< REASON > job 1 Test script returned error (Err: 1)
< REASON > job 1 Assertion failures were encountered (Count: 1)
< REASON > job 1 Subtest failures were encountered (Count: 1)
The following jobs failed:
+--------------------------------------+--------------+
| Job ID | Test File |
+--------------------------------------+--------------+
| A8E805E0-25DF-11EB-B086-7E3F55DB4F54 | t/00-basic.t |
+--------------------------------------+--------------+
Yath Result Summary
-----------------------------------------------------------------------------------
Fail Count: 1
File Count: 1
Assertion Count: 2
Wall Time: 0.74 seconds
CPU Time: 0.94 seconds (usr: 0.24s | sys: 0.05s | cusr: 0.52s | csys: 0.13s)
CPU Usage: 127%
--> Result: FAILED <--
bash-3.2$ prove t/00-basic.t
t/00-basic.t .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.15 cusr 0.05 csys = 0.24 CPU)
Result: PASS
=head1 ANSWER
The problem appears to be the path of the MacOS C<tmp> directory. If we set it to something shorter it works
I<(though I do not yet know why we have to set the C<port> or why C<prove> does not have this problem)>.
=cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment