Commit Graph

168 Commits

Author SHA1 Message Date
Pietro Albini
44556eed36
ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
bors
dbfc95f969 Auto merge of #111348 - ozkanonur:remove-hardcoded-rustdoc-flags, 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-27 04:20:44 +00:00
jyn
9314ed0cbd libtest: Improve error when missing -Zunstable-options
"only accepted on the nightly compiler" is misleading when this *is* nightly.
2023-05-24 11:18:20 -05:00
ozkanonur
6a347322a9 derive Default trait for compiletest::common::Config 2023-05-20 14:40:46 +03:00
Matthias Krüger
bf72b64b96
Rollup merge of #110651 - durin42:xunit-stdout, r=cuviper
libtest: include test output in junit xml reports

Fixes #110336.
2023-05-04 19:18:18 +02:00
Matthias Krüger
0098cd4e83
Rollup merge of #108865 - Zoxc:library-dummy-crate, r=jyn514
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-04 19:18:17 +02:00
Raoul Strackx
a18b750de2 Ensure test library issues json string line-by-line 2023-05-01 10:27:37 +02:00
Augie Fackler
58537cde06 junit: fix typo in comment and don't include output for passes when not requested 2023-04-28 18:37:26 -04:00
Pietro Albini
a7bb8c7851 handle cfg(bootstrap) 2023-04-28 08:47:55 -07:00
John Kåre Alsaker
fd4c81f4c1 Add a sysroot crate to represent the standard library crates 2023-04-25 13:40:36 +02:00
Augie Fackler
610f827261 junit: also include per-case stdout in xml
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 
 to avoid literal newlines in the
output.
2023-04-21 13:15:04 -04:00
Matthias Krüger
d1c480f986
Rollup merge of #110154 - DaniPopes:library-typos, r=JohnTitor
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-14 21:11:12 +02:00
DaniPopes
a0daf22b95
Fix typos in library 2023-04-10 21:07:29 +02:00
Josh Triplett
afd45c2e10 Stabilize IsTerminal
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-10 17:24:23 +09:00
Partha P. Das
3720753632
Implementing "<test_binary> --list --format json" #107307 #49359 2023-03-15 14:20:20 -04:00
est31
999405059c Match unmatched backticks in library/ 2023-03-03 03:03:29 +01:00
klensy
c3749ddf4c test: drop unused deps 2023-02-24 20:45:00 +03:00
Matthias Krüger
192eecd53a
Rollup merge of #106769 - 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-29 20:03:36 +01:00
Dylan DPC
9e6873f788
Rollup merge of #106767 - chbaker0:disable-unstable-features, r=Mark-Simulacrum
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-25 17:01:41 +05:30
Lenko Donchev
77133370ce Print why a test was ignored if it's the only test specified. 2023-01-22 18:56:13 -06:00
André Vennberg
0b35f448f8 Remove various double spaces in source comments. 2023-01-14 17:22:04 +01:00
Collin Baker
0a03d1c9ca 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-12 05:36:04 -05:00
Joshua Nelson
3534e0a393 Fix a few clippy lints in libtest
- Remove unnecessary references and dereferences
- Use `.contains` instead of `a <= x && x <= b`
- Use `mem::take` instead of `mem::replace` where possible
2023-01-03 18:55:03 +00:00
nils
5fb2d63d07
Fix uninlined_format_args in libtest 2022-12-19 08:58:40 +01:00
Oli Scherer
e59025867d Create a hacky fail-fast mode that stops tests at the first failure 2022-12-01 20:29:18 +00:00
Collin Baker
426296ecc3 Update test's cfg-if dependency to 1.0
This change was mistakenly left out of #103367
2022-11-21 16:43:34 -05:00
Matthias Krüger
c38ee06b62
Rollup merge of #103681 - RalfJung:libtest-thread, r=thomcc
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-11-04 18:52:26 +01:00
Thom Chiovoloni
b56cb9e032
Include both benchmarks and tests in the numbers given to TeFiltered{,Out} 2022-10-31 00:42:10 -07:00
Ralf Jung
3af058ec94 libtest: run all tests in their own thread, if supported by the host 2022-10-28 12:26:09 +02:00
Ben Kimock
17b86cb611 Do fewer passes and generally be more efficient when filtering tests 2022-10-27 21:34:56 -04:00
Ben Kimock
458aaa5a23 Print the precondition we violated, and visible through output capture
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-10-26 22:09:17 -04:00
Yuki Okushi
779418deb4
Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726
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-24 19:32:25 +09:00
Ralf Jung
3ff0a33a83 WinConsole::new is not actually fallible 2022-10-21 12:18:33 +02:00
Josh Triplett
326ef470a8 Add IsTerminal trait to determine if a descriptor or handle is a terminal
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>
2022-10-15 00:35:38 +01:00
Dylan DPC
13f47f608e
Rollup merge of #100451 - hovinen:no-panic-on-result-err-in-test, r=Mark-Simulacrum
Do not panic when a test function returns Result::Err.

