<commit_before>use v6;
use lib 't/spec/packages';
use Test;
use Test::Util;
plan 3;

is_run 'use Test; plan 3; ok 1; ok 0; ok 1;', {
    :out("1..3\nok 1 - \nnot ok 2 - \nok 3 - \n"),
    :err(/:i 'failed' .+ 'line 1' .+ 'failed 1 test of 3'/),
    :1status,
}, 'test failures without PERL6_TEST_DIE_ON_FAIL set do not die';

is_run 'BEGIN %*ENV<PERL6_TEST_DIE_ON_FAIL> = 1;'
        ~ 'use Test; plan 3; ok 1; ok 0; ok 1;', {
    :out("1..3\nok 1 - \nnot ok 2 - \n"),
    :err(/:i
        'failed' .+ 'line 1' .+
        'Stopping test suite' .+ 'PERL6_TEST_DIE_ON_FAIL' .+
        'planned 3 tests, but ran 2' .+ 'failed 1 test of 2'
    /),
    :255status,
}, 'test failures with PERL6_TEST_DIE_ON_FAIL set die';

is_run 'BEGIN %*ENV<PERL6_TEST_DIE_ON_FAIL> = 1;'
        ~ 'use Test; plan 2; todo "foo"; ok 0; ok 0, "test-ok"', {
    :out(/'test-ok'/),
    :1status,
}, 'PERL6_TEST_DIE_ON_FAIL does not exit on failed TODO tests';


#      got status: 1
#      got out: "1..2\nnot ok 1 - # TODO foo\n\n# Failed test at getout-21997-614887.code line 1\n# expected: '72'\n#      got: '42'\nnot ok 2 - test-ok\n"
# expected out: "1..3\nok 1 - \nnot ok 2 - \n"
#      got err: "\n# Failed test 'test-ok'\n# at getout-21997-614887.code line 1\n# expected: '72'\n#      got: '42'\n# Test failed. Stopping test suite, because PERL6_TEST_DIE_ON_FAIL environmental variable is set to a true value.\n# Looks like you failed 1 test of 2\n"


# vim: expandtab shiftwidth=4 ft=perl6<commit_msg>test failure diagnostics must show up when PERL6_TEST_DIE_ON_FAIL is used<commit_after>use v6;
use lib 't/spec/packages';
use Test;
use Test::Util;
plan 4;

is_run 'use Test; plan 3; ok 1; ok 0; ok 1;', {
    :out("1..3\nok 1 - \nnot ok 2 - \nok 3 - \n"),
    :err(/:i 'failed' .+ 'line 1' .+ 'failed 1 test of 3'/),
    :1status,
}, 'test failures without PERL6_TEST_DIE_ON_FAIL set do not die';

is_run 'BEGIN %*ENV<PERL6_TEST_DIE_ON_FAIL> = 1;'
        ~ 'use Test; plan 3; ok 1; ok 0; ok 1;', {
    :out("1..3\nok 1 - \nnot ok 2 - \n"),
    :err(/:i
        'failed' .+ 'line 1' .+
        'Stopping test suite' .+ 'PERL6_TEST_DIE_ON_FAIL' .+
        'planned 3 tests, but ran 2' .+ 'failed 1 test of 2'
    /),
    :255status,
}, 'test failures with PERL6_TEST_DIE_ON_FAIL set die';

is_run 'BEGIN %*ENV<PERL6_TEST_DIE_ON_FAIL> = 1;'
        ~ 'use Test; plan 2; todo "foo"; ok 0; ok 0, "test-ok"', {
    :out(/'test-ok'/),
    :1status,
}, 'PERL6_TEST_DIE_ON_FAIL does not exit on failed TODO tests';

# RT #129192
is_run 'BEGIN %*ENV<PERL6_TEST_DIE_ON_FAIL> = 1;'
        ~ 'use Test; plan 1; is "x", "test-ok"', {
    :err(/'test-ok'/),
    :1status,
}, 'test failure diagnostics show up when PERL6_TEST_DIE_ON_FAIL is used';

# vim: expandtab shiftwidth=4 ft=perl6
{'fraction_non_alphanumeric': 0.16642494561276286, 'fraction_numerical': 0.05293691080493111, 'mean_word_length': 2.8426183844011144, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5972428', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1145, 'n_words': 346}