mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 05:26:47 +00:00
Auto merge of #88269 - prconrad:doctest-persist-binaries, r=jyn514
Doctest persist full binaries when persisting Tested by adding an extra debug to echo the whole compiler line. Trimmed significantly: Persisted but not running -> full compile so we get binaries (new behavior). ``` $ rustdoc -Zunstable-options --test --persist-doctests doctests --no-run --extern t=libt.rlib t.rs DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_8_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always" DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_2_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always" test t.rs - foople (line 2) - compile ... ok test t.rs - florp (line 8) - compile ... ok ``` Persisted and running -> full compile. ``` $ rustdoc -Zunstable-options --test --persist-doctests doctests --extern t=libt.rlib t.rs DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_8_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always" DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "doctests/t_rs_2_0/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--target" "x86_64-unknown-linux-gnu" "--color" "always" ``` Running but not persisted -> full compile only ``` $ rustdoc --test --extern t=libt.rlib t.rs DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctestixWAUI/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "--target" "x86_64-unknown-linux-gnu" "--color" "always" DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctestKEaJQu/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "--target" "x86_64-unknown-linux-gnu" "--color" "always" ``` Not running and not persisting -> save time and only run metadata. ``` RUSTDOC_LOG=rustdoc=debug,std::test=debug rustdoc -Zunstable-options --no-run --test --extern t=libt.rlib t.rs DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctest8twt2c/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--emit=metadata" "--target" "x86_64-unknown-linux-gnu" "--color" "always" DEBUG rustdoc::doctest run_test compiler "rustc" "--crate-type" "bin" "--edition" "2015" "-o" "/tmp/rustdoctest3miSqv/rust_out" "--extern" "t=libt.rlib" "-Ccodegen-units=1" "-Z" "unstable-options" "--emit=metadata" "--target" "x86_64-unknown-linux-gnu" "--color" "always" ``` I can't see any infrastructure for automating this sort of test. Am I missing it?
This commit is contained in:
commit
ad3407f482
@ -361,7 +361,7 @@ fn run_test(
|
||||
for debugging_option_str in &options.debugging_opts_strs {
|
||||
compiler.arg("-Z").arg(&debugging_option_str);
|
||||
}
|
||||
if no_run && !compile_fail {
|
||||
if no_run && !compile_fail && options.persist_doctests.is_none() {
|
||||
compiler.arg("--emit=metadata");
|
||||
}
|
||||
compiler.arg("--target").arg(match target {
|
||||
|
21
src/test/run-make-fulldeps/doctests-keep-binaries/Makefile
Normal file
21
src/test/run-make-fulldeps/doctests-keep-binaries/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
include ../../run-make-fulldeps/tools.mk
|
||||
|
||||
# Check that valid binaries are persisted by running them, regardless of whether the --run or --no-run option is used.
|
||||
|
||||
all: run no_run
|
||||
|
||||
run:
|
||||
mkdir -p $(TMPDIR)/doctests
|
||||
$(RUSTC) --crate-type rlib t.rs
|
||||
$(RUSTDOC) -Zunstable-options --test --persist-doctests $(TMPDIR)/doctests --extern t=$(TMPDIR)/libt.rlib t.rs
|
||||
$(TMPDIR)/doctests/t_rs_2_0/rust_out
|
||||
$(TMPDIR)/doctests/t_rs_8_0/rust_out
|
||||
rm -rf $(TMPDIR)/doctests
|
||||
|
||||
no_run:
|
||||
mkdir -p $(TMPDIR)/doctests
|
||||
$(RUSTC) --crate-type rlib t.rs
|
||||
$(RUSTDOC) -Zunstable-options --test --persist-doctests $(TMPDIR)/doctests --extern t=$(TMPDIR)/libt.rlib t.rs --no-run
|
||||
$(TMPDIR)/doctests/t_rs_2_0/rust_out
|
||||
$(TMPDIR)/doctests/t_rs_8_0/rust_out
|
||||
rm -rf $(TMPDIR)/doctests
|
11
src/test/run-make-fulldeps/doctests-keep-binaries/t.rs
Normal file
11
src/test/run-make-fulldeps/doctests-keep-binaries/t.rs
Normal file
@ -0,0 +1,11 @@
|
||||
/// Fungle the foople.
|
||||
/// ```
|
||||
/// t::foople();
|
||||
/// ```
|
||||
pub fn foople() {}
|
||||
|
||||
/// Flomble the florp
|
||||
/// ```
|
||||
/// t::florp();
|
||||
/// ```
|
||||
pub fn florp() {}
|
Loading…
Reference in New Issue
Block a user