Test

=title class Zef::Test
=subtitle A configurable implementation of the Tester interface

Synopsis

    use Zef;
    use Zef::Test;
    use Zef::Distribution::Local;
    # Setup with a single tester backend
    my $tester = Zef::Test.new(
        backends => [
            { module  => "Zef::Service::Shell::Test" },
        ],
    );
    # Assuming our current directory is a raku distribution...
    my $dist-to-test = Zef::Distribution::Local.new($*CWD);
    my $candidate    = Candidate.new(dist => $dist-to-test);
    my $logger       = Supplier.new andthen *.Supply.tap: -> $m { say $m.<message> }
    # ...test the distribution using the first available backend
    my $passed = so all $tester.test($candidate, :$logger);
    say $passed ?? "PASS" !! "FAIL";

Description

A Tester class that uses 1 or more other Tester instances as backends. It abstracts the logic to do 'test this path with the first backend that supports the given path'.

Methods

method test-matcher

method test-matcher($path --> Bool:D)

Returns True if any of the probeable self.plugins know how to test $path.

method test

method test(Candidate $candi, Str :@includes, Supplier :$logger, Int :$timeout --> Array[Bool])

Tests the files for $candi (usually locally extracted files from $candi.dist in the t/ directory with an extension of .rakutest .t6 or .t) using the provided @includes (e.g. /foo/bar or inst#/foo/bar. It will use the first matching backend, and will not attempt to use a different backend on failure (like e.g. Zef::Fetch) since failing test are not unexpected.

An optional :$logger can be supplied to receive events about what is occurring.

An optional :$timeout can be passed to denote the number of seconds after which we'll assume failure.

Returns an Array with some number of Bool (which depends on the backend used). If there are no False items in the returned Array then we assume success.

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.