Rust's test library allows test functions to return a `Result`, so that the test is deemed to have failed if the function returns a `Result::Err` variant. Currently, this works by having `Result` implement the `Termination` trait and asserting in assert_test_result that `Termination::report()` indicates successful completion. This turns a `Result::Err` into a panic, which is caught and unwound in the test library.

This approach is problematic in certain environments where one wishes to save on both binary size and compute resources when running tests by:

 * Compiling all code with `--panic=abort` to avoid having to generate unwinding tables, and
 * Running most tests in-process to avoid the overhead of spawning new processes.

This change removes the intermediate panic step and passes a `Result::Err` directly through to the test runner.

To do this, it modifies `assert_test_result` to return a `Result<(), String>` where the `Err` variant holds what was previously the panic message. It changes the types in the `TestFn` enum to return `Result<(), String>`.

This tries to minimise the changes to benchmark tests, so it calls `unwrap()` on the `Result` returned by `assert_test_result`, effectively keeping the same behaviour as before.

Some questions for reviewers:

 * Does the change to the return types in the enum `TestFn` constitute a breaking change for the library API? Namely, the enum definition is public but the test library indicates that "Currently, not much of this is meant for users" and most of the library API appears to be marked unstable.
 * Is there a way to test this change, i.e., to test that no panic occurs if a test returns `Result::Err`?
 * Is there a shorter, more idiomatic way to fold `Result<Result<T,E>,E>` into a `Result<T,E>` than the `fold_err` function I added?
2022-10-02 20:42:20 +05:30
Urgau
9ad2f00f6a Stabilize bench_black_box 2022-09-27 17:38:51 +02:00
Bradford Hovinen
e19a98cff7 Do not panic when a test function returns Result::Err.
Rust's test library allows test functions to return a Result, so that the test is deemed to have failed if the function returns a Result::Err variant. Currently, this works by having Result implement the Termination trait and asserting in assert_test_result that Termination::report() indicates successful completion. This turns a Result::Err into a panic, which is caught and unwound in the test library.

This approach is problematic in certain environments where one wishes to save on both binary size and compute resources when running tests by:

 * Compiling all code with --panic=abort to avoid having to generate unwinding tables, and
 * Running most tests in-process to avoid the overhead of spawning new processes.

This change removes the intermediate panic step and passes a Result::Err directly through to the test runner.

To do this, it modifies assert_test_result to return a Result<(), String> where the Err variant holds what was previously the panic message. It changes the types in the TestFn enum to return Result<(), String>.

This tries to minimise the changes to benchmark tests, so it calls unwrap() on the Result returned by assert_test_result, effectively keeping the same behaviour as before.
2022-09-16 14:36:00 +00:00
LingMan
fd21df7182 Fix naming format of IEEE 754 standard
Currently the documentation of f64::min refers to "IEEE-754 2008" while the documentation of
f64::minimum refers to "IEEE 754-2019".
Note that one has the format IEEE,hyphen,number,space,year while the other is
IEEE,space,number,hyphen,year. The official IEEE site [1] uses the later format and it is also the
one most commonly used throughout the codebase.

