Skip to content

Commit 025402d

Browse files
committed
Expose information to tests about scope
Allow tests to find out if they are being running in the scope of all files, or just a subset. Add note to 'make xtest' helper script Update search-categories to use this and skip a test that will always fail if run on a subset of files.
1 parent 7f3b45f commit 025402d

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

lib/Test-Files.rakumod

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@ unit class Test-Files;
22

33
=begin overview
44
5-
Provide methods to generate a list of all C<files>, C<pod> documents,
6-
all C<documents> (POD and markdown), and C<tests> based on the output
7-
of C<git ls-files>.
5+
Utility methods for generating lists of files for testing.
86
9-
If the environment variable C<TEST_FILES> is set, it's treated a
10-
space-separated list of files to use instead. Files are trimmed from the list
11-
if they don't exist.
7+
=end overview
8+
9+
#|(
10+
Are we working with all the files in the repository?
11+
)
12+
method all-files() {
13+
not (@*ARGS or %*ENV<TEST_FILES>);
14+
}
1215

13-
If files were passed on the command line, use that list (as is) instead.
16+
#|(
17+
Return list of files to test.
1418

15-
=end overview
19+
If files were passed on the command line, use those.
1620

21+
Otherwise, if the C<TEST_FILES> environmental variable is set to
22+
a space-separated list of files, use that. Any files specified
23+
this way that don't exist are silently removed.
24+
)
1725
method files() {
1826
my @files;
1927

@@ -29,14 +37,23 @@ method files() {
2937
return @files.sort;
3038
}
3139

40+
#|(
41+
Filtered list of C<files> to return only Pod files.
42+
)
3243
method pods() {
3344
return $.files.grep({$_.ends-with: '.pod6'})
3445
}
3546

47+
#|(
48+
Filtered list of C<files> to return only Pod files and markdown.
49+
)
3650
method documents() {
3751
return $.files.grep({$_.ends-with: '.pod6' or $_.ends-with: '.md'})
3852
}
3953

54+
#|(
55+
Filtered list of C<files> to return only test files.
56+
)
4057
method tests() {
4158
return $.files.grep({$_.ends-with: '.t'})
4259
}

util/update-and-test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
55
Not everyone runs the extended test suite; this gives developers the ability
66
to test as they go; it updates the repository, runs xtest only on those
7-
files that have changed in that update, and leaves a local 'retest' script
7+
files that have changed in that update, and leaves a local C<retest> script
88
that can be rerun against those changes until xtest is clean.
99
10+
Note that test files are allowed to skip certain tests if they are run on a restricted
11+
subset of files; the full C<make xtest> should still be run on a regular basis.
12+
1013
=end overview
1114

1215
# Get the old and new commit IDs

xt/search-categories.t

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ for @files -> $file {
3232
}
3333
}
3434

35-
# Note: if run on a subset of files, this will report false positives
36-
subtest "Category usage" => {
37-
for @categories -> $category {
38-
ok %*used-categories{$category}:exists, "Category「$category」is used in documentation";
35+
if Test-Files.all-files {
36+
subtest "Category usage" => {
37+
for @categories -> $category {
38+
ok %*used-categories{$category}:exists, "Category「$category」is used in documentation";
39+
}
3940
}
41+
} else {
42+
skip "Can't check category usage when testing subset of files", 1;
4043
}
4144

4245
sub test-ref ($ref) {

0 commit comments

Comments
 (0)