about summary refs log tree commit diff
path: root/library/std/tests
AgeCommit message (Collapse)AuthorLines
2025-10-02Rollup merge of #146281 - Jules-Bertholet:static-align-thread-local, ↵Matthias Krüger-0/+2
r=Mark-Simulacrum Support `#[rustc_align_static]` inside `thread_local!` Tracking issue: rust-lang/rust#146177 ```rust thread_local! { #[rustc_align_static(64)] static SO_ALIGNED: u64 = const { 0 }; } ``` This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case. r? libs ``@rustbot`` label A-attributes A-macros A-thread-locals F-static_align T-libs
2025-09-30Rollup merge of #142506 - clarfonthey:path-trailing-sep, r=joboetMatthias Krüger-1/+37
Add `Path::has_trailing_sep` and related methods Implements rust-lang/libs-team#335. Tracking issue: rust-lang/rust#142503 Notable differences from ACP: * `trim_trailing_sep` was added to `Path` since it felt reasonable to ensure that the inverse operation was available. * Per suggestion of `@kennytm,` added `push_trailing_sep` and `pop_trailing_sep` to `PathBuf` in addition to `set_trailing_sep`. This also updates some of the docs on various `Path` methods to use the term "trailing separator" instead of "trailing slash" for consistency.
2025-09-26Support `#[rustc_align_static]` inside `thread_local!`Jules Bertholet-0/+2
2025-09-24Rollup merge of #146958 - el-ev:fix_path_string_eq_recurse, r=joboetMatthias Krüger-3/+13
Fix infinite recursion in Path::eq with String - Closes [after beta backport] rust-lang/rust#146940
2025-09-24Repro duration_since regression from issue 146228Stepan Koltsov-0/+16
2025-09-24Fix infinite recursion in Path::eq with StringIris Shi-3/+13
2025-09-19Fix test suite in iOS/tvOS/watchOS/visionOS simulatorMads Marquart-0/+1
2025-09-11update doc commentConnor Tsui-1/+1
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-09-11fix config for poison macro testConnor Tsui-15/+18
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-09-10Rollup merge of #146322 - weiznich:fix/146087, r=joboetMatthias Krüger-0/+9
Make Barrier RefUnwindSafe again This commit manually implements `RefUnwindSafe` for `std::sync::Barrier` to fix rust-lang/rust#146087. This is a fix for a regression indroduced by https://github.com/rust-lang/rust/commit/e95db591a4550e28ad92660b753ad85b89271882
2025-09-09Make the compile test use a const insteadGeorg Semmler-8/+7
2025-09-09Make Barrier RefUnwindSafe againGeorg Semmler-0/+10
This commit manually implements `RefUnwindSafe` for `std::sync::Barrier` to fix 146087. This is a fix for a regression indroduced by https://github.com/rust-lang/rust/commit/e95db591a4550e28ad92660b753ad85b89271882
2025-09-09add approx_delta to all gamma testsLorrensP-2158466-5/+5
2025-09-07Auto merge of #146216 - ↵bors-7/+7
LorrensP-2158466:miri-float-nondet-foreign-items-take2, r=RalfJung Miri: non-deterministic floating point operations in foreign_items Take 2 of rust-lang/rust#143906. The last 2 commits are what changed compared to the original pr. Verified the tests using (fish shell): ```fish env MIRIFLAGS="-Zmiri-max-extra-rounding-error -Zmiri-many-seeds" ./x miri --no-fail-fast std core coretests -- f32 f64 ``` r? `@RalfJung`
2025-09-06Change stdlib float tests to account for miri nondet floats.LorrensP-2158466-7/+7
2025-09-04Add `Path::has_trailing_sep` and related methodsltdk-1/+37
2025-09-04add testbendn-0/+6
2025-09-04Rollup merge of #145209 - hanna-kruppe:path_add_extension, r=tgross35Stuart Cook-1/+1
Stabilize `path_add_extension` FCP in tracking issue rust-lang/rust#127292 finished in January. There was more discussion since then, but [libs-api decided to match `set_extension`][0] by keeping the return type as-is and adding a panic for invalid extensions. The latter was implemented in rust-lang/rust#140163, so this feature should be ready for stabilization. But if anyone's unsure, another FCP could be done to confirm. Closes rust-lang/rust#127292 [0]: https://github.com/rust-lang/rust/issues/127292#issuecomment-2605197960
2025-08-31fixLorrensP-2158466-2/+2
2025-08-30Rollup merge of #144651 - connortsui20:nonpoison_condvar, r=joboetStuart Cook-195/+241
Implementation: `#[feature(nonpoison_condvar)]` Tracking Issue: https://github.com/rust-lang/rust/issues/134645 This PR continues the effort made in https://github.com/rust-lang/rust/pull/144022 by adding the implementation of `nonpoison::condvar`. Many of the changes here are similar to the changes made to implement `nonpoison::mutex`. There are two other changes here. The first is that the `Barrier` implementation is migrated to use the `nonpoison::Condvar` instead of the `poison` variant. The second (which might be subject to some discussion) is that `WaitTimeoutResult` is moved up to `mod.rs`, as both `condvar` variants need that type (and I do not know if there is a better place to put it now). ### Related PRs - `nonpoison_rwlock` implementation: https://github.com/rust-lang/rust/pull/144648 - `nonpoison_once` implementation: https://github.com/rust-lang/rust/pull/144653
2025-08-23Rollup merge of #145307 - connortsui20:lazylock-poison-msg, r=AmanieuJacob Pratt-31/+53
Fix `LazyLock` poison panic message Fixes the issue raised in https://github.com/rust-lang/rust/pull/144872#issuecomment-3151100248 r? ```@Amanieu```
2025-08-23add nonpoison and poison condvar testsConnor Tsui-195/+241
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. Also steals the `test_mutex_arc_condvar` test from `mutex.rs`. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-22Rollup merge of #144648 - connortsui20:nonpoison_rwlock, r=Mark-SimulacrumJacob Pratt-417/+530
Implementation: `#[feature(nonpoison_rwlock)]` Tracking Issue: https://github.com/rust-lang/rust/issues/134645 This PR continues the effort made in https://github.com/rust-lang/rust/pull/144022 by adding the implementation of `nonpoison::rwlock`. Many of the changes here are similar to the changes made to implement `nonpoison::mutex`. The only real difference is that this PR includes a reorganizing of the existing `poison::rwlock` file that hopefully makes both variants more readable. ### Related PRs - `nonpoison_condvar` implementation: https://github.com/rust-lang/rust/pull/144651 - `nonpoison_once` implementation: https://github.com/rust-lang/rust/pull/144653
2025-08-22modify `LazyLock` poison panic messageConnor Tsui-31/+53
Fixes an issue where if the underlying `Once` panics because it is poisoned, the panic displays the wrong message. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-19Rollup merge of #144960 - ↵Stuart Cook-0/+1
raoulstrackx:raoul/rte-513-disable_sleep_tests_on_sgx, r=Mark-Simulacrum [RTE-513] Ignore sleep_until test on SGX rust-lang/rust#141829 added a test for `sleep_until`: it checks whether its specification holds: > Puts the current thread to sleep until the specified deadline has passed. but in SGX there's no secure time source. There's only the ability to request the `insecure_time` from outside of the enclave through a [usercall](https://github.com/fortanix/rust-sgx/blob/master/intel-sgx/fortanix-sgx-abi/src/lib.rs#L590-L592) and the ability to [wait](https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs#L173-L179) for a certain event or timeout. But both are under the control of an attacker; users should not depend on the accuracy nor correctness of this time. We try to even enforce this by adding a +/-10% time interval to wait usercalls. The current `thread::sleep_until` implementation uses this `wait` usercall. When a negative randomization interval is added to the timeout passed in `wait`, the test fails. As users should not rely on the correctness of any time inside the enclave, it should be considered an incorrect test on SGX. This PR ignores this test.
2025-08-16library: Migrate from `cfg_if` to `cfg_select`Josh Triplett-3/+6
Migrate the standard library from using the external `cfg_if` crate to using the now-built-in `cfg_select` macro. This does not yet eliminate the dependency from `library/std/Cargo.toml`, because while the standard library itself no longer uses `cfg_if`, it also incorporates the `backtrace` crate, which does. Migration assisted by the following vim command (after selecting the full `cfg_if!` invocation): ``` '<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e ``` This is imperfect, but substantially accelerated the process. This prompts for confirmation on the `} else {` since that can also appear inside one of the arms. This also requires manual intervention to handle any multi-line conditions.
2025-08-13stabilize path_add_extensionHanna Kruppe-1/+1
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-09add nonpoison and poison rwlock testsConnor Tsui-280/+381
Adds tests for the `nonpoison::RwLock` 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-08-09reorganize rwlock testsConnor Tsui-336/+348
This commit simply helps discern the actual changes needed to test both poison and nonpoison `rwlock`s.
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-05Ignore sleep_until test on SGXRaoul Strackx-0/+1
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