File: 04-simple.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 (36 lines) | stat: -rw-r--r-- 1,045 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
use v6;

use Test;
use File::Which;

plan *;

is which(''), Any, 'Null-length false result';

is which('non_existent_very_unlinkely_thingy_executable'), Any, 'Positive length false result';

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";
}
unless (File::Which::MacOSX || File::Which::Win32) {
  my $test3 = $*SPEC.catfile($test-bin, 'test3');
  chmod 0o755, $test3;
}

if $*KERNEL ~~ 'linux' {
  is which('test3'), $*SPEC.catfile($test-bin, 'test3'), 'Check test3 for Unix';
}

if $*DISTRO.is-win {
  is which('test1').lc, $*SPEC.catfile($test-bin, "test1.exe"), 'Looking for test1.exe';
  is which('test2').lc, $*SPEC.catfile($test-bin, "test2.bat"), 'Looking for test2.bat';
  is which('test3'), Any, 'test3 returns Any';
  chdir($test-bin);
  is which('test1').lc, $*SPEC.catfile($*SPEC.curdir, 'test1.exe'), 'Looking for test1.exe in curdir';
}

done-testing;