Cavil-CLI
view release on metacpan or search on metacpan
t/lib/CavilCliTest.pm view on Meta::CPAN
sub run_with_env ($self, $env, @argv) { return $self->_invoke(\@argv, undef, $env) }
# Run exactly the given arguments with no credentials in the environment, optionally feeding stdin (for the
# config command's prompts). Used to exercise resolution from the saved config file.
sub run_bare ($self, $argv, $stdin = undef) { return $self->_invoke($argv, $stdin) }
sub _invoke ($self, $argv, $stdin = undef, $env = {}) {
my $cli = $self->cli;
my ($out, $err, $code) = ('', '', undef);
my $run = sub {
local @ARGV = @$argv;
# A whole copy, so a CAVIL_URL or CAVIL_API_KEY in the real environment cannot reach the code under test.
local %ENV = (%ENV, XDG_CONFIG_HOME => $self->config_dir->to_string, NO_COLOR => 1);
delete @ENV{qw(CAVIL_URL CAVIL_API_KEY)};
@ENV{keys %$env} = values %$env;
$code = $cli->run;
};
{
open my $o, '>', \$out;
open my $e, '>', \$err;
( run in 1.304 second using v1.01-cache-2.11-cpan-364913b4093 )