about summary refs log tree commit diff
path: root/src/librustdoc/doctest/tests.rs
AgeCommit message (Collapse)AuthorLines
2025-06-11Update extracted-doctest feature documentationGuillaume Gomez-0/+1
2025-06-10Add more tests to check extracted doctests featureGuillaume Gomez-3/+55
2025-06-10Give more information into extracted doctest informationGuillaume Gomez-2/+2
2025-05-22Collect and use `#![doc(test(attr(..)))]` at module level tooUrgau-29/+39
2025-05-22Auto merge of #140527 - GuillaumeGomez:doctest-main-fn, r=notriddlebors-11/+9
Emit a warning if the doctest `main` function will not be run Fixes #140310. I think we could try to go much further like adding a "link" (ie UI annotations) on the `main` function in the doctest. However that will require some more computation, not sure if it's worth it or not. Can still be done in a follow-up if we want it. For now, this PR does two things: 1. Pass the `DiagCtxt` to the doctest parser to emit the warning. 2. Correctly generate the `Span` to where the doctest is starting (I hope the way I did it isn't too bad either...). cc `@fmease` r? `@notriddle`
2025-05-02Create a builder for DocTestBuilder typeGuillaume Gomez-14/+9
2025-05-02Emit a warning if the doctest `main` function will not be runGuillaume Gomez-0/+3
2025-04-15Replace flag `--doctest-compilation-args` with a simpler one: ↵León Orell Valerian Liehr-22/+0
`--doctest-build-arg` More notably, the value of the new flag does *not* get lexed shell-like and ad hoc.
2025-03-27Only take outer attributes into account when generating content between ↵Guillaume Gomez-117/+14
first non-crate items and the crate items
2025-03-27Add new regression test for doctestGuillaume Gomez-0/+131
2025-03-27Improve comment and test for generated doctest with code commentsGuillaume Gomez-1/+23
2025-03-27Correctly handle line comments in attributes and generate extern cratesGuillaume Gomez-3/+27
outside of wrapping function
2025-03-27Correctly handle `fn main` in macroGuillaume Gomez-5/+5
2025-02-28Fully qualify `Result` in generated doctest codeGuillaume Gomez-1/+1
2024-12-20Move test into the `tests.rs` fileGuillaume Gomez-0/+22
2024-08-13Run fmtGuillaume Gomez-1/+2
2024-08-13Improve code readabilityGuillaume Gomez-0/+1
2024-08-13Rename `DocTest` into `DocTestBuilder`Guillaume Gomez-3/+8
2024-08-13Correctly handle doctests with invalid ASTGuillaume Gomez-1/+1
2024-08-13Split doctests into two categories: mergeable ones and standalone onesGuillaume Gomez-2/+3
2024-08-13Split doctests between standalone and mergeable onesGuillaume Gomez-1/+1
2024-08-13Simplify doctest testsGuillaume Gomez-27/+24
2024-08-13Add `DocTest` typeGuillaume Gomez-2/+16
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-07Fix broken rustdoc unit testsNoah Lev-22/+37
2024-02-15add extra indent spaces for rust-playground linkyukang-1/+43
2023-04-25pass `unused_extern_crates` in `librustdoc::doctest::make_test`ozkanonur-0/+4
Signed-off-by: ozkanonur <work@onurozkan.dev>
2021-12-12Rename `TestOptions` to `GlobalTestOptions`Noah Lev-17/+17
It seems to apply to all doctests in the crate.
2021-11-26Remove `--display-doctest-warnings`Joshua Nelson-16/+1
This can be replicated in full with other existing features, there's no need to have a separate option for it. This also fixes a bug where `--test-args=--show-output` had no effect, and updates the documentation.
2021-09-14Rename --display-warnings to --display-doctest-warningsGuillaume Gomez-3/+4
2021-02-11Fix injected errors when running doctests on a crate named after a keywordJoshua Nelson-4/+4
Unfortunately, this can't currently be tested. The problem is that we need the file to be compiled first to then be used as dependency, which cannot be done currently unfortunately in the rustdoc test suites. Example: ```rust // name this file "foo.rs" /// ``` /// let x = foo::foo(); /// ``` pub fn foo() {} ``` If you run `rustdoc --test foo.rs`, you'll get: ``` running 1 test test foo.rs - foo (line 1) ... FAILED failures: ---- foo.rs - foo (line 1) stdout ---- error[E0463]: can't find crate for `foo` --> foo.rs:0:1 | 2 | extern crate foo; | ^^^^^^^^^^^^^^^^^ can't find crate ``` If a test were possible, it would look something like ````rust #![crate_name = "mod"] #![crate_type = "lib"] //! ``` //! // NOTE: requires that the literal string 'mod' appears in the doctest for //! // the bug to appear //! assert_eq!(1, 1); //! ``` ````
2020-12-29Remove unnecessary semicolon from Rustdoc-generated codeAaron Hill-2/+2
2020-12-20add an attribute to inner doctest fnArpad Borsos-3/+3
2020-12-19Remap instrument-coverage line numbers in doctestsArpad Borsos-17/+52
This uses the `SourceMap::doctest_offset_line` method to re-map line numbers from doctests. Remapping columns is not yet done. Part of issue #79417.
2020-11-17Update doctest testsGuillaume Gomez-34/+34
2020-08-27Rename rustdoc/test -> rustdoc/doctestAleksey Kladov-0/+279
This modules contains the implementation of doctests, and not the tests of rustdoc itself. This name is confusing, so let's rename it to doctest for clarity.