Windows and Linux build environments; check clean on both (E-01)
MuPDF builds with MSBuild on Windows (/MT, OpenSSL from vcpkg); Git for Windows' MinGit stands in for the source build there. CEF loads from where libcef lives and sets its API version first on every platform. File identity on Windows compares volume and index. The checkout and reference/ keep LF on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d59159cea2
commit
68b5af76e0
40 files changed
+380
-82
No files matched your search
@@ -56,6 +56,28 @@ fn an_unreadable_log_is_an_error_not_nothing() {
|
||||
assert!(log_part(log).is_err(), "a log that cannot be read shows");
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn an_unreadable_log_is_an_error_not_nothing() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let logs = dir.path().join("logs");
|
||||
std::fs::create_dir(&logs).unwrap();
|
||||
let log = logs.join("ely.log");
|
||||
assert_eq!(log_part(log.clone()).unwrap(), None, "no log yet is nothing");
|
||||
std::fs::write(&log, "a line\n").unwrap();
|
||||
let icacls = |path: &std::path::Path, args: [&str; 2]| {
|
||||
let done = std::process::Command::new("icacls").arg(path).args(args).output().unwrap();
|
||||
assert!(done.status.success(), "icacls: {}", String::from_utf8_lossy(&done.stdout));
|
||||
};
|
||||
// Everyone loses its attributes and its folder's listing.
|
||||
icacls(&log, ["/deny", "*S-1-1-0:(RA)"]);
|
||||
icacls(&logs, ["/deny", "*S-1-1-0:(RD)"]);
|
||||
let read = log_part(log.clone());
|
||||
icacls(&logs, ["/remove:d", "*S-1-1-0"]);
|
||||
icacls(&log, ["/remove:d", "*S-1-1-0"]);
|
||||
assert!(read.is_err(), "a log that cannot be read shows: {read:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cut_log_starts_at_a_whole_line() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -14,6 +14,12 @@ pub const PROGRAM: &str = "git";
|
||||
/// The oldest system Git counted as verified (user decision).
|
||||
pub const LEAST: (u32, u32) = (2, 40);
|
||||
|
||||
/// Git inside a Git install: MinGit's on Windows.
|
||||
#[cfg(windows)]
|
||||
const GIT: &str = "cmd/git.exe";
|
||||
#[cfg(not(windows))]
|
||||
const GIT: &str = "bin/git";
|
||||
|
||||
/// `ELY_GIT`, ElyTree's setting, else Ely's own Git.
|
||||
pub fn locate() -> io::Result<(PathBuf, bool)> {
|
||||
if let Some(path) = std::env::var_os("ELY_GIT") {
|
||||
@@ -62,12 +68,12 @@ pub fn system_version(path: &Path) -> io::Result<String> {
|
||||
/// Beside `dir`, in its bundle, in ElyTree's, or built.
|
||||
fn own(dir: &Path) -> PathBuf {
|
||||
// ElyTree carries Git; the other apps use its copy.
|
||||
let tree = format!("../../../{}.app/Contents/Resources/git/bin/git", AppId::Tree.name());
|
||||
let built = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../engines/git/bin/git");
|
||||
let tree = format!("../../../{}.app/Contents/Resources/git", AppId::Tree.name());
|
||||
let built = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../engines/git").join(GIT);
|
||||
[
|
||||
dir.join("git/bin/git"),
|
||||
dir.join("../Resources/git/bin/git"),
|
||||
dir.join(tree),
|
||||
dir.join("git").join(GIT),
|
||||
dir.join("../Resources/git").join(GIT),
|
||||
dir.join(tree).join(GIT),
|
||||
]
|
||||
.into_iter()
|
||||
.find(|path| path.is_file())
|
||||
@@ -113,17 +119,17 @@ mod tests {
|
||||
assert_eq!(super::parse_version("hello"), None);
|
||||
}
|
||||
|
||||
use super::own;
|
||||
use super::{GIT, own};
|
||||
|
||||
#[test]
|
||||
fn apps_beside_elytree_use_its_git() {
|
||||
let apps = tempfile::tempdir().expect("a temp dir");
|
||||
let mark = apps.path().join("ElyMark.app/Contents/MacOS");
|
||||
let git = apps.path().join("ElyTree.app/Contents/Resources/git/bin");
|
||||
let git = apps.path().join("ElyTree.app/Contents/Resources/git").join(GIT);
|
||||
std::fs::create_dir_all(&mark).expect("ElyMark");
|
||||
assert!(own(&mark).ends_with("engines/git/bin/git"));
|
||||
std::fs::create_dir_all(&git).expect("ElyTree's Git");
|
||||
std::fs::write(git.join("git"), "").expect("git");
|
||||
assert_eq!(own(&mark), mark.join("../../../ElyTree.app/Contents/Resources/git/bin/git"));
|
||||
assert!(own(&mark).ends_with(std::path::Path::new("engines/git").join(GIT)));
|
||||
std::fs::create_dir_all(git.parent().expect("a folder")).expect("ElyTree's Git");
|
||||
std::fs::write(&git, "").expect("git");
|
||||
assert_eq!(own(&mark), mark.join("../../../ElyTree.app/Contents/Resources/git").join(GIT));
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,9 @@
|
||||
use std::{
|
||||
io,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
/// The `.app` running this process; none in dev builds.
|
||||
pub fn running_bundle() -> io::Result<Option<PathBuf>> {
|
||||
@@ -50,6 +51,7 @@ fn stage(from: &Path, parent: &Path, name: &std::ffi::OsStr) -> io::Result<PathB
|
||||
}
|
||||
|
||||
/// Puts `staged` at `bundle`; on failure the old returns.
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn swap(staged: &Path, bundle: &Path) -> io::Result<()> {
|
||||
let name = bundle.file_name().ok_or_else(|| io::Error::other("the app has no name"))?;
|
||||
let old = bundle.with_file_name(format!(".{}.old", name.to_string_lossy()));
|
||||
|
||||
@@ -73,6 +73,7 @@ pub fn print_pdf(pdf: &Path) -> anyhow::Result<bool> {
|
||||
}
|
||||
|
||||
/// One paper holding every page, turned as needed.
|
||||
#[cfg(any(target_os = "macos", test))]
|
||||
fn paper_for(sizes: &[(f64, f64)]) -> Option<(f64, f64)> {
|
||||
let long = sizes.iter().map(|(w, h)| w.max(*h)).fold(None, |most: Option<f64>, side| Some(most.map_or(side, |m| m.max(side))))?;
|
||||
let short = sizes.iter().map(|(w, h)| w.min(*h)).fold(0.0, f64::max);
|
||||
|
||||
@@ -51,7 +51,7 @@ fn full_name() -> io::Result<String> {
|
||||
return Ok(String::new());
|
||||
}
|
||||
let mut buffer = vec![0u16; size as usize];
|
||||
if unsafe { GetUserNameExW(NameDisplay, buffer.as_mut_ptr(), &mut size) } == 0 {
|
||||
if !unsafe { GetUserNameExW(NameDisplay, buffer.as_mut_ptr(), &mut size) } {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
Ok(String::from_utf16_lossy(&buffer[..size as usize]))
|
||||
|
||||
Reference in new issue
Block a user