[go: up one dir, main page]

File: can_run.t

package info (click to toggle)
rex 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,800 kB
  • sloc: perl: 30,667; xml: 264; makefile: 8
file content (32 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use strict;
use warnings;

use Test::More tests => 4;

use Rex::Commands::Run;

{
  my $command_to_check = $^O =~ /^MSWin/ ? 'where' : 'which';
  my $result = can_run($command_to_check);
  ok( $result, 'Found checker command' );
}

{
  my $command_to_check = "I'm pretty sure this command doesn't exist anywhere";
  my $result           = can_run($command_to_check);
  ok( !$result, 'Non-existing command not found' );
}

{
  my @commands_to_check = $^O =~ /^MSWin/ ? 'where' : 'which';
  push @commands_to_check, 'non-existing command';
  my $result = can_run(@commands_to_check);
  ok( $result, 'Multiple commands - existing first' );
}

{
  my @commands_to_check = $^O =~ /^MSWin/ ? 'where' : 'which';
  unshift @commands_to_check, 'non-existing command';
  my $result = can_run(@commands_to_check);
  ok( $result, 'Multiple commands - non-existing first' );
}