### ----------------------------------------------------
### -- Test::Async
### -- Licenses: Artistic-2.0
### -- Authors: Vadim Belman <vrurg@cpan.org>
### -- File: t/040-skip.rakutest
### ----------------------------------------------------
use v6;
use Test::Async;

plan 7;

my @default-args = '-I' ~ $?FILE.IO.parent(2), '-MTest::Async';

is-run q:to/TEST-CODE/, "plan skip counted",
       plan 3;
       pass "test 1";
       skip "test 2";
       pass "test 3";
       TEST-CODE
   :compiler-args(@default-args),
   :exitcode(0),
   :err(""),
   :out(/^"1..3\nok 1 - test 1\nok 2 - # SKIP test 2\nok 3 - test 3\n"/);

is-run q:to/TEST-CODE/,
       plan 2, :skip-all("this suite won't run");
       pass "test 1"; pass "test 2";
       TEST-CODE
    "skip in plan",
    :compiler-args(@default-args),
    :exitcode(0),
    :err(""),
    :out(/^"1..0 # Skipped: this suite won't run\n"/);

is-run q:to/TEST-CODE/, "skip-remaining",
       plan 4;
       pass "test 1";
       skip-remaining "these are irrelevant now";
       pass "test 2";
       pass "test 3";
       subtest "a subtest" => { pass "subtest 1" }
       TEST-CODE
   :compiler-args(@default-args),
   :exitcode(0),
   :err(""),
   :out("1..4\nok 1 - test 1\n"
       ~ "ok 2 - # SKIP these are irrelevant now\n"
       ~ "ok 3 - # SKIP these are irrelevant now\n"
       ~ "ok 4 - # SKIP these are irrelevant now\n");

is-run q:to/TEST-CODE/, "skip-remaining without a message",
       plan 4;
       pass "test 1";
       skip-remaining;
       pass "test 2";
       pass "test 3";
       subtest "a subtest" => { pass "subtest 1" }
       TEST-CODE
    :compiler-args(@default-args),
    :exitcode(0),
    :err(""),
    :out("1..4\nok 1 - test 1\nok 2 - # SKIP \nok 3 - # SKIP \nok 4 - # SKIP \n");

is-run q:to/TEST-CODE/, "skip-rest",
       plan 4;
       pass "test 1";
       skip-rest "these are irrelevant now";
       TEST-CODE
   :compiler-args(@default-args),
   :exitcode(0),
   :err(""),
   :out("1..4\nok 1 - test 1\n"
        ~ "ok 2 - # SKIP these are irrelevant now\n"
        ~ "ok 3 - # SKIP these are irrelevant now\n"
        ~ "ok 4 - # SKIP these are irrelevant now\n");

is-run q:to/TEST-CODE/, "skip-rest without a message",
                     plan 4;
       pass "test 1";
       skip-rest;
       TEST-CODE
   :compiler-args(@default-args),
   :exitcode(0),
   :err(""),
   :out("1..4\nok 1 - test 1\nok 2 - # SKIP \nok 3 - # SKIP \nok 4 - # SKIP \n");

is-run q:to/TEST-CODE/, "no tests must follow skip-rest",
            plan 4;
            pass "test 1";
            skip-rest;
            pass "test 2";
            TEST-CODE
   :compiler-args(@default-args),
   :exitcode(255),
   :err(""),
   :out("1..4\nok 1 - test 1\nok 2 - # SKIP \nok 3 - # SKIP \nok 4 - # SKIP \n"
        ~ "ok 5 - test 2\n# You planned 4 tests, but ran 5\n");

done-testing;


