12 / 12 lines covered (100.0%)
1unit module BDD::Behave::FailureStore;23our sub default-path(IO::Path :$base = $*CWD --> IO::Path) {4 $base.IO.add('.behave-failures');5}67our sub read-failures(IO::Path $path --> List) {8 return ().List unless $path.defined && $path.e;910 $path.slurp.lines.grep({ .chars && !.starts-with('#') }).List;11}1213our sub merge-failures(14 @existing,15 @ran-locations,16 @failure-locations,17 --> List18) {19 my %ran = @ran-locations.map: { $_ => True };20 my @result = @existing.grep({ !%ran{$_} });2122 @result.append: @failure-locations;2324 @result.unique.List;25}2627our sub write-failures(28 IO::Path $path,29 @ran-locations,30 @failure-locations,31) {32 my @existing = read-failures($path);33 my @final = merge-failures(@existing, @ran-locations, @failure-locations);3435 my $content = @final.elems ?? @final.join("\n") ~ "\n" !! '';3637 $path.spurt: $content;38}