Skip to content
Merged
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
18 changes: 17 additions & 1 deletion crates/sqlbuild-cli/tests/launcher/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,26 @@ pub(crate) fn sqb_file() -> String {
/// A copy of the real `sqlbuild` forwarder, alone in `directory`; a copy works across volumes.
pub(crate) fn forwarder_in(directory: &Path) -> PathBuf {
let forwarder = directory.join(format!("sqlbuild{}", std::env::consts::EXE_SUFFIX));
std::fs::copy(env!("CARGO_BIN_EXE_sqlbuild"), &forwarder).expect("copy the forwarder");
copy_executable(Path::new(env!("CARGO_BIN_EXE_sqlbuild")), &forwarder);
forwarder
}

/// Copies in a child, so tests forking in parallel never inherit a write handle (ETXTBSY).
#[cfg(unix)]
fn copy_executable(source: &Path, destination: &Path) {
let status = Command::new("cp")
.arg(source)
.arg(destination)
.status()
.expect("run cp");
assert!(status.success(), "copy the forwarder: {status:?}");
}

#[cfg(windows)]
fn copy_executable(source: &Path, destination: &Path) {
std::fs::copy(source, destination).expect("copy the forwarder");
}

/// The real forwarder with a fake `sqb` beside it that reports what it received.
pub(crate) fn forwarder_with_fake_sqb(directory: &Path) -> PathBuf {
compile(FAKE_SQB, directory, "sqb");
Expand Down
Loading