Skip to content

Commit

Permalink
Update bootstrap tfp to --skip-huge instead of listing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jul 15, 2024
1 parent c451197 commit d758e96
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3535,11 +3535,7 @@ impl Step for TestFloatParse {
if builder.config.args().is_empty() {
builder.info("only running a subset of tests by default");
// By default, exclude tests that take longer than ~1m.
cargo_run
.args(["--exclude", "fuzz"])
.args(["--exclude", "exhaustive"])
.args(["--exclude", "large exp"])
.args(["--exclude", "rand digits"]);
cargo_run.arg("--skip-huge");
} else {
cargo_run.args(builder.config.args());
}
Expand Down
31 changes: 17 additions & 14 deletions src/etc/test-float-parse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ The generators work as follows:

- Each generator is a struct that lives somewhere in the `gen` module. Usually
it is generic over a float type.
- These generators must implement `Iterator`, which should return a context
type that can be used to construct a test string (but usually not the string
- These generators must implement `Iterator`, which should return a context type
that can be used to construct a test string (but usually not the string
itself).
- They must also implement the `Generator` trait, which provides a method to
write test context to a string as a test case, as well as some extra metadata.
The split between context generation and string construction is so that
we can reuse string allocations.

The split between context generation and string construction is so that we can
reuse string allocations.
- Each generator gets registered once for each float type. All of these
generators then get iterated, and each test case checked against the float
type's parse implementation.

Some tests produce decimal strings, others generate bit patterns that need
to convert to the float type before printing to a string. For these, float to
Some tests produce decimal strings, others generate bit patterns that need to
convert to the float type before printing to a string. For these, float to
decimal (`flt2dec`) conversions get tested, if unintentionally.

For each test case, the following is done:
Expand All @@ -30,13 +30,16 @@ For each test case, the following is done:
- The test string is parsed separately to a `BigRational`, which acts as a
representation with infinite precision.
- The rational value then gets checked that it is within the float's
representable values (absolute value greater than the smallest number to
round to zero, but less less than the first value to round to infinity). If
these limits are exceeded, check that the parsed float reflects that.
- For real nonzero numbers, the parsed float is converted into a
rational using `significand * 2^exponent`. It is then checked against the
actual rational value, and verified to be within half a bit's precision
of the parsed value.
representable values (absolute value greater than the smallest number to round
to zero, but less less than the first value to round to infinity). If these
limits are exceeded, check that the parsed float reflects that.
- For real nonzero numbers, the parsed float is converted into a rational using
`significand * 2^exponent`. It is then checked against the actual rational
value, and verified to be within half a bit's precision of the parsed value.

This is all highly parallelized with `rayon`; test generators can run in
parallel, and their tests get chunked and run in parallel.

There is a simple command line that allows filtering which tests are run,
setting the number of iterations for fuzzing tests, limiting failures, setting
timeouts, etc. See `main.rs` or run with `--help` for options.
3 changes: 2 additions & 1 deletion src/etc/test-float-parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ mod gen {
pub const DEFAULT_FUZZ_COUNT: u64 = u32::MAX as u64;

/// If there are more tests than this threashold, the test will be defered until after all
/// others run (so as to avoid thread pool starvation).
/// others run (so as to avoid thread pool starvation). They also can be excluded with
/// `--skip-huge`.
const HUGE_TEST_CUTOFF: u64 = 5_000_000;

/// Seed for tests that use a deterministic RNG.
Expand Down

0 comments on commit d758e96

Please sign in to comment.