about summary refs log tree commit diff
path: root/library/test
AgeCommit message (Collapse)AuthorLines
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+2
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-09Rollup merge of #114377 - Enselic:test_get_dbpath_for_term-utf-8, r=thomccMatthias Krüger-7/+5
test_get_dbpath_for_term(): handle non-utf8 paths (fix FIXME) Removes a FIXME for #9639 Part of #44366 which is E-help-wanted The remaining two FIXMEs for #9639 are considerably more complicated, so I will create separate PRs for them.
2023-08-03Add `internal_features` lintNilstrieb-0/+1
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-08-02test_get_dbpath_for_term(): handle non-utf8 pathsMartin Nordholts-6/+4
2023-08-02test_get_dbpath_for_term(): Use assert_eq!()Martin Nordholts-3/+3
For better failure messages.
2023-07-31Rollup merge of #113717 - cuishuang:master, r=NilstriebMatthias Krüger-1/+1
remove repetitive words
2023-07-31remove repetitive wordscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-23Auto merge of #113975 - matthiaskrgr:clippy_07_2023, r=fee1-deadbors-2/+1
clippy::style fixes r? `@oli-obk` filter_map_identity iter_kv_map needless_question_mark redundant_at_rest_pattern filter_next derivable_impls useless_format
2023-07-23fix couple of clippy findings:Matthias Krüger-2/+1
filter_map_identity iter_kv_map needless_question_mark redundant_at_rest_pattern filter_next derivable_impls
2023-07-23match on chars instead of &strs for .split() or .strip_prefix()Matthias Krüger-1/+1
2023-07-01Auto merge of #111992 - ferrocene:pa-panic-abort-tests-bench, r=m-ou-sebors-118/+170
Test benchmarks with `-Z panic-abort-tests` During test execution, when a `#[bench]` benchmark is encountered it's executed once to check whether it works. Unfortunately that was not compatible with `-Z panic-abort-tests`: the feature works by spawning a subprocess for each test, which prevents the use of dynamic tests as we cannot pass closures to child processes, and before this PR the conversion from benchmark to test was done by turning benchmarks into dynamic tests whose closures execute the benchmark once. The approach this PR took was to add two new kinds of `TestFn`s: `StaticBenchAsTestFn` and `DynBenchAsTestFn` (:warning: **this is a breaking change** :warning:). With that change, a `StaticBenchFn` can be converted into a `StaticBenchAsTestFn` without creating dynamic tests, and making it possible to test `#[bench]` functions with `-Z panic-abort-tests`. The subprocess test runner also had to be updated to perform the conversion from benchmark to test when appropriate. Along with the bug fix, in the first commit I refactored how tests are executed: rather than executing the test function in multiple places across `libtest`, there is now a private `TestFn::into_runnable()` method, which returns either a `RunnableTest` or `RunnableBench`, on which you can call the `run()` method. This simplified the rest of the changes in the PR. This PR is best reviewed commit-by-commit. Fixes https://github.com/rust-lang/rust/issues/73509
2023-06-13ignore core, alloc and test tests that require unwinding on panic=abortPietro Albini-0/+5
2023-05-27Auto merge of #111348 - ozkanonur:remove-hardcoded-rustdoc-flags, ↵bors-2/+4
r=albertlarsan68,oli-obk new tool `rustdoc-gui-test` Implements new tool `rustdoc-gui-test` that allows using compiletest headers for `rustdoc-gui` tests.
2023-05-26convert benches to tests in subprocess if we're not benchmarkingPietro Albini-2/+17
2023-05-26add StaticBenchAsTestFn and DynBenchAsTestFn to convert benches to testsPietro Albini-19/+23
Before this commit, both static and dynamic benches were converted to a DynTestFn, with a boxed closure that ran the benchmarks exactly once. While this worked, it conflicted with -Z panic-abort-tests as the flag does not support dynamic tests. With this change, a StaticBenchFn is converted to a StaticBenchAsTestFn, avoiding any dynamic test creation. DynBenchFn is also converted to DynBenchAsTestFn for completeness.
2023-05-26remove nested function from run_testPietro Albini-63/+47
The inner function is not needed anymore as it's only called once after the previous commit's refactoring.
2023-05-26refactor executing tests to centralize actually invoking testsPietro Albini-41/+90
Before this commit, tests were invoked in multiple places, especially due to `-Z panic-abort-tests`, and adding a new test kind meant having to chase down and update all these places. This commit creates a new Runnable enum, and its children RunnableTest and RunnableBench. The rest of the harness will now pass around the enum rather than constructing and passing around boxed functions. The enum has two children enums because invoking tests and invoking benchmarks requires different parameters.
2023-05-24libtest: Improve error when missing `-Zunstable-options`jyn-2/+2
"only accepted on the nightly compiler" is misleading when this *is* nightly.
2023-05-20derive `Default` trait for `compiletest::common::Config`ozkanonur-2/+4
2023-05-04Rollup merge of #110651 - durin42:xunit-stdout, r=cuviperMatthias Krüger-5/+35
libtest: include test output in junit xml reports Fixes #110336.
2023-05-04Rollup merge of #108865 - Zoxc:library-dummy-crate, r=jyn514Matthias Krüger-20/+0
Add a `sysroot` crate to represent the standard library crates This adds a dummy crate named `sysroot` to represent the standard library target instead of using the `test` crate. This allows the removal of `proc_macro` as a dependency of `test` allowing these 2 crates to build in parallel saving around 9 seconds locally.
2023-05-01Ensure test library issues json string line-by-lineRaoul Strackx-70/+62
2023-04-28junit: fix typo in comment and don't include output for passes when not ↵Augie Fackler-2/+2
requested
2023-04-28handle cfg(bootstrap)Pietro Albini-121/+0
2023-04-25Add a `sysroot` crate to represent the standard library cratesJohn Kåre Alsaker-20/+0
2023-04-21junit: also include per-case stdout in xmlAugie Fackler-5/+35
By placing the stdout in a CDATA block we avoid almost all escaping, as there's only two byte sequences you can't sneak into a CDATA and you can handle that with some only slightly regrettable CDATA-splitting. I've done this in at least two other implementations of the junit xml format over the years and it's always worked out. The only quirk new to this (for me) is smuggling newlines as &#xA; to avoid literal newlines in the output.
2023-04-14Rollup merge of #110154 - DaniPopes:library-typos, r=JohnTitorMatthias Krüger-5/+5
Fix typos in library I ran [`typos -w library`](https://github.com/crate-ci/typos) to fix typos in the `library` directory. Refs #110150
2023-04-10Fix typos in libraryDaniPopes-5/+5
2023-04-10Stabilize IsTerminalJosh Triplett-1/+0
closes: https://github.com/rust-lang/rust/issues/98070
2023-03-15Implementing "<test_binary> --list --format json" #107307 #49359Partha P. Das-31/+377
2023-03-03Match unmatched backticks in library/est31-1/+1
2023-02-24test: drop unused depsklensy-2/+0
2023-01-29Rollup merge of #106769 - ↵Matthias Krüger-1/+16
lenko-d:libtest-print_why_a_test_was_ignored_if_its_the_only_test_specified, r=Mark-Simulacrum libtest: Print why a test was ignored if it's the only test specified. Fixes [#106659](https://github.com/rust-lang/rust/issues/106659) Needed by [106763](https://github.com/rust-lang/rust/pull/106763)
2023-01-25Rollup merge of #106767 - chbaker0:disable-unstable-features, r=Mark-SimulacrumDylan DPC-1/+2
Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0 Two locations check whether this build-time environment variable is defined. Allowing it to be explicitly disabled with a "0" value is useful, especially for integrating with external build systems.
2023-01-22Print why a test was ignored if it's the only test specified.Lenko Donchev-1/+16
2023-01-14Remove various double spaces in source comments.André Vennberg-2/+2
2023-01-12Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0Collin Baker-1/+2
Two locations check whether this build-time environment variable is defined. Allowing it to be explicitly disabled with a "0" value is useful, especially for integrating with external build systems.
2023-01-03Fix a few clippy lints in libtestJoshua Nelson-51/+51
- Remove unnecessary references and dereferences - Use `.contains` instead of `a <= x && x <= b` - Use `mem::take` instead of `mem::replace` where possible
2022-12-19Fix `uninlined_format_args` in libtestnils-24/+15
2022-12-01Create a hacky fail-fast mode that stops tests at the first failureOli Scherer-1/+27
2022-11-21Update test's cfg-if dependency to 1.0Collin Baker-1/+1
This change was mistakenly left out of #103367
2022-11-04Rollup merge of #103681 - RalfJung:libtest-thread, r=thomccMatthias Krüger-54/+37
libtest: run all tests in their own thread, if supported by the host This reverts the threading changes of https://github.com/rust-lang/rust/pull/56243, which made it so that with `-j1`, the test harness does not spawn any threads. Those changes were done to enable Miri to run the test harness, but Miri supports threads nowadays, so this is no longer needed. Using a thread for each test is useful because the thread's name can be set to the test's name which makes panic messages consistent between `-j1` and `-j2` runs and also a bit more readable. I did not revert the HashMap changes of https://github.com/rust-lang/rust/pull/56243; using a deterministic map seems fine for the test harness and the more deterministic testing is the better. Fixes https://github.com/rust-lang/rust/issues/59122 Fixes https://github.com/rust-lang/rust/issues/70492
2022-10-31Include both benchmarks and tests in the numbers given to `TeFiltered{,Out}`Thom Chiovoloni-2/+5
2022-10-28libtest: run all tests in their own thread, if supported by the hostRalf Jung-54/+37
2022-10-27Do fewer passes and generally be more efficient when filtering testsBen Kimock-29/+66
2022-10-26Print the precondition we violated, and visible through output captureBen Kimock-0/+25
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-10-24Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726Yuki Okushi-38/+8
Sort tests at compile time, not at startup Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue. Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately. (except for doctests, because there is no compile-time harness)
2022-10-21WinConsole::new is not actually fallibleRalf Jung-5/+4
2022-10-15Add `IsTerminal` trait to determine if a descriptor or handle is a terminalJosh Triplett-35/+3
The UNIX and WASI implementations use `isatty`. The Windows implementation uses the same logic the `atty` crate uses, including the hack needed to detect msys terminals. Implement this trait for `File` and for `Stdin`/`Stdout`/`Stderr` and their locked counterparts on all platforms. On UNIX and WASI, implement it for `BorrowedFd`/`OwnedFd`. On Windows, implement it for `BorrowedHandle`/`OwnedHandle`. Based on https://github.com/rust-lang/rust/pull/91121 Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>