about summary refs log tree commit diff
path: root/library/test/src
AgeCommit message (Collapse)AuthorLines
2021-10-07Rollup merge of #89082 - smoelius:master, r=kennytmJubilee-39/+276
Implement #85440 (Random test ordering) This PR adds `--shuffle` and `--shuffle-seed` options to `libtest`. The options are similar to the [`-shuffle` option](https://github.com/golang/go/blob/c894b442d1e5e150ad33fa3ce13dbfab1c037b3a/src/testing/testing.go#L1482-L1499) that was recently added to Go. Here are the relevant parts of the help message: ``` --shuffle Run tests in random order --shuffle-seed SEED Run tests in random order; seed the random number generator with SEED ... By default, the tests are run in alphabetical order. Use --shuffle or set RUST_TEST_SHUFFLE to run the tests in random order. Pass the generated "shuffle seed" to --shuffle-seed (or set RUST_TEST_SHUFFLE_SEED) to run the tests in the same order again. Note that --shuffle and --shuffle-seed do not affect whether the tests are run in parallel. ``` Is an RFC needed for this?
2021-10-06Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-seManish Goregaokar-2/+2
Rename `std::thread::available_conccurrency` to `std::thread::available_parallelism` _Tracking issue: https://github.com/rust-lang/rust/issues/74479_ This PR renames `std::thread::available_conccurrency` to `std::thread::available_parallelism`. ## Rationale The API was initially named `std::thread::hardware_concurrency`, mirroring the [C++ API of the same name](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency). We eventually decided to omit any reference to the word "hardware" after [this comment](https://github.com/rust-lang/rust/pull/74480#issuecomment-662045841). And so we ended up with `available_concurrency` instead. --- For a talk I was preparing this week I was reading through ["Understanding and expressing scalable concurrency" (A. Turon, 2013)](http://aturon.github.io/academic/turon-thesis.pdf), and the following passage stood out to me (emphasis mine): > __Concurrency is a system-structuring mechanism.__ An interactive system that deals with disparate asynchronous events is naturally structured by division into concurrent threads with disparate responsibilities. Doing so creates a better fit between problem and solution, and can also decrease the average latency of the system by preventing long-running computations from obstructing quicker ones. > __Parallelism is a resource.__ A given machine provides a certain capacity for parallelism, i.e., a bound on the number of computations it can perform simultaneously. The goal is to maximize throughput by intelligently using this resource. For interactive systems, parallelism can decrease latency as well. _Chapter 2.1: Concurrency is not Parallelism. Page 30._ --- _"Concurrency is a system-structuring mechanism. Parallelism is a resource."_ — It feels like this accurately captures the way we should be thinking about these APIs. What this API returns is not "the amount of concurrency available to the program" which is a property of the program, and thus even with just a single thread is effectively unbounded. But instead it returns "the amount of _parallelism_ available to the program", which is a resource hard-constrained by the machine's capacity (and can be further restricted by e.g. operating systems). That's why I'd like to propose we rename this API from `available_concurrency` to `available_parallelism`. This still meets the criteria we previously established of not attempting to define what exactly we mean by "hardware", "threads", and other such words. Instead we only talk about "concurrency" as an abstract resource available to our program. r? `@joshtriplett`
2021-09-30Check `allow_unstable` before checking environment variablesSamuel E. Moelius III-2/+2
2021-09-29Add testsSamuel E. Moelius III-25/+92
2021-09-29Implement #85440Samuel E. Moelius III-14/+184
2021-09-28Rename `std::thread::available_onccurrency` to ↵Yoshua Wuyts-2/+2
`std::thread::available_parallelism`
2021-09-27Apply suggestions from code reviewJane Lusby-2/+2
Co-authored-by: kennytm <kennytm@gmail.com>
2021-09-24make junit output more consistent with default formatJane Lusby-1/+4
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-1/+1
2021-09-09Ignore automatically derived impls of `Clone` and `Debug` in dead code analysisFabian Wolff-0/+1
2021-07-18Remove unused stuff and switch to pub(crate) whenever possible.Charles Lew-299/+58
2021-07-18Fix compilation errors.Charles Lew-30/+13
2021-07-18Move `library/term/src` to `library/test/src/term/`.Charles Lew-0/+1788
2021-06-28Update to new bootstrap compilerMark Rousskov-46/+0
2021-06-23Use HTTPS links where possibleSmitty-1/+1
2021-06-17Use as_secs_f64 in JunitFormatterDeadbeef-4/+4
2021-06-06Auto merge of #84863 - ABouttefeux:libtest, r=m-ou-sebors-2/+120
Show test type during prints Test output can sometimes be confusing. For example doctest with the no_run argument are displayed the same way than test that are run. During #83857 I got the feedback that test output can be confusing. For the moment test output is ``` test $DIR/test-type.rs - f (line 12) ... ignored test $DIR/test-type.rs - f (line 15) ... ok test $DIR/test-type.rs - f (line 21) ... ok test $DIR/test-type.rs - f (line 6) ... ok ``` I propose to change output by indicating the test type as ``` test $DIR/test-type.rs - f (line 12) ... ignored test $DIR/test-type.rs - f (line 15) - compile ... ok test $DIR/test-type.rs - f (line 21) - compile fail ... ok test $DIR/test-type.rs - f (line 6) ... ok ``` by indicating the test type after the test name (and in the case of doctest after the function name and line) and before the "...". ------------ Note: this is a proof of concept, the implementation is probably not optimal as the properties added in `TestDesc` are only use in the display and does not represent actual change of behavior, maybe `TestType::DocTest` could have fields
2021-06-04rustdoc: link to stable/beta docs consistently in documentationJoshua Nelson-1/+1
## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel
2021-05-27Auto merge of #84568 - andoriyu:libtest/junit_formatter, r=yaahcbors-5/+190
feat(libtest): Add JUnit formatter tracking issue: https://github.com/rust-lang/rust/issues/85563 Add an alternative formatter to `libtest`. Formatter produces valid xml that later can be interpreted as JUnit report. Caveats: - `timestamp` is required by schema, but every viewer/parser ignores it. Attribute is not set to avoid depending on chrono; - Running all "suits" (unit tests, doc-tests and integration tests) will produce a mess; - I couldn't find a way to get integration test binary name, so it's just goes by "integration"; Sample output for unit tests (pretty printed by 3rd party tool): ``` <?xml version="1.0" encoding="UTF-8"?> <testsuites> <testsuite name="test" package="test" id="0" errors="0" failures="0" tests="13" skipped="1"> <testcase classname="results::tests" name="test_completed_bad" time="0"/> <testcase classname="results::tests" name="suite_started" time="0"/> <testcase classname="results::tests" name="suite_ended_ok" time="0"/> <testcase classname="results::tests" name="suite_ended_bad" time="0"/> <testcase classname="junit::tests" name="test_failed_output" time="0"/> <testcase classname="junit::tests" name="test_simple_output" time="0"/> <testcase classname="junit::tests" name="test_multiple_outputs" time="0"/> <testcase classname="results::tests" name="test_completed_ok" time="0"/> <testcase classname="results::tests" name="test_stared" time="0"/> <testcase classname="junit::tests" name="test_generate_xml_no_error_single_testsuite" time="0"/> <testcase classname="results::tests" name="test_simple_output" time="0"/> <testcase classname="test" name="should_panic" time="0"/> <system-out/> <system-err/> </testsuite> </testsuites> ``` Sample output for integration tests (pretty printed by 3rd party tool): ``` <?xml version="1.0" encoding="UTF-8"?> <testsuites> <testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0"> <testcase classname="integration" name="test_add" time="0"/> <system-out/> <system-err/> </testsuite> </testsuites> ``` Sample output for Doc-tests (pretty printed by 3rd party tool): ``` <?xml version="1.0" encoding="UTF-8"?> <testsuites> <testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0"> <testcase classname="src/lib.rs" name="(line 2)" time="0"/> <system-out/> <system-err/> </testsuite> </testsuites> ```
2021-05-18change based on reviewAliénore Bouttefeux-17/+17
2021-05-16remove mode for run and ignore testsAliénore Bouttefeux-4/+14
2021-05-14Expose `Concurrent` (private type in public i'face)Alan Egerton-1/+1
2021-05-09add bootstrap cfgAliénore Bouttefeux-3/+49
2021-05-03change based on reviewAliénore Bouttefeux-10/+10
2021-05-03proof of concept add test type on printsAliénore Bouttefeux-2/+64
2021-04-30Better output for junit formatterAndrey Cherkashin-12/+52
2021-04-26Update junit.rsAndrey Cherkashin-1/+1
2021-04-25feat(libtest): Add JUnit formatterAndrey Cherkashin-5/+150
2021-04-25move core::hint::black_box under its own feature gateRalf Jung-2/+10
2021-04-12Auto merge of #82300 - andersk:libtest-id, r=Amanieubors-41/+75
libtest: Index tests by a unique TestId This more robustly avoids problems with duplicate `TestDesc`. See #81852 and #82274. Cc `@Mark-Simulacrum.`
2021-03-27lazily calls some fnsklensy-1/+1
2021-03-24libtest: Index tests by a unique TestIdAnders Kaseorg-41/+75
This more robustly avoids problems with duplicate TestDesc. See #81852 and #82274. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2021-03-14Remove Option::{unwrap_none, expect_none}.Mara Bos-3/+3
2021-02-28Auto merge of #82350 - ehuss:test-chapter, r=jyn514bors-8/+2
Add a chapter on the test harness. There isn't really any online documentation on the test harness, so this adds a chapter to the rustc book which provides information on how the harness works and details on the command-line options.
2021-02-26Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-seGuillaume Gomez-1/+0
Stabilize str_split_once Closes #74773
2021-02-21Rollup merge of #82349 - tmiasko:pretty-test-timeout, r=Mark-SimulacrumYuki Okushi-4/+0
test: Print test name only once on timeout Pretty formatter when using multiple test threads displays test name twice on timeout event. This implicitly suggest that those are two different events, while in fact they are always printed together. Print test name only once. Before: ``` running 3 tests test src/lib.rs - c (line 16) ... ok test src/lib.rs - a (line 3) ... ok test src/lib.rs - b (line 9) ... test src/lib.rs - b (line 9) has been running for over 60 seconds test src/lib.rs - b (line 9) ... ok ``` After: ``` running 3 tests test src/lib.rs - c (line 16) ... ok test src/lib.rs - a (line 3) ... ok test src/lib.rs - b (line 9) has been running for over 60 seconds test src/lib.rs - b (line 9) ... ok ```
2021-02-20Add a chapter on the test harness.Eric Huss-8/+2
2021-02-21test: Print test name only once on timeoutTomasz Miąsko-4/+0
Pretty formatter when using multiple test threads displays test name twice on timeout event. This implicitly suggest that those are two different events, while in fact they are always printed together. Print test name only once. Before: ``` running 3 tests test src/lib.rs - c (line 16) ... ok test src/lib.rs - a (line 3) ... ok test src/lib.rs - b (line 9) ... test src/lib.rs - b (line 9) has been running for over 60 seconds test src/lib.rs - b (line 9) ... ok ``` After: ``` running 3 tests test src/lib.rs - c (line 16) ... ok test src/lib.rs - a (line 3) ... ok test src/lib.rs - b (line 9) has been running for over 60 seconds test src/lib.rs - b (line 9) ... ok ```
2021-02-19Rollup merge of #82274 - andersk:test-unwrap, r=Mark-SimulacrumDylan DPC-6/+7
libtest: Fix unwrap panic on duplicate TestDesc It is possible for different tests to collide to the same `TestDesc` when macros are involved. That is a bug, but it didn’t cause a panic until #81367. For now, change the code to ignore this problem. Fixes #81852. This will need to be applied to `beta` too.
2021-02-19Remove unsafe impl Send for CompletedTest & TestResultTomasz Miąsko-4/+0
2021-02-18libtest: Fix unwrap panic on duplicate TestDesc.Anders Kaseorg-6/+7
It is possible for different tests to collide to the same TestDesc when macros are involved. That is a bug, but it didn’t cause a panic until #81367. For now, change the code to ignore this problem. Fixes #81852. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2021-02-18Rollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-SimulacrumDylan DPC-1/+12
[libtest] Run the test synchronously when hitting thread limit libtest currently panics if it hits the thread limit. This often results in spurious test failures (<code>thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }'</code> ... `error: test failed, to rerun pass '--lib'`). This PR makes it continue to run the test synchronously if it runs out of threads. Closes #78165. ``@rustbot`` label: A-libtest T-libs
2021-02-17[libtest] Run the test synchronously when hitting thread limithyd-dev-1/+12
2021-02-09Stabilize str_split_onceJacob Pratt-1/+0
2021-02-08Rollup merge of #81356 - ehuss:libtest-filters, r=m-ou-seMara Bos-22/+34
libtest: allow multiple filters Libtest ignores any filters after the first. This changes it so that if multiple filters are passed, it will test against all of them. This also affects compiletest to do the same. Closes #30422
2021-02-07Auto merge of #81821 - nikic:update-wasm32, r=sanxiynbors-1/+1
Upgrade wasm32 image to Ubuntu 20.04 This switches the wasm32 image, which is used to test wasm32-unknown-emscripten, to Ubuntu 20.04. While at it, enable most of the excluded tests, as they seem to work fine with some minor fixes.
2021-02-06Upgrade wasm32 image to Ubuntu 20.04Nikita Popov-1/+1
This switches the wasm32 image, which is used to test wasm32-unknown-emscripten to Ubuntu 20.04. While at it, enable most of the excluded tests, as they seem to work fine with some minor fixes.
2021-02-03Allow/fix non_fmt_panic in tests.Mara Bos-1/+1
2021-01-31Rollup merge of #80053 - gilescope:include-ignore, r=m-ou-seJonas Schievink-7/+2
stabilise `cargo test -- --include-ignored` stabilise `cargo test -- --include-ignored` On stable there's no way to run ignored tests as well as the normal tests. An example use case where stabilising this would help: Exercism has some initial tests and then some additional ignored tests that people run currently with --ignore but currently they can't run all the tests in one go without being on nightly. It would be a little more ergonomic if this flag was stablilised. ( Fixes #65770 ) I built with ./x.py build -i library/test - but as libtest is a dylib is there an easy way to invoke it manually to check it's working as expected? (I've updated the automated tests.)
2021-01-28Rollup merge of #80868 - johanngan:should-panic-msg-with-expected, r=m-ou-seYuki Okushi-16/+25
Print failure message on all tests that should panic, but don't Fixes #80861. Tests with the `#[should_panic]` attribute should always print a failure message if no panic occurs, regardless of whether or not an `expected` panic message is specified.