Skip to content

Commit

Permalink
Merge #238
Browse files Browse the repository at this point in the history
238: Address target directory change in trybuild 1.0.76 r=taiki-e a=taiki-e

See dtolnay/trybuild#219

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored Jan 15, 2023
2 parents d154ca4 + 58a702a commit 3874e78
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Support `trybuild` 1.0.76+. ([#238](https://github.com/taiki-e/cargo-llvm-cov/pull/238))

## [0.5.8] - 2023-01-15

- Fix handling of cases where the target directory contains glob characters.
Expand Down
15 changes: 15 additions & 0 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ impl Workspace {
.trim()
.into())
}

pub(crate) fn trybuild_target(&self) -> Utf8PathBuf {
let mut trybuild_dir = self.metadata.target_directory.join("tests/trybuild");
if !trybuild_dir.is_dir() {
trybuild_dir = self.metadata.target_directory.join("tests");
}
let mut trybuild_target = trybuild_dir.join("target");
// https://github.com/dtolnay/trybuild/pull/219 specifies tests/trybuild as the target
// directory, which is a bit odd since build artifacts are generated in the same directory
// as the test project.
if !trybuild_target.is_dir() {
trybuild_target.pop();
}
trybuild_target
}
}

fn rustc_version(rustc: &ProcessBuilder) -> Result<bool> {
Expand Down
3 changes: 1 addition & 2 deletions src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ fn pkg_hash_re(ws: &Workspace, pkg_ids: &[PackageId]) -> RegexVec {
}

fn clean_trybuild_artifacts(ws: &Workspace, pkg_ids: &[PackageId], verbose: bool) -> Result<()> {
let trybuild_dir = &ws.metadata.target_directory.join("tests");
let trybuild_target = &trybuild_dir.join("target");
let trybuild_target = ws.trybuild_target();
let re = pkg_hash_re(ws, pkg_ids);

for e in WalkDir::new(trybuild_target).into_iter().filter_map(Result::ok) {
Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,7 @@ fn object_files(cx: &Context) -> Result<Vec<OsString>> {
}

// trybuild
let trybuild_dir = &cx.ws.metadata.target_directory.join("tests");
let mut trybuild_target = trybuild_dir.join("target");
let mut trybuild_target = cx.ws.trybuild_target();
if let Some(target) = &cx.args.target {
trybuild_target.push(target);
}
Expand Down

0 comments on commit 3874e78

Please sign in to comment.