Closed moritz closed 9 years ago
See the README for how to run the full tests. Do you have a suggestion of how to make this automatic for distributions?
You could skip the tests that need them if the mustache specs aren't found.
Fixed, thank you!
Issue is not fixed, I can reproduce now with a fresh rakudo and panda build. It does not fail with OS X homebrew version This is perl6 version 2015.03 built on MoarVM version 2015.03
.
Although the CATCH block is being called, the program still aborts. Here is a simplified test case:
my @files;
try {
@files = dir('NONEXISTENT-DIR', :test(rx{ '.json' $ })).sort;
note "After dir() call, which returned ", @files.perl;
CATCH {
@files = (); # Doesn't matter if this is here or not
note "Caught an error reading nonexistent dir.";
}
}
# This isn't reached
say "OK, files is ", @files.perl;
And result:
tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 (master %=)
[17:53:25] &4 $ perl6 --version
This is perl6 version 2015.04-112-gbcf3f1c built on MoarVM version 2015.04-24-g6ef0f8f
tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 (master %=)
[17:53:33] &4 $ perl6 t.pl6
Caught an error reading nonexistent dir.
Failed to get the directory contents of '/Users/tsmith/local/src/p6/panda/.panda-work/1430350453_1/NONEXISTENT-DIR': chdir failed: Unknown system error
in method dir at src/gen/m-CORE.setting:19003
in sub dir at src/gen/m-CORE.setting:19322
in block <unit> at t.pl6:3
tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 !127 (master %=)
[17:53:49] &4 $ /usr/local/bin/perl6 --version
This is perl6 version 2015.03 built on MoarVM version 2015.03
tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 (master %=)
[17:53:55] &4 $ /usr/local/bin/perl6 t.pl6
After dir() call, which returned Array.new(Failure.new(exception => X::IO::Dir.new(path => "/Users/tsmith/local/src/p6/panda/.panda-work/1430350453_1/NONEXISTENT-DIR", os-error => "chdir failed: Unknown system error")))
OK, files is Array.new(Failure.new(exception => X::IO::Dir.new(path => "/Users/tsmith/local/src/p6/panda/.panda-work/1430350453_1/NONEXISTENT-DIR", os-error => "chdir failed: Unknown system error")))
Putting a default { ... } block around the code inside the CATCH will fix it. This oversight was hidden by the fact that until recently, a 'try' didn't properly enforce 'use fatal', so your code would continue to run if it was a "soft" Failure, instead of an Exception.
As documented at http://design.perl6.org/S04.html#Exception_handlers , a CATCH is similar to a 'given' block, with the important difference that putting code directly in the block is not the same as having an actual default {}, because not "handling" the exception by an explicit when or default case will cause it to be rethrown. Hope that helps and makes sense. :)
Since dir() produces a Failure, you don't even need a try/catch, you can do something like this:
my @files = given dir('NONEXISTENT-DIR', :test(rx{ '.json' $ })) {
when Failure {
note "Caught an error reading nonexistent dir.";
();
}
default {
.sort;
}
};
Thank you, raydiak and moritz. Issue is actually fixed now, see a0bf17f.
A
panda install Task::Star
fails with