Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::de::{Deserialize, Deserializer};
use serde_derive::Serialize;
use std::borrow::Cow;
use std::env;
use std::ffi::OsString;
use std::ffi::{OsStr, OsString};
use std::io;
use std::path::{Path, PathBuf};

Expand All @@ -27,6 +27,10 @@ impl Directory {
self.path.to_string_lossy()
}

pub fn as_os_str(&self) -> &OsStr {
self.path.as_os_str()
}

pub fn join<P: AsRef<Path>>(&self, tail: P) -> PathBuf {
self.path.join(tail)
}
Expand Down
5 changes: 5 additions & 0 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::normalize::{self, Context, Normalization, Variations};
use crate::path::CanonicalPath;
use crate::{Expected, Runner, Test, features};
use serde_derive::Deserialize;
use std::cmp::Reverse;
use std::collections::{BTreeMap as Map, BTreeSet as Set};
use std::env;
use std::ffi::{OsStr, OsString};
Expand Down Expand Up @@ -164,6 +165,10 @@ impl Runner {
);
}

// Sort by decreasing path length so that a linear scan can use the
// first match knowing it is the longest match.
path_dependencies.sort_by_key(|dep| Reverse(dep.normalized_path.as_os_str().len()));

let crate_name = &source_manifest.package.name;
let project_dir = path!(target_dir / "tests" / "trybuild" / crate_name /);
fs::create_dir_all(&project_dir)?;
Expand Down