Subject: | Tests cannot be executed in parallel |
When running with HARNESS_OPTIONS=j5, or "prove -j5 ...", tests randomly fail because scratch files and directories are shared across tests. Instead, File::Temp can be used to use a unique scratch directory for every test.
e.g.:
Building and testing File-ShareDir-Install-0.10
cp lib/File/ShareDir/Install.pm blib/lib/File/ShareDir/Install.pm
Manifying 1 pod document
PERL_DL_NONLAZY=1 "/Volumes/amaretto/Users/ether/perl5/perlbrew/perls/8.9/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_pod.t ........... skipped: these tests are for authors only
t/02_pod_coverage.t .. skipped: these tests are for authors only
t/00_compile.t ....... ok
rename MakeMaker.tmp => test-18291-Makefile: No such file or directory at /Volumes/amaretto/Users/ether/.perlbrew/libs/8.9@std/lib/perl5/ExtUtils/MakeMaker.pm line 1188.
# Failed test 'Created test-18291-Makefile'
# at t/11_dotfile.t line 54.
Can't open test-18291-Makefile: No such file or directory at t/11_dotfile.t line 49.
Use of uninitialized value in pattern match (m//) at t/11_dotfile.t line 56.
# Failed test 'Shared a dotfile'
# at t/11_dotfile.t line 56.
Use of uninitialized value in pattern match (m//) at t/11_dotfile.t line 57.
Use of uninitialized value in pattern match (m//) at t/11_dotfile.t line 59.
Use of uninitialized value in pattern match (m//) at t/11_dotfile.t line 60.
Error running make -f test-18291-Makefile: ?=512 ret=make[1]: test-18291-Makefile: No such file or directory
make[1]: *** No rule to make target `test-18291-Makefile'. Stop.
# Looks like you planned 9 tests but ran 5.
# Looks like you failed 2 tests of 5 run.
# Looks like your test exited with 2 just after 5.
t/11_dotfile.t .......
Dubious, test returned 2 (wstat 512, 0x200)
Failed 6/9 subtests
# Failed test 'Don't share dot files'
# at t/10_makefile.t line 58.
t/12_delete.t ........ ok
# Looks like you failed 1 test of 16.
t/10_makefile.t ......
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/16 subtests
Test Summary Report
-------------------
t/11_dotfile.t (Wstat: 512 Tests: 5 Failed: 2)
Failed tests: 1-2
Non-zero exit status: 2
Parse errors: Bad plan. You planned 9 tests but ran 5.
t/10_makefile.t (Wstat: 256 Tests: 16 Failed: 1)
Failed test: 6
Non-zero exit status: 1
Files=6, Tests=29, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.82 cusr 0.22 csys = 1.08 CPU)
Result: FAIL
Failed 2/6 test programs. 3/29 subtests failed.
make: *** [test_dynamic] Error 1