File: 05-all.rakutest

package info (click to toggle)
raku-file-which 1.0.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 156 kB
  • sloc: makefile: 4; sh: 2
file content (38 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (3)
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
33
34
35
36
37
38
use v6;

use Test;
use File::Which;

plan *;

my $test-bin = $*SPEC.catdir('t', 'corpus', $*DISTRO.is-win ?? 'test-bin-win' !! 'test-bin-unix');
ok $test-bin.IO.e, 'Found test-bin';
if $*DISTRO.is-win {
  %*ENV<PATH> ~= ";$test-bin";
} else {
  %*ENV<PATH> ~= ":$test-bin";
}

if $*KERNEL ~~ 'linux' {
  # On linux we need to have an execution bit.
  my $all = $*SPEC.catfile($test-bin, 'all');
  chmod 0o755, $all;
}

my @result = which('all');
like @result[0], rx/all/, 'Found all';
ok @result.defined, 'Found at least one result';

if $*KERNEL ~~ 'linux' {
  # On linux we need to have an execution bit.
  my $zero = $*SPEC.catfile($test-bin, '0');
  chmod 0o755, $zero;
}

my $zero = which '0';
ok $zero.defined, 'Zero is defined';

my $empty-string = which '';
is $empty-string, Any, 'Empty string';

done-testing;