Skip to content

Commit

Permalink
Merge #203
Browse files Browse the repository at this point in the history
203: Fix "File name or extension is too long" error when merging profile data on Windows r=taiki-e a=messense

See https://github.com/PyO3/pyo3/runs/7682300607?check_suite_focus=true

> (never executed): The filename or extension is too long. (os error 206)

Switched to use [`-f`](https://llvm.org/docs/CommandGuide/llvm-profdata.html#cmdoption-llvm-profdata-merge-input-files) to pass input files by a temp file.

Co-authored-by: messense <[email protected]>
  • Loading branch information
bors[bot] and messense authored Aug 6, 2022
2 parents 3c74b7e + bbdf1ab commit f7870c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ serde = { version = "1.0.103", features = ["derive"] }
serde_json = "1"
shell-escape = "0.1.5"
target-spec = "1"
tempfile = "3"
termcolor = "1.1.2"
walkdir = "2.2.3"

Expand All @@ -49,4 +50,3 @@ easy-ext = "1"
itertools = "0.10"
once_cell = "1"
rustversion = "1"
tempfile = "3"
17 changes: 12 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::{
collections::HashMap,
ffi::{OsStr, OsString},
fmt::Write as _,
io,
io::{self, Write},
path::Path,
};

Expand Down Expand Up @@ -509,12 +509,19 @@ fn open_report(cx: &Context, path: &Utf8Path) -> Result<()> {

fn merge_profraw(cx: &Context) -> Result<()> {
// Convert raw profile data.
let profraw_files =
glob::glob(cx.ws.target_dir.join(format!("{}-*.profraw", cx.ws.name)).as_str())?
.filter_map(Result::ok);
let mut input_files = tempfile::NamedTempFile::new()?;
for path in profraw_files {
let path_str =
path.to_str().with_context(|| format!("{:?} contains invalid utf-8 data", path))?;
writeln!(input_files, "{}", path_str)?;
}
let mut cmd = cx.process(&cx.llvm_profdata);
cmd.args(["merge", "-sparse"])
.args(
glob::glob(cx.ws.target_dir.join(format!("{}-*.profraw", cx.ws.name)).as_str())?
.filter_map(Result::ok),
)
.arg("-f")
.arg(input_files.path())
.arg("-o")
.arg(&cx.ws.profdata_file);
if let Some(mode) = &cx.cov.failure_mode {
Expand Down

0 comments on commit f7870c5

Please sign in to comment.