Commit Graph

636 Commits

Author SHA1 Message Date
Tyler Mandry 861b328f7d Respect --nocapture in panic=abort test mode 2020-02-06 14:43:53 -08:00
Matthias Krüger 697ef95c9f remove redundant imports (clippy::single_component_path_imports) 2020-02-04 01:05:45 +01:00
Dylan DPC 98347cdbff Rollup merge of #68301 - tmandry:dont-propagate-test-invoke, r=alexcrichton
Don't propagate __RUST_TEST_INVOKE to subprocess

When -Z panic_abort_tests is enabled, we use an environment variable to
tell the subprocess which test to invoke. If that subprocess then
invokes another Rust test binary, chaos ensues.

r? @alexcrichton
2020-01-17 11:16:42 +05:30
Tyler Mandry 6246f7e1f9 Don't propagate __RUST_TEST_INVOKE to subprocess
When -Z panic_abort_tests is enabled, we use an environment variable to
tell the subprocess which test to invoke. If that subprocess then
invokes another Rust test binary, chaos ensues.
2020-01-16 16:54:00 -08:00
Matthias Krüger 7fbd30b1ae don't clone types that are copy
found via clippy
2020-01-16 23:48:49 +01:00
Matthias Krüger 312c3a067a remove redundant clones, found by clippy 2020-01-15 15:00:25 +01:00
Mikail Bagishov 91e9531ed1 Clarify test timeout evironment variables 2020-01-10 21:00:29 +03:00
Mark Rousskov a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
varkor 442514884d Use Instant::now lazily 2019-12-06 12:24:54 +00:00
varkor 9f1269f23c Rename to then_some and then 2019-12-06 12:24:54 +00:00
varkor e3a8ea4e18 Use to_option in various places 2019-12-06 12:23:23 +00:00
Thomas Etter 16bf4f5e1b Simplify if else as suggested in PR feedback 2019-11-19 21:44:45 +01:00
Thomas Etter 48a86e0b2c replace some asserts with assert_eq for better error readability 2019-11-18 00:52:10 +01:00
Thomas Etter be993beb0b print a more useful error message on should_panic mismatch 2019-11-18 00:51:18 +01:00
Tyler Mandry b8dca6c827 Add --force-run-in-process unstable libtest option 2019-11-15 05:52:06 -08:00
Lukas Kalbertodt 761ba89ffd Replace array.into_iter() with iter() in libtest/tests.rs 2019-11-06 14:43:52 +01:00
Tyler Mandry 4bb91c7845 Rollup merge of #65898 - hermitcore:rusty-hermit, r=kennytm
add basic HermitCore support within libtest

This an extension to #65167. The current pull request extend libtest to support HermitCore as target OS.
2019-10-29 12:01:41 -07:00
Stefan Lankes cf65200e5c removing trailing whitespaces 2019-10-28 14:03:53 -04:00
Stefan Lankes 7cecfab386 add basic HermitCore support within libtest 2019-10-28 09:54:24 -04:00
Thomas Lively 62c3443e96 Re-enable Emscripten's exception handling support
Passes LLVM codegen and Emscripten link-time flags for exception
handling if and only if the panic strategy is `unwind`. Sets the
default panic strategy for Emscripten targets to `unwind`. Re-enables
tests that depend on unwinding support for Emscripten, including
`should_panic` tests.
2019-10-25 15:16:36 -07:00
Mazdak Farrokhzad 426c6cf84f Rollup merge of #64178 - mati865:clippy, r=scottmcm
More Clippy fixes for alloc, core and std

Continuation of https://github.com/rust-lang/rust/pull/63805
2019-10-23 22:19:07 +02:00
Lzu Tao 557cbd0fd5 Public some types for compiletest_rs 2019-10-23 03:49:42 +00:00
Mateusz Mikuła 95c06a2970 Apply clippy::needless_return suggestions 2019-10-22 19:23:10 +02:00
Igor Aleksanov ae04dc8473 Remove unneccessary use under cfg(unix) 2019-10-21 09:05:40 +03:00
Igor Aleksanov a06b205177 Add public re-exports for benches 2019-10-18 08:32:44 +03:00
Igor Aleksanov cb5733de86 Improve code style 2019-10-17 19:37:01 +03:00
Igor Aleksanov 85628e8063 Add more explaining comments to the code 2019-10-17 19:10:35 +03:00
Igor Aleksanov ddc6a5fd0e Split options parsing into several functions 2019-10-17 19:10:17 +03:00
Igor Aleksanov 12397e9dd5 Make enum usage explicit and fix tests 2019-10-17 17:47:03 +03:00
Igor Aleksanov c951882c73 Extract ConsoleTestState 2019-10-17 17:38:44 +03:00
Igor Aleksanov 4d5052203d Split libtest into several smaller modules 2019-10-17 17:38:44 +03:00
Thomas Lively 2bf59bea48 Upgrade Emscripten targets to use upstream LLVM backend
- Compatible with Emscripten 1.38.46-upstream or later upstream.
 - Refactors the Emscripten target spec to share code with other wasm
   targets.
 - Replaces the old incorrect wasm32 C call ABI with the correct one,
   preserving the old one as wasm32_bindgen_compat for wasm-bindgen
   compatibility.
 - Updates the varargs ABI used by Emscripten and deletes the old one.
 - Removes the obsolete wasm32-experimental-emscripten target.
 - Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.
2019-10-16 17:06:48 -07:00
bors 80b861bed1 Auto merge of #64873 - popzxc:prettify-test-time, r=wesleywiser
Enhance report-time option

## Short overview

This PR is a follow-up to a previously closed #64714 PR.

## Changes introduced by this PR

* `libtest` now retrieves the type of the test within `TestDesc` (available types are: `UnitTest`, `IntegrationTest`, `DocTest`, `Unknown`).
* `--report-time` subcommand of the `libtest` now supports colored output (disabled by default).
* Colorized output depends on the threshold values. Default values (proposed by @wesleywiser):
  - For unit-tests: 50ms warn/100ms critical,
  - For integration-tests: 500ms warn/1000ms critical,
  - For doctests: same as for integration tests,
  - For unknown tests: `TEST_WARN_TIMEOUT_S` warn/ `TEST_WARN_TIMEOUT_S * 2` critical (it will only applied single-threaded mode, because otherwise test will be interrupted after reaching `TEST_WARN_TIMEOUT_S`).
  - These values can be overrided by setting environment variables (since those thresholds are somewhat constant for every project, it's more flexible to use environment variables than command line arguments).
* New optional flag `--ensure-test-time` for `libtest`. With this flag applied, exectuion time limit excesss will cause test failure.

## What have not been done

There was a comment that it would be nice to have an entry in the Cargo book about it.

However, changes introduced by this PR (and #64663 in which `report-time` flag was added) aren't related directly to `cargo`, it's more about `libtest` itself.
I'm considering that [The Unstable Book](https://doc.rust-lang.org/unstable-book/) is more appropriate place, but not sure if I'm right (and if so, how exactly it should be described).

As one possible option, this PR may be merged without denoting it in the documentation, and in the next PR adding support of this feature to the `cargo` itself, I'll add a note in the Cargo book.

## Scope of this PR

Logical scope of this PR is `libtest` only. However, to get test types, I had to modify also `libsyntax_ext` and `librustdoc` for them to provide information about test type.

## Rationale

Rationale for colored output was submitted in #64714

Providing the information about kind of test was also proposed in #64714, and as an additional benefit this information may be useful for the tools using `libtest` (e.g. `cargo`).

Adding flag to treat time limits excess seems logical to me, so projects that do care about test execution time won't have to invent a wheel.

## Backward compatibility

All the changes are completely backward compatible.

## Demo

![rustc_enhanced_time](https://user-images.githubusercontent.com/12111581/65818381-c04f6800-e219-11e9-9875-322463abe24f.gif)

r? @wesleywiser
2019-10-12 23:47:27 +00:00
Igor Aleksanov 56077605fd Follow the styling guide 2019-10-09 10:29:20 +03:00
Igor Aleksanov 375a051f7f Make interface of the feature more convenient 2019-10-09 10:03:08 +03:00
Igor Aleksanov 8231f46a8f Resolve divergency with master 2019-10-09 09:52:08 +03:00
Tyler Mandry d16b7f705b Revert "Auto merge of #63649 - tlively:emscripten-upstream-upgrade, r=alexcrichton"
This reverts commit 7870050796, reversing
changes made to 2e7244807a.
2019-10-05 21:38:45 -07:00
Thomas Lively 5b56c660c9 Fix ABI, run and fix more tests, re-enable CI for PRs 2019-10-04 00:47:21 -07:00
Guillaume Gomez 70dcb99889 Remove rustdoc warning 2019-10-02 14:24:59 +02:00
Igor Aleksanov f2b84788fb libtest: encapsulate time-related logic and avoid unnecessary allocations 2019-09-29 21:22:30 +03:00
Igor Aleksanov 75a297573f Enhance report-time option 2019-09-29 21:22:30 +03:00
Tyler Mandry 8ae1ec60cc Spawn one subprocess per unit test when panic=abort 2019-09-28 13:52:18 -07:00
Kenny Goodin 821ff46878 Include message on tests that should panic 2019-09-26 19:39:59 -04:00
Jakob Schikowski d91b965664 libtest: Make --report-time an unstable option 2019-09-22 22:20:30 +02:00
Jakob Schikowski c16a547012 libtest: Add --report-time flag to print test execution time 2019-09-21 19:03:14 +02:00
Mazdak Farrokhzad 6d20265a9e Rollup merge of #62600 - emmericp:libtest-add-show-output, r=gnzlbg
libtest: add --show-output flag to print stdout of successful tests

This pull request adds a new flag `--show-output` for tests to show the output of successful tests. For most formatters this was already supported just not exposed via the CLI (apparently only used by `librustdoc`). I've also added support for this option in the JSON formatter.

This kind of fixes https://github.com/rust-lang/rust/issues/54669 which wants `--format json` to work with `--nocapture`, which is... well, impossible. What this issue really calls for is `--show-output` as implemented here.
2019-08-27 08:17:48 +02:00
Alex Crichton b47c9690d2 bootstrap: Merge the libtest build step with libstd
Since its inception rustbuild has always worked in three stages: one for
libstd, one for libtest, and one for rustc. These three stages were
architected around crates.io dependencies, where rustc wants to depend
on crates.io crates but said crates don't explicitly depend on libstd,
requiring a sysroot assembly step in the middle. This same logic was
applied for libtest where libtest wants to depend on crates.io crates
(`getopts`) but `getopts` didn't say that it depended on std, so it
needed `std` built ahead of time.

Lots of time has passed since the inception of rustbuild, however,
and we've since gotten to the point where even `std` itself is depending
on crates.io crates (albeit with some wonky configuration). This
commit applies the same logic to the two dependencies that the `test`
crate pulls in from crates.io, `getopts` and `unicode-width`. Over the
many years since rustbuild's inception `unicode-width` was the only
dependency picked up by the `test` crate, so the extra configuration
necessary to get crates building in this crate graph is unlikely to be
too much of a burden on developers.

After this patch it means that there are now only two build phasese of
rustbuild, one for libstd and one for rustc. The libtest/libproc_macro
build phase is all lumped into one now with `std`.

This was originally motivated by rust-lang/cargo#7216 where Cargo was
having to deal with synthesizing dependency edges but this commit makes
them explicit in this repository.
2019-08-23 16:46:11 -07:00
newpavlov 2ff1f45ead revert num_cpus change 2019-08-21 20:16:52 +03:00
Artyom Pavlov 82cb207607 fix num_cpus 2019-08-21 00:18:05 +00:00
Artyom Pavlov 40cb69da59 fix libtest 2019-08-21 00:15:11 +00:00