Skip to content

Commit d3230c9

Browse files
committed
Add :wipe named parameter in run-smth
As well as another helper method to avoid run-smth altogether. This allows heavy parallelization of things that need to use the same build at the same time. Quotable, Benchable and Project Blin can benefit from that. Note that if you use that you'll have to remove unpacked builds yourself (the location of them is returned by run-smth-build-path).
1 parent dc063f3 commit d3230c9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/Whateverable/Running.pm6

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ use Whateverable::Builds;
2727
unit module Whateverable::Running;
2828

2929
#↓ Unpacks a build, runs $code and cleans up.
30-
sub run-smth($full-commit-hash, Code $code, :$backend=rakudo-moar) is export {
31-
my $build-prepath = $CONFIG<builds-location>/$backend;
32-
my $build-path = $build-prepath/$full-commit-hash;
30+
sub run-smth($full-commit-hash, Code $code,
31+
:$backend=rakudo-moar, :$wipe = True) is export {
32+
my $build-path = run-smth-build-path $full-commit-hash, :$backend;
3333
my $archive-path = $CONFIG<archives-location>/$backend/$full-commit-hash.zst;
3434
my $archive-link = $CONFIG<archives-location>/$backend/$full-commit-hash;
3535

3636
# create all parent directories just in case
3737
# (may be needed for isolated /tmp)
38-
mkdir $build-prepath;
38+
mkdir $build-path.IO.parent;
3939

4040
# lock on the destination directory to make
4141
# sure that other bots will not get in our way.
@@ -61,10 +61,17 @@ sub run-smth($full-commit-hash, Code $code, :$backend=‘rakudo-moar’) is expo
6161
}
6262

6363
my $return = $code($build-path); # basically, we wrap around $code
64-
rmtree $build-path;
64+
rmtree $build-path if $wipe;
6565
$return
6666
}
6767

68+
#| Returns path to the unpacked build. This is useful if you want to
69+
#| use some build multiple times simultaneously (just pass that path
70+
#| to the code block).
71+
sub run-smth-build-path($full-commit-hash, :$backend=rakudo-moar) is export {
72+
$CONFIG<builds-location>/$backend/$full-commit-hash;
73+
}
74+
6875

6976
sub run-snippet($full-commit-hash, $file,
7077
:$backend=rakudo-moar,

0 commit comments

Comments
 (0)