about summary refs log tree commit diff
path: root/src/librustdoc/doctest
AgeCommit message (Collapse)AuthorLines
2024-08-13Improve code readabilityGuillaume Gomez-0/+9
2024-08-13If there are crate attributes, we prevent doctest to be merged with othersGuillaume Gomez-27/+4
2024-08-13Rename `DocTest` into `DocTestBuilder`Guillaume Gomez-9/+14
2024-08-13Reduce merged doctest source code sizeGuillaume Gomez-25/+7
2024-08-13Add documentation on `DocTest` and `RunnableDoctest` structsGuillaume Gomez-0/+2
2024-08-13Improve code by removing unneeded function argumentsGuillaume Gomez-2/+0
2024-08-13Correctly handle macros using `$crate` in merged doctestsGuillaume Gomez-3/+14
2024-08-13If no argument is provided to merged doctests binary, they will be run in ↵Guillaume Gomez-6/+4
the same process (needed for miri)
2024-08-13Correctly handle `internal_features` attributeGuillaume Gomez-1/+13
2024-08-13Don't change indent in merged doctestsGuillaume Gomez-1/+1
2024-08-13Make merged doctests run in their own processGuillaume Gomez-15/+81
2024-08-13Fix weird memory allocation failure in merged doctests by storing doctest ↵Guillaume Gomez-8/+8
list into a const
2024-08-13Don't merge doctests with `#[global_allocator]`Guillaume Gomez-75/+70
2024-08-13Greatly improve handling of doctests attributes, making it possible to merge ↵Guillaume Gomez-45/+112
doctests more efficiently
2024-08-13Simplify `has_main_fn` to be a boolean instead of a `Option<Span>`Guillaume Gomez-29/+31
2024-08-13Correctly handle doctests with invalid ASTGuillaume Gomez-4/+17
2024-08-13If there is any AST error with a doctest, we make it a standalone testGuillaume Gomez-88/+182
To do so, AST error detection was improved in order to not filter out too many doctests.
2024-08-13Prevent merged doctests to break stdin if the generated file is too bigGuillaume Gomez-3/+8
2024-08-13Split doctests into two categories: mergeable ones and standalone onesGuillaume Gomez-22/+56
2024-08-13Split standalone and mergeable doctestsGuillaume Gomez-19/+208
2024-08-13Split doctests between standalone and mergeable onesGuillaume Gomez-6/+4
2024-08-13Simplify doctest testsGuillaume Gomez-27/+24
2024-08-13Add `DocTest` typeGuillaume Gomez-130/+181
2024-08-13Clean up rustdoc make_test function codeGuillaume Gomez-21/+21
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+6
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-1/+1
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-09rustdoc: Add support for --remap-path-prefixEdward Shen-5/+7
Adds --remap-path-prefix as an unstable option. This is implemented to mimic the behavior of rustc's --remap-path-prefix but with minor adjustments. This flag similarly takes in two paths, a prefix to replace and a replacement string.
2024-06-07run fmtGuillaume Gomez-18/+16
2024-06-07Fix broken rustdoc unit testsNoah Lev-22/+37
2024-06-07Parse full doctest source; extract helper for parsing codeNoah Lev-90/+104
It doesn't really make sense to skip part of the source when we're parsing it, so parse the whole doctest. This simplifies things too.
2024-06-07Move logic for "making" doctests to submoduleNoah Lev-0/+381
This code turns the raw code given by the user into something actually runnable, e.g. by adding a `main` function if it doesn't already exist. I also made a couple other items private that didn't need to be crate-public.
2024-06-07Move some arguments to fields and reorganize fieldsNoah Lev-12/+14
I moved some local arguments and options to either the local options struct or, if it made sense, the global options struct.
2024-06-07rustdoc: Remove `DoctestVisitor::get_line`Noah Lev-14/+13
This was used to get the line number of the first line from the current docstring, which was then used together with an offset within the docstring. It's simpler to just pass the offset to the visitor and have it do the math because it's clearer and this calculation only needs to be done in one place (the Rust doctest visitor).
2024-06-07Merge `RustDoctest` and `MdDoctest` into one typeNoah Lev-23/+7
2024-06-07rustdoc: Extract actual doctest running logic into functionNoah Lev-3/+9
2024-06-07Separate doctest collection from runningNoah Lev-42/+201
2024-06-07Move Markdown-specific doctest code into submoduleNoah Lev-0/+46
2024-06-07Start moving format-specific code into doctest submoduleNoah Lev-0/+127
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.