Update all comments and - more importantly - documentation to consistently use the official format.

[1] https://standards.ieee.org/ieee/754/4211/
2022-09-11 04:13:33 +02:00
Ben Kimock
df6221adc6 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.
2022-09-01 09:04:25 -04:00
Ralf Jung
5076c902a4 test: skip terminfo parsing in Miri 2022-08-07 11:56:12 -04:00
Ben Kimock
90dc0b02ae Lock stdout once when listing tests 2022-07-22 18:39:26 -04:00
Smitty
ed542df9bc Fix binary name in help message for test binaries 2022-07-09 18:52:37 -04:00
Jack Huey
410dcc9674 Fully stabilize NLL 2022-06-03 17:16:41 -04:00
bors
f565016edd Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrum
Bump bootstrap compiler to 1.61.0 beta

This PR bumps the bootstrap compiler to the 1.61.0 beta. The first commit changes the stage0 compiler, the second commit applies the "mechanical" changes and the third and fourth commits apply changes explained in the relevant comments.

r? `@Mark-Simulacrum`
2022-04-07 07:34:04 +00:00
Dylan DPC
687e40a959
Rollup merge of #95709 - nnethercote:improve-terse-test-output, r=Dylan-DPC
Improve terse test output.

The current terse output gives 112 chars per line, which causes
wraparound for people using 100 char wide terminals, which is very
common.

This commit changes it to be exactly 100 wide, which makes the output
look much nicer.
2022-04-07 01:59:23 +02:00
Nicholas Nethercote
b72a7fbcdc Improve terse test output.
The current terse output gives 112 chars per line, which causes
wraparound for people using 100 char wide terminals, which is very
common.

This commit changes it to be exactly 100 wide, which makes the output
look much nicer.
2022-04-06 11:21:14 +10:00
Pietro Albini
181d28bb61
trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
Pyry Kontio
1b9cd5bb62 Stabilize total_cmp 2022-04-04 18:57:49 +09:00
Dylan DPC
bba2a64d0c
Rollup merge of #93840 - yaahc:termination-stabilization-celebration-station, r=joshtriplett
Stabilize Termination and ExitCode

From https://github.com/rust-lang/rust/issues/43301

This PR stabilizes the Termination trait and associated ExitCode type. It also adjusts the ExitCode feature flag to replace the placeholder flag with a more permanent name, as well as splitting off the `to_i32` method behind its own permanently unstable feature flag.

This PR stabilizes the termination trait with the following signature:

```rust
pub trait Termination {
    fn report(self) -> ExitCode;
}
```

The existing impls of `Termination` are effectively already stable due to the prior stabilization of `?` in main.

This PR also stabilizes the following APIs on exit code

```rust
#[derive(Clone, Copy, Debug)]
pub struct ExitCode(_);

impl ExitCode {
    pub const SUCCESS: ExitCode;
    pub const FAILURE: ExitCode;
}

impl From<u8> for ExitCode { /* ... */ }
```

---

All of the previous blockers have been resolved. The main ones that were resolved recently are:

* The trait's name: We decided against changing this since none of the alternatives seemed particularly compelling. Instead we decided to end the bikeshedding and stick with the current name. ([link to the discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization/near/269793887))
* Issues around platform specific representations: We resolved this issue by changing the return type of `report` from `i32` to the opaque type `ExitCode`. That way we can change the underlying representation without affecting the API, letting us offer full support for platform specific exit code APIs in the future.
* Custom exit codes: We resolved this by adding `From<u8> for ExitCode`. We choose to only support u8 initially because it is the least common denominator between the sets of exit codes supported by our current platforms. In the future we anticipate adding platform specific extension traits to ExitCode for constructors from larger or negative numbers, as needed.
2022-03-29 22:46:31 +02:00
Mara Bos
b1c3494d88
Remove unnecessary .as_ref(). 2022-03-29 15:53:09 +02:00