mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #95836 - workingjubilee:doctest-exe, r=notriddle
Use `rust_out{exe_suffix}` for doctests This was mentioned as an issue to me by ````@bruxisma.```` There are 3 separate instances where "rust_out" can become part of the name of a Rust executable, so I am mostly just hoping that this fixes the problem, given that the other sites which it can slip in seem to be well-behaved.
This commit is contained in:
commit
7ce937fe4a
@ -19,7 +19,7 @@ use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP};
|
||||
use rustc_target::spec::TargetTriple;
|
||||
use rustc_target::spec::{Target, TargetTriple};
|
||||
use tempfile::Builder as TempFileBuilder;
|
||||
|
||||
use std::env;
|
||||
@ -293,6 +293,16 @@ struct UnusedExterns {
|
||||
unused_extern_names: Vec<String>,
|
||||
}
|
||||
|
||||
fn add_exe_suffix(input: String, target: &TargetTriple) -> String {
|
||||
let exe_suffix = match target {
|
||||
TargetTriple::TargetTriple(_) => Target::expect_builtin(target).options.exe_suffix,
|
||||
TargetTriple::TargetJson { contents, .. } => {
|
||||
Target::from_json(contents.parse().unwrap()).unwrap().0.options.exe_suffix
|
||||
}
|
||||
};
|
||||
input + &exe_suffix
|
||||
}
|
||||
|
||||
fn run_test(
|
||||
test: &str,
|
||||
crate_name: &str,
|
||||
@ -313,7 +323,9 @@ fn run_test(
|
||||
let (test, line_offset, supports_color) =
|
||||
make_test(test, Some(crate_name), lang_string.test_harness, opts, edition, Some(test_id));
|
||||
|
||||
let output_file = outdir.path().join("rust_out");
|
||||
// Make sure we emit well-formed executable names for our target.
|
||||
let rust_out = add_exe_suffix("rust_out".to_owned(), &target);
|
||||
let output_file = outdir.path().join(rust_out);
|
||||
|
||||
let rustc_binary = rustdoc_options
|
||||
.test_builder
|
||||
|
@ -132,7 +132,7 @@ include clear_expected_if_blessed
|
||||
--instr-profile="$(TMPDIR)"/$@.profdata \
|
||||
$(call BIN,"$(TMPDIR)"/$@) \
|
||||
$$( \
|
||||
for file in $(TMPDIR)/rustdoc-$@/*/rust_out; do \
|
||||
for file in $(TMPDIR)/rustdoc-$@/*/rust_out*; do \
|
||||
[ -x "$$file" ] && printf "%s %s " -object $$file; \
|
||||
done \
|
||||
) \
|
||||
|
Loading…
Reference in New Issue
Block a user