Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix directive naming Update check_nightly.py #12729

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions scripts/check_nightly.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
they are all referenced in NayDuck test list files (the nightly/*.txt files).
Returns with success if that's the case; with failure otherwise.

An expensive test is one which is marked with expensive_tests feature as
follows:
An expensive test is one which is marked with `ultra_slow_test_` prefix in the
function name as follows:

#[test]
#[cfg_attr(not(feature = "expensive_tests"), ignore)]
fn test_gc_random_large() {
fn ultra_slow_test_gc_random_large() {
test_gc_random_common(25);
}

The `test` and `cfg_attr` annotations can be specified in whatever order but
note that the script isn’t too smart about parsing Rust files and using
something more complicated in the `cfg_attr` will confuse it.
The script isn’t too smart about parsing Rust files and using something more
complicated in the `cfg_attr` will confuse it.

Expensive tests are not executed when running `cargo test` nor are they run in
CI and it’s the purpose of this script to make sure that they are listed for
Expand All @@ -33,33 +31,27 @@

IGNORED_SUBDIRS = ('target', 'target_expensive', 'sandbox')

EXPENSIVE_DIRECTIVE = 'ultra_slow_test_'
TEST_DIRECTIVE = '#[test]'


def expensive_tests_in_file(path: pathlib.Path) -> typing.Iterable[str]:
"""Yields names of expensive tests found in given Rust file.

An expensive test is a function annotated with `test` and a conditional
`ignore` attributes, specifically:
An expensive test is a function annotated with `test` and prefixed with
`ultra_slow_test_` in the function name, specifically:

#[test]
#[cfg_attr(not(feature = "expensive_tests"), ignore)]
fn test_slow() {
fn ultra_slow_test_slow() {
// ...
}

Note that anything more complex in the `cfg_attr` will cause the function
not to recognise the test.

Args:
path: Path to the Rust source file.
Yields:
Names of functions defining expensive tests (e.g. `test_slow` in example
above).
Names of functions defining expensive tests (e.g. `ultra_slow_test_slow`
in example above).
"""
with open(path) as rd:
is_expensive = False
is_test = False
for line in rd:
line = line.strip()
Expand All @@ -73,7 +65,6 @@ def expensive_tests_in_file(path: pathlib.Path) -> typing.Iterable[str]:
line)
if match:
yield match.group(1)
is_expensive = False
is_test = False


Expand Down