Alien-Xmake

 view release on metacpan or  search on metacpan

t/01_build_cpp.t  view on Meta::CPAN

use v5.40;
use blib;
use Test2::V0 -no_srand => 1;
use File::Temp    qw[tempdir];
use Capture::Tiny qw[capture];
my $dir = tempdir();
#
use Alien::Xmake;
#
my $xmake = Alien::Xmake->new;
{
    my $exe = $xmake->exe;
    diag qx[$exe g --theme=plain] if $ENV{AUTOMATED_TESTING};
    chdir $dir;
    my ( $stdout, $stderr, $exit ) = capture { system $exe, qw[create --quiet --project=test_cpp --language=c++ --template=console] };
    ok( ( -d 'test_cpp' ), 'project created' );

    #~ ok !$exit, 'project created';
    diag $stdout if $exit && length $stdout;
    diag $stderr if $exit && length $stderr;
    chdir 'test_cpp';
    subtest compile => sub {
        my $todo = todo 'Require a working compiler';    # outside the scope of Alien::Xmake
        diag 'Building project..';
        ( $stdout, $stderr, $exit ) = capture { system $exe, '--quiet' };
        ok !$exit, 'project built';
        diag $stdout if $exit && length $stdout;
        diag $stderr if $exit && length $stderr;
        ( $stdout, $stderr, $exit ) = capture { system $exe, 'run' };
        ok $stdout =~ /hello world!/, 'project says hello';
        diag $stdout if $exit && length $stdout;
        diag $stderr if $exit && length $stderr;
    }
}
#
done_testing;



( run in 0.708 second using v1.01-cache-2.11-cpan-39bf76dae61 )