1use strict; 2use Test::More; 3use xt::CLI; 4 5subtest 'carton check fails when there is no lock' => sub { 6 my $app = cli(); 7 $app->write_cpanfile(<<EOF); 8requires 'Try::Tiny', '== 0.11'; 9EOF 10 11 $app->run("check"); 12 like $app->stderr, qr/find cpanfile\.snapshot/; 13}; 14 15subtest 'carton install and check' => sub { 16 my $app = cli(); 17 $app->write_cpanfile(<<EOF); 18requires 'Try::Tiny', '== 0.11'; 19EOF 20 21 $app->run("install"); 22 23 $app->run("check"); 24 like $app->stdout, qr/are satisfied/; 25 26 $app->run("list"); 27 like $app->stdout, qr/Try-Tiny-0\.11/; 28 29 $app->write_cpanfile(<<EOF); 30requires 'Try::Tiny', '0.16'; 31EOF 32 33 $app->run("check"); 34 like $app->stdout, qr/not satisfied/; 35 36 TODO: { 37 local $TODO = 'exec does not verify lock'; 38 $app->run("exec", "perl", "use Try::Tiny"); 39 like $app->stderr, qr/\.snapshot/; 40 } 41 42 $app->run("install"); 43 44 $app->run("check"); 45 like $app->stdout, qr/are satisfied/; 46 47 $app->run("list"); 48 like $app->stdout, qr/Try-Tiny-0\.\d\d/; 49 50 $app->write_cpanfile(<<EOF); 51requires 'Try::Tiny', '10.00'; 52EOF 53 54 $app->run("check"); 55 like $app->stdout, qr/not satisfied/; 56 57 $app->run("install"); 58 like $app->stderr, qr/failed/; 59 60 $app->run("check"); 61 like $app->stdout, qr/not satisfied/; 62}; 63 64subtest 'detect unused modules' => sub { 65 my $app = cli; 66 $app->write_cpanfile("requires 'Try::Tiny';"); 67 68 $app->run("install"); 69 $app->write_cpanfile(""); 70 71 72 TODO: { 73 local $TODO = "Can't detect superflous modules"; 74 $app->run("install"); 75 $app->run("list"); 76 is $app->stdout, ""; 77 78 $app->run("check"); 79 like $app->stdout, qr/unused/; 80 } 81}; 82 83subtest 'detect downgrade' => sub { 84 my $app = cli; 85 $app->write_cpanfile("requires 'URI';"); 86 $app->run("install"); 87 88 $app->write_cpanfile("requires 'URI', '== 1.59';"); 89 $app->run("check"); 90 91 like $app->stdout, qr/not satisfied/; 92 like $app->stdout, qr/URI has version .* Needs == 1\.59/; 93}; 94 95done_testing; 96 97