648 Commits

Author SHA1 Message Date
Yuki Okushi
8e17c8366c
Rollup merge of #69802 - matthiaskrgr:cl1ppy, r=Dylan-DPC
fix more clippy findings

* reduce references on match patterns (clippy::match_ref_pats)
* Use writeln!(fmt, "word") instead of write!(fmt, "word\n") (clippy::write_with_newline)
* libtest: remove redundant argument to writeln!() (clippy::writeln_empty_string)
* remove unneeded mutable references (cippy::unnecessary_mut_passed)
* libtest: declare variables as floats instead of casting them (clippy::unnecessary_cast)
* rustdoc: remove redundant static lifetimes (clippy::redundant_static_lifetimes)
* call .as_deref() instead of .as_ref().map(Deref::deref) (clippy::option_as_ref_deref)
* iterate over a maps values directly. (clippy::for_kv_map)
* rustdoc: simplify boolean condition (clippy::nonminimal_bool)
* Use ?-operator in more places (clippy::question_mark, had some false negatives fixed recently)
* rustdoc: Use .any(p) instead of find(p).is_some(). (clippy::search_is_some)
* rustdoc: don't call into_iter() on iterator. (clippy::identity_conversion)
2020-03-14 04:03:24 +09:00
Matthias Krüger
8351138370 reduce references on match patterns (clippy::match_ref_pats) 2020-03-07 21:48:17 +01:00
Matthias Krüger
3f87f8cfee Use writeln!(fmt, "word") instead of write!(fmt, "word\n") (clippy::write_with_newline) 2020-03-07 21:48:17 +01:00
Matthias Krüger
f326f0f70f libtest: remove redundant argument to writeln!() (clippy::writeln_empty_string) 2020-03-07 21:48:17 +01:00
Matthias Krüger
cca3d52160 libtest: declare variables as floats instead of casting them (clippy::unnecessary_cast) 2020-03-07 21:48:17 +01:00
Matthias Krüger
136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
Matthias Krüger
a1c3eb6043 Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call) 2020-03-05 16:39:20 +01:00
Matthias Krüger
c2bbe3349f Const items have by default a static lifetime, there's no need to annotate it. (clippy::redundant_static_lifetimes) 2020-03-05 16:38:24 +01:00
Yuki Okushi
680a0e1dd5
Rollup merge of #69580 - matthiaskrgr:map_clone, r=Centril
use .copied() instead of .map(|x| *x) on iterators
2020-03-01 19:28:12 +09:00
Vadim Petrochenkov
6054a30370 Make it build again 2020-02-29 20:47:10 +03:00
Matthias Krüger
c9a02c2e42 use .copied() instead of .map(|x| *x) on iterators 2020-02-29 15:23:13 +01:00
Matthias Krüger
9523c89f18 use is_empty() instead of len() == x to determine if structs are empty. 2020-02-28 15:16:27 +01:00
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 7870050796e5904a0fc85ecbe6fa6dde1cfe0c91, reversing
changes made to 2e7244807a7878f6eca3eb7d97ae9b413aa49014.
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