about summary refs log tree commit diff
path: root/library/std/tests
AgeCommit message (Collapse)AuthorLines
2025-08-13Rollup merge of #144870 - Kivooeo:file_prefix-stabilize, r=tgross35Jakub Beránek-7/+1
Stabilize `path_file_prefix` feature This stabilises `Path::file_prefix`, following the FCP in [tracking issue ](https://github.com/rust-lang/rust/issues/86319) (FCP ended almost a year ago, so if it's needed for proccess we could rerun it) Closes: https://github.com/rust-lang/rust/issues/86319
2025-08-10Remove unnecessary parentheses in `assert!`sEsteban Küber-1/+1
2025-08-08Revert "Rollup merge of #143906 - ↵Jakub Beránek-7/+7
LorrensP-2158466:miri-float-nondet-foreign-items, r=RalfJung" This reverts commit 71f04692c32e181ab566c01942f1418dec8662d4, reversing changes made to 995ca3e532b48b689567533e6b736675e38b741e.
2025-08-07Rollup merge of #143906 - LorrensP-2158466:miri-float-nondet-foreign-items, ↵Stuart Cook-7/+7
r=RalfJung Miri: non-deterministic floating point operations in `foreign_items` Part of [rust-lang/miri/#3555](https://github.com/rust-lang/miri/issues/3555#issue-2278914000), this pr does the `foreign_items` work. Some things have changed since rust-lang/rust#138062 and rust-lang/rust#142514. I moved the "helpers" used for creating fixed outputs and clamping operations to their defined ranges to `math.rs`. These are now also extended to handle the floating-point operations in `foreign_items`. Tests in `miri/tests/float.rs` were changed/added. Failing tests in `std` were extracted, run under miri with `-Zmiri-many-seeds=0..1000` and changed accordingly. Double checked with `-Zmiri-many-seeds`. I noticed that the C standard doesn't specify the output ranges for all of its mathematical operations; it just specifies them as: ``` Returns The sinh functions return sinh x. ``` So I used [Wolfram|Alpha](https://www.wolframalpha.com/).
2025-08-06Change stdlib float tests to account for miri nondet floats.LorrensP-2158466-7/+7
2025-08-04remove gateKivooeo-7/+1
2025-07-29add extra drop, panic, and unwind testsConnor Tsui-22/+80
2025-07-29add nonpoison and poison mutex testsConnor Tsui-146/+260
Adds tests for the `nonpoison::Mutex` variant by using a macro to duplicate the existing `poison` tests. Note that all of the tests here are adapted from the existing `poison` tests.
2025-07-29reorder mutex testsConnor Tsui-144/+158
This commit simply helps discern the actual changes needed to test both poison and nonpoison locks.
2025-07-06Auto merge of #141829 - dvdsk:sleep_until_linux, r=cuviper,RalfJungbors-1/+13
Specialize sleep_until implementation for unix (except mac) related tracking issue: https://github.com/rust-lang/rust/issues/113752 Supersedes https://github.com/rust-lang/rust/pull/118480 for the reasons see: https://github.com/rust-lang/rust/issues/113752#issuecomment-2902594469 Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos etc. Other platforms like wasi, macos/ios/tvos/watchos and windows will follow in later separate PR's (once this is merged).
2025-07-06sleep_until: use clock_nanosleep where possibledvdsk-1/+13
Using clock nanosleep leads to more accurate sleep times on platforms where it is supported. To enable using clock_nanosleep this makes `sleep_until` platform specific. That unfortunatly requires identical placeholder implementations for the other platforms (windows/mac/wasm etc). we will land platform specific implementations for those later. See the `sleep_until` tracking issue. This requires an accessors for the Instant type. As that accessor is only used on the platforms that have clock_nanosleep it is marked as allow_unused. 32bit time_t targets do not use clock_nanosleep atm, they instead rely on the same placeholder as the other platforms. We could make them use clock_nanosleep too in the future using `__clock_nanosleep_time64`. __clock_nanosleep_time64 is documented at: https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-06-25make `tidy-alphabetical` use a natural sortFolkert de Vries-4/+4
2025-06-19Auto merge of #141864 - Berrysoft:cygwin-path, r=ChrisDentonbors-0/+472
Handle win32 separator for cygwin paths This PR handles a issue that cygwin actually supports Win32 path, so we need to handle the Win32 prefix and separaters. r? `@mati865` cc `@jeremyd2019` ~~Not sure if I should handle the prefix like the windows target... Cygwin *does* support win32 paths directly going through the APIs, but I think it's not the recommended way.~~ Here I just use `cygwin_conv_path` because it handles both cygwin and win32 paths correctly and convert them into absolute POSIX paths. UPDATE: Windows path prefix is handled.
2025-06-17library: Increase timeout on mpmc test to reduce flakesJubilee Young-2/+2
This recently spuriously failed in a rollup, so I think we can afford to increase the base timeout and the amount of time slept for to provide a much wider margin for the timeout to be reached.
2025-06-16Handle win32 separator & prefixes for cygwin paths王宇逸-0/+472
2025-06-09Auto merge of #138062 - LorrensP-2158466:miri-enable-float-nondet, r=RalfJungbors-18/+23
Enable Non-determinism of float operations in Miri and change std tests Links to [#4208](https://github.com/rust-lang/miri/issues/4208) and [#3555](https://github.com/rust-lang/miri/issues/3555) in Miri. Non-determinism of floating point operations was disabled in rust-lang/rust#137594 because it breaks the tests and doc-tests in core/coretests and std. This PR enables some of them. This pr includes the following changes: - Enables the float non-determinism but with a lower relative error of 4ULP instead of 16ULP - These operations now have a fixed output based on the C23 standard, except the pow operations, this is tracked in [#4286](https://github.com/rust-lang/miri/issues/4286#issue-3010677983) - Changes tests that made incorrect assumptions about the operations, not to make that assumption anymore (from `assert_eq!` to `assert_approx_eq!`. - Changed the doctests of the stdlib of these operations to compare against fixed constants instead of `f*::EPSILON`, which now succeed with Miri and `-Zmiri-many-seeds` - Added a constant `APPROX_DELTA` in `std/tests/floats/f32.rs` which is used for approximation tests, but with a different value when run in Miri. This is to make these tests succeed. - Added tests in the float tests of Miri to test the C23 behaviour. Fixes https://github.com/rust-lang/miri/issues/4208
2025-06-08Avoid a gratuitous 10s wait in a stress testJosh Triplett-6/+16
`stress_recv_timeout_two_threads`, in the mpmc and mpsc testsuites, is a stress test of the `recv_timeout` function. This test processes and ignores timeouts, and just ensures that every sent value gets received. As such, the exact length of the timeouts is not critical, only that the timeout and sleep durations ensure that at least one timeout occurred. The current tests have 100 iterations, half of which sleep for 200ms, causing the test to take 10s. This represents around 2/3rds of the *total* runtime of the `library/std` testsuite. Reduce this to 50 iterations where half of them sleep for 10ms, causing the test to take 0.25s. Add a check that at least one timeout occurred.
2025-06-06Stabilised `os_string_pathbuf_leak`schvv31n-1/+0
2025-06-05change tests to use fixed constants to let them pass with miriLorrensP-2158466-52/+12
2025-06-03Enable Float non-determinism in miri. Update and add tests and changeLorrensP-2158466-18/+63
change tests in std, core and coretests.
2025-05-25Implement normalize lexicallyChris Denton-1/+55
2025-05-24Rollup merge of #141105 - GrantBirki:grantbirki/path-tests, r=jhprattGuillaume Gomez-0/+31
additional edge cases tests for `path.rs` 🧪 This pull request adds a few new edge case tests to the `std::path` module. The new tests cover scenarios such as paths with only separators, non-ASCII and Unicode characters, embedded new lines, etc. Each new test is documented with some helpful in-line comments as well.
2025-05-17remove extra tests that really might not be all that usefulGrantBirki-55/+0
2025-05-17revert forward slash to backslashGrantBirki-1/+1
2025-05-16remove `test_embedded_null_byte()` test for nowGrantBirki-20/+0
2025-05-16additional edge cases tests for `path.rs`GrantBirki-1/+107
2025-05-14Move applicable float tests from `coretests` back to `std`Trevor Gross-0/+1166
The previous commit moved all test files from `std` to `core` so git understands the move. Not all functionality is actually testable in `core`, however, so perform move the relevant portions back. Changes from inherent to module methods is also done since this is the form of math operations available in `core` (as `core_float_math`).
2025-05-13Move float tests from std to coreTrevor Gross-3994/+0
Many float-related tests in `std` only depend on `core`, so move the tests there. This also allows us to verify functions from `core_float_math`. Since the majority of test files need to be moved to `coretests`, move the files here without any cleanup; this is done in a followup commit. This makes git history slightly cleaner, but coretests will not build immediately after this commit.
2025-05-12update cfg(bootstrap)Pietro Albini-64/+2
2025-04-30Rename `(Mapped)(RwLock|Mutex)Guard::try_map` to `filter_map`.Zachary S-18/+26
1. analogous to std::cell::Ref(Mut)::filter_map. 2. doesn't imply `Try` genericizability.
2025-04-27Use `feature(target_has_reliable_f16_f128)` in library testsTrevor Gross-62/+192
New compiler configuration has been introduced that is designed to replace the build script configuration `reliable_f16`, `reliable_f128`, `reliable_f16_math`, and `reliable_f128_math`. Do this replacement here, which allows us to clean up `std`'s build script. All tests are gated by `#[cfg(bootstrap)]` rather than doing a more complicated `cfg(bootstrap)` / `cfg(not(bootstrap))` split since the next beta split is within two weeks.
2025-04-22test_nan: ensure the NAN contant is quietRalf Jung-0/+8
2025-04-15Basic tests of MPMC receiver cloningGlyn Normington-0/+30
Ref: https://github.com/rust-lang/rust/issues/126840#issuecomment-2802321146
2025-04-05Rollup merge of #137897 - xTachyon:tls-fix, r=thomcc,jieyouxuStuart Cook-1/+22
fix pthread-based tls on apple targets Tries to fix #127773.
2025-04-04Expose algebraic floating point intrinsicsCalder Coalson-2/+82
2025-03-22Rollup merge of #138294 - paulmenage:test-panic-unwind, r=bjorn3Matthias Krüger-2/+34
Mark some std tests as requiring `panic = "unwind"` This allows these test modules to pass on builds/targets without unwinding support, where `panic = "abort"` - the ignored tests are for functionality that's not supported on those targets.
2025-03-18fix pthread-based tls on apple targetsAndrei Damian-1/+22
2025-03-17Rollup merge of #137793 - NobodyXu:stablise-annoymous-pipe, r=joshtriplettJacob Pratt-2/+0
Stablize anonymous pipe Since #135822 is staled, I create this PR to stablise anonymous pipe Closes #127154 try-job: test-various
2025-03-17Auto merge of #138363 - beetrees:f16-f128-integer-convert, r=Amanieubors-0/+43
Add `From<{integer}>` for `f16`/`f128` impls This PR adds `impl From<{bool,i8,u8}> for f16` and `impl From<{bool,i8,u8,i16,u16,i32,u32}> for f128`. The `From<{i64,u64}> for f128` impls are left commented out as adding them would allow using `f128` on stable before it is stabilised like in the following example: ```rust fn f<T: From<u64>>(x: T) -> T { x } fn main() { let x = f(1.0); // the type of the literal is inferred to be `f128` } ``` None of the impls added in this PR have this issue as they are all, at minimum, also implemented by `f64`. This PR will need a crater run for the `From<{i32,u32}>` impls, as `f64` is no longer the only float type to implement them (similar to the cause of #125198). cc `@bjoernager` r? `@tgross35` Tracking issue: #116909
2025-03-16Rollup merge of #138275 - folkertdev:expose-is-s390x-feature-detected, ↵许杰友 Jieyou Xu (Joe)-0/+30
r=Mark-Simulacrum expose `is_s390x_feature_detected!` from `std::arch` tracking issue: https://github.com/rust-lang/rust/issues/135413 implementation: https://github.com/rust-lang/stdarch/pull/1699 (more features added in https://github.com/rust-lang/stdarch/pull/1720) This macro was part of the recent `stdarch` synchronization, but not yet exposed via `std::arch`. r? libs
2025-03-14Stablize feature `anonymous_pipe`Jiahao XU-2/+0
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-11Add `From<{integer}>` for `f16`/`f128` implsbeetrees-0/+43
2025-03-11Enable `f16` tests for `powf`Trevor Gross-43/+41
The LLVM issue [1] was fixed with [2], which is included in the LLVM20 upgrade. Tests no longer fail, so enable them here. [1]: https://github.com/llvm/llvm-project/pull/98681 [2]: https://github.com/llvm/llvm-project/pull/98681
2025-03-10Mark some std tests as requiring `panic = "unwind"`Paul Menage-2/+34
This allows these test modules to pass on builds/targets without unwinding support, where `panic = "abort"` - the ignored tests are for functionality that's not supported on those targets.
2025-03-09expose `is_s390x_feature_detected` from `std::arch`Folkert de Vries-0/+30
2025-02-13std: Apply deprecated_safe_2024Eric Huss-33/+51
2025-02-13library: Update rand to 0.9.0Eric Huss-2/+2
2025-02-10Rollup merge of #136805 - RalfJung:miri-win-delete-self, r=NoratriebJubilee-0/+1
ignore win_delete_self test in Miri Follow-up to https://github.com/rust-lang/rust/pull/134679, fixes miri-test-libstd on Windows Cc `@ChrisDenton` `@Mark-Simulacrum`
2025-02-10ignore win_delete_self test in MiriRalf Jung-0/+1