Skip to content

Commit a29ac07

Browse files
committed
Test lib/Test-Files
Part of #1751
1 parent 96ece3f commit a29ac07

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

xt/lib-test-files.raku

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env raku
2+
3+
use Test;
4+
use lib $*PROGRAM.parent(2).child('lib');
5+
use Test-Files;
6+
7+
=begin overview
8+
9+
Exercise Test-Files command line
10+
11+
=end overview
12+
13+
say Test-Files.files().join(',');
14+
say '---';
15+
say Test-Files.pods().join(',');
16+
say '---';
17+
say Test-Files.documents().join(',');
18+
say '---';
19+
say Test-Files.tests().join(',');
20+
say '---';

xt/lib-test-files.t

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env raku
2+
3+
use Test;
4+
use lib $*PROGRAM.parent(2).child('lib');
5+
6+
=begin overview
7+
8+
Test the Test-Files module
9+
10+
=end overview
11+
12+
plan 25;
13+
use-ok 'Test-Files';
14+
15+
use Test-Files;
16+
17+
# We could ourselves be running with TEST_FILES set - ignore it for now...
18+
%*ENV<TEST_FILES>='';
19+
20+
my @files = Test-Files.files();
21+
ok @files.elems > 1, '.files returns something array-like with at least one item';
22+
ok all(@files.map(*.IO.f)), 'all files returned exist';
23+
24+
my @pods = Test-Files.pods();
25+
ok @pods.elems > 1, '.pods returns something array-like with at least one item';
26+
ok all(@pods>>.ends-with('.pod6')), 'all files returned are pod files';
27+
ok all(@pods.map(*.IO.f)), 'all files returned exist';
28+
29+
my @docs = Test-Files.documents();
30+
ok @docs.elems > 1, '.documents returns something array-like with at least one item';
31+
ok all(@docs>>.ends-with('.pod6'|'.md')), 'all files returned are pod/md files';
32+
ok all(@docs.map(*.IO.f)), 'all files returned exist';
33+
34+
my @tests = Test-Files.tests();
35+
ok @tests.elems > 1, '.tests returns something array-like with at least one item';
36+
ok all(@tests>>.ends-with('.t')), 'all files returned are test files';
37+
ok all(@tests.map(*.IO.f)), 'all files returned exist';
38+
39+
my $expected = q:to/END/;
40+
foo,foo.md,foo.pod6,foo.t
41+
---
42+
foo.pod6
43+
---
44+
foo.md,foo.pod6
45+
---
46+
foo.t
47+
---
48+
END
49+
50+
is run($*EXECUTABLE, 'xt/lib-test-files.raku', 'foo.t', 'foo.pod6', 'foo.md', 'foo', :out).out.slurp(:close), $expected, 'correct (sorted) output from command line usage';
51+
52+
# Now test the specific TEST_FILES we want...
53+
%*ENV<TEST_FILES>='this-file-does-not-exist xt/lib-test-files.t';
54+
is Test-Files.files, 'xt/lib-test-files.t', 'TEST_FILES 1 skip missing files, keep existing';
55+
is Test-Files.pods, '', 'TEST_FILES 1 skip missing files, bad type';
56+
is Test-Files.documents, '', 'TEST_FILES 1 skip missing files, bad type';
57+
is Test-Files.tests, 'xt/lib-test-files.t', 'TEST_FILES 1 skip missing files, keep existing type match';
58+
59+
%*ENV<TEST_FILES>='this-file-does-not-exist CONTRIBUTING.md';
60+
is Test-Files.files, 'CONTRIBUTING.md', 'TEST_FILES 2 skip missing files, keep existing';
61+
is Test-Files.pods, '', 'TEST_FILES 2 skip missing files, bad type';
62+
is Test-Files.documents, 'CONTRIBUTING.md', 'TEST_FILES 2 skip missing files, keep existing type match';
63+
is Test-Files.tests, '', 'TEST_FILES 2 skip missing files, bad type';
64+
65+
%*ENV<TEST_FILES>='this-file-does-not-exist doc/Type/Mu.pod6';
66+
is Test-Files.files, 'doc/Type/Mu.pod6', 'TEST_FILES 3 skip missing files, keep existing';
67+
is Test-Files.pods, 'doc/Type/Mu.pod6', 'TEST_FILES 3 skip missing files, keep existing type match';
68+
is Test-Files.documents, 'doc/Type/Mu.pod6', 'TEST_FILES 3 skip missing files, keep existing type match';
69+
is Test-Files.tests, '', 'TEST_FILES 3 skip missing files, bad type';
70+

0 commit comments

Comments
 (0)