mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
## Summary In https://github.com/openai/codex/pull/21584, we disabled doctests for crates that lack any doctests. We can enforce that property via `cargo shear --deny-warnings`: crates that lack doctests will be flagged if doctests are enabled, and crates with doctests will be flagged if doctests are disabled. A few additional notes: - By adding `--deny-warnings`, `cargo shear` also flagged a number of modules that were not reachable at all. Some of those have been removed. - This PR removes a usage of `windows_modules!` (since `cargo shear` and `rustfmt` couldn't see through it) in favor of simple `#[cfg(target_os = "windows")]` macros. As a consequence, many of these files exhibit churn in this PR, since they weren't being formatted by `rustfmt` at all on main. - Again, to make the code more analyzable, this PR also removes some usages of `#[path = "cwd_junction.rs"]` in favor of a more standard module structure. The bin sidecar structure is still retained, but, e.g., `windows-sandbox-rs/src/bin/command_runner.rs` was moved to `windows-sandbox-rs/src/bin/command_runner/main.rs`, and so on. --------- Co-authored-by: Codex <noreply@openai.com>
32 lines
783 B
Rust
32 lines
783 B
Rust
use std::path::Path;
|
|
use std::path::PathBuf;
|
|
|
|
pub fn canonicalize_path(path: &Path) -> PathBuf {
|
|
dunce::canonicalize(path).unwrap_or_else(|_| path.to_path_buf())
|
|
}
|
|
|
|
pub fn canonical_path_key(path: &Path) -> String {
|
|
canonicalize_path(path)
|
|
.to_string_lossy()
|
|
.replace('\\', "/")
|
|
.to_ascii_lowercase()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::canonical_path_key;
|
|
use pretty_assertions::assert_eq;
|
|
use std::path::Path;
|
|
|
|
#[test]
|
|
fn canonical_path_key_normalizes_case_and_separators() {
|
|
let windows_style = Path::new(r"C:\Users\Dev\Repo");
|
|
let slash_style = Path::new("c:/users/dev/repo");
|
|
|
|
assert_eq!(
|
|
canonical_path_key(windows_style),
|
|
canonical_path_key(slash_style)
|
|
);
|
|
}
|
|
}
|