examples/sync-commands.pl

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 6 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 81.1% 43 / 53 CC 1 SCAR 0.0
CC
1
Cov
83%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Discord/Client/Error.pm ↑ Summary examples/commands.pl »
1 #!/usr/bin/env perl
2 1 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Validate deployment settings before constructing the example client.
9 my $guild_id = $ENV{TEST_GUILD_ID}
10 1 ▶ or die "TEST_GUILD_ID is required for guild command deployment\n";
Branch: 1 branch
BranchTrueFalseTotal
my $guild_id = $ENV{"TEST_GUILD_ID"} or die "TEST_GUILD_ID is required for guild command deployment\n" 1 0 1
11  
12 # Load one example's declarations without starting its Gateway connection.
13 1 my ($example) = @ARGV;
14 1 ▶die "Usage: perl examples/sync-commands.pl EXAMPLE.pl\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV == 1 0 1 1
15 unless @ARGV == 1;
16 1 my $path = File::Spec->rel2abs($example);
17 1 ▶die "Example file does not exist\n" unless -f $path;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $path 0 1 1
18 1 my $bot = do $path;
19 1 ▶die "Could not load example\n"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($bot) and $bot->isa("Discord::Client") 0 1 1
Condition33%1/3
builtin::blessed($bot) and $bot->isa("Discord::Client")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($bot) and $bot->isa("Discord::Client")
builtin::blessed($bot) $bot->isa("Discord::Client")
Truth table33%1/3
A and B
A= builtin::blessed($bot)B= $bot->isa("Discord::Client")
ABresult
0X0
100
111
20 unless blessed($bot) && $bot->isa('Discord::Client');
21  
22 # Deployment replaces this application's commands in the selected test guild.
23 1 my $deployed = eval {
24 1 $bot->commands->sync( scope => { guild_id => $guild_id } )->get;
25 1 1;
26 };
27 1 my $deployment_error = $@;
28  
29 # Close SDK resources even when deployment fails, preserving the original error.
30 1 my $closed = eval {
31 1 $bot->close->get;
32 1 1;
33 };
34 1 my $close_error = $@;
35 1 ▶die $deployment_error unless $deployed;
Branch: 1 branch
BranchTrueFalseTotal
unless $deployed 0 1 1
36 1 ▶die $close_error unless $closed;
Branch: 1 branch
BranchTrueFalseTotal
unless $closed 0 1 1
« blib/lib/Discord/Client/Error.pm ↑ Summary examples/commands.pl »