1use strict;
2use Test::More;
3use xt::CLI;
4
5subtest 'carton install --cpanfile' => sub {
6    my $app = cli();
7    $app->write_file('cpanfile.foo', <<EOF);
8requires 'Try::Tiny', '== 0.11';
9EOF
10    $app->run("install", "--cpanfile", "cpanfile.foo");
11    $app->run("check", "--cpanfile", "cpanfile.foo");
12
13    ok !$app->dir->child('cpanfile.snapshot')->exists;
14    ok $app->dir->child('cpanfile.foo.snapshot')->exists;
15
16    like $app->stdout, qr/are satisfied/;
17
18    local $ENV{PERL_CARTON_CPANFILE} = $app->dir->child('cpanfile.foo')->absolute;
19
20    $app->run("list");
21    like $app->stdout, qr/Try-Tiny-0\.11/;
22
23    $app->run("exec", "perl", "-e", "use Try::Tiny\ 1");
24    like $app->stderr, qr/Try::Tiny .* 0\.11/;
25};
26
27subtest 'PERL_CARTON_CPANFILE' => sub {
28    my $app = cli();
29
30    local $ENV{PERL_CARTON_CPANFILE} = $app->dir->child('cpanfile.foo')->absolute;
31
32    $app->write_file('cpanfile.foo', <<EOF);
33requires 'Try::Tiny', '== 0.11';
34EOF
35
36    $app->run("install");
37    $app->run("list");
38
39    like $app->stdout, qr/Try-Tiny-0\.11/;
40    ok $app->dir->child('cpanfile.foo.snapshot')->exists;
41};
42
43done_testing;
44
45