Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add support for custom scripts
So that users can bisect arbitrary code. The code can depend on
modules, in which case these have to be listed on the command line
(e.g. for a script depending on WWW you should list WWW module,
dependencies will be detected automatically).

Using this ticket as an example: rakudo/rakudo#2779

Create file foo.p6 with this content:

    use WWW;
    my @StationS;
    @StationS = | jpost "https://www.perl6.org", :limit(42);

Then run Blin:

    ./bin/blin.p6 --old=2018.12 --new=HEAD --custom-script=foo.p6 WWW

Then check out the output folder to see the results.

Resolves #11.
  • Loading branch information
AlexDaniel committed Mar 25, 2019
1 parent 80417a8 commit 6da7c3c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
21 changes: 20 additions & 1 deletion bin/blin.p6
Expand Up @@ -25,6 +25,8 @@ unit sub MAIN(
# now-failing modules.
#| Number of seconds between printing the current status (default: 60.0)
Rat :$heartbeat = 60.0,
#| Additional scripts to be tested
:$custom-script, # XXX Oh sausages! https://github.com/rakudo/rakudo/issues/2797
#| Use this to test some specific modules (empty = whole ecosystem)
*@specified-modules,
);
Expand Down Expand Up @@ -205,6 +207,21 @@ note β€˜πŸ₯žπŸ₯ž Sorting modules’;
.value = .value.sort(*.version).eager for %lookup;


if $custom-script {
note β€˜πŸ₯žπŸ₯ž Generating fake modules for custom scripts’;
for $custom-script.list -> IO() $script {
die β€œScript β€œ$script” does not exist” unless $script.e;
my Module $module .= new:
name => ~$script,
version => v1234567890, # sue me
depends => @specified-modules.Set, # depend on everything specified on the command line
test-script => $script,
;
@modules.push: $module;
%lookup{$module.name}.push: $module;
}
}

note β€˜πŸ₯žπŸ₯ž Resolving dependencies’;
for @modules -> $module {
sub resolve-dep($depstr) {
Expand All @@ -231,7 +248,9 @@ for @modules -> $module {
note β€˜πŸ₯žπŸ₯ž Marking latest versions and their deps’;
for %lookup {
next unless .key eq .valueΒ».name.any; # proceed only if not an alias
next if @specified-modules and not .key eq @specified-modules.any;
if @specified-modules or $custom-script {
next if not .key eq @specified-modules.any | $custom-script.any;
}
.value.tail.needify
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Blin/Module.pm6
Expand Up @@ -11,6 +11,8 @@ has Bool $.visited;
has Promise $.done = Promise.new;
has Str $.output-old;
has Str $.output-new;
#| Something to run when testing this β€œmodule”
has IO $.test-script;

method handle {
# TODO surely we can do better to ensure it won't clash
Expand Down
31 changes: 20 additions & 11 deletions lib/Blin/Processing.pm6
Expand Up @@ -374,17 +374,26 @@ sub test-module($full-commit-hash, $module,
return %(output => β€˜Commit exists, but a perl6 executable could not be built for it’,
exit-code => -1, signal => -1, time => -1,)
}
my $result = get-output $binary-path,
β€˜--’,
$zef-path.add(β€˜/bin/zef’),
β€œ--config-path=$zef-config-path”,
<--verbose --force-build --force-install>,
($testable ?? β€˜--force-test’ !! β€˜--/test’),
<--/depends --/test-depends --/build-depends>,
β€˜install’,
($install ?? Empty !! β€˜--dry’),
β€œ--to=inst#$install-path”, $module.name,
:stdin(β€˜β€™), :$timeout, ENV => %tweaked-env, :!chomp;

my $result;
if $module.test-script { # fake module
$result = get-output $binary-path,
β€˜--’,
$module.test-script,
:stdin(β€˜β€™), :$timeout, ENV => %tweaked-env, :!chomp;
} else { # normal module
$result = get-output $binary-path,
β€˜--’,
$zef-path.add(β€˜/bin/zef’),
β€œ--config-path=$zef-config-path”,
<--verbose --force-build --force-install>,
($testable ?? β€˜--force-test’ !! β€˜--/test’),
<--/depends --/test-depends --/build-depends>,
β€˜install’,
($install ?? Empty !! β€˜--dry’),
β€œ--to=inst#$install-path”, $module.name,
:stdin(β€˜β€™), :$timeout, ENV => %tweaked-env, :!chomp;
}
# XXX ↓ this workaround looks stupid
$result<exit-code> = 1 if $result<output>.contains: β€˜[FAIL]:’;
$result
Expand Down

0 comments on commit 6da7c3c

Please sign in to comment.