Skip to content

Commit bcdaa4c

Browse files
committed
Spawn sbt and scala-cli test CLIs through the hermetic builder
spawn_env_hygiene's no_new_bare_binary_spawns ratchet failed on test, test-release and coverage. The four sbt / scala-cli suites added on this branch started the CLI with a bare Command::new(CARGO_BIN_EXE) and their own SOCKET_* sweep. The sweep also removed the SOCKET_NO_CONFIG and SOCKET_NO_UPDATE_CHECK guards that hermetic::command forces. Spawn them through hermetic::binary_command() instead, and keep only the COURSIER_* sweep these suites need on top of it. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d836a59 commit bcdaa4c

5 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎crates/socket-patch-cli/tests/e2e_sbt_vendor.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
//! drift, `repair`, a forged ledger, an escaping symlink, the subproject
1515
//! and build-edit refusals.
1616
17+
#[path = "common/hermetic.rs"]
18+
mod hermetic;
1719
#[path = "prebuilt_common/mod.rs"]
1820
mod prebuilt_common;
1921
#[path = "sbt_common/mod.rs"]
@@ -22,7 +24,6 @@ mod sbt_common;
2224
use std::collections::BTreeMap;
2325
use std::io::Write as _;
2426
use std::path::{Path, PathBuf};
25-
use std::process::Command;
2627

2728
use sbt_common::{copy_evidence, record_pinned_resolution, write_coursier_artifact, Gav, SbtHome};
2829
use socket_patch_core::formats::sbt::owned_file::{
@@ -169,10 +170,10 @@ impl Fixture {
169170

170171
/// `socket-patch <args> --json --cwd <proj>/<dir>`; `(exit, envelope)`.
171172
fn run_in(&self, dir: &str, args: &[&str]) -> (Option<i32>, serde_json::Value) {
172-
let mut cmd = Command::new(env!("CARGO_BIN_EXE_socket-patch"));
173+
let mut cmd = hermetic::binary_command();
173174
for (k, _) in std::env::vars_os() {
174175
let k = k.to_string_lossy();
175-
if k.starts_with("SOCKET_") || k.starts_with("COURSIER_") {
176+
if k.starts_with("COURSIER_") {
176177
cmd.env_remove(&*k);
177178
}
178179
}

‎crates/socket-patch-cli/tests/e2e_sbt_vendor_build.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
//! VERSION,REQUIRED,SEED}` (`sbt_vendor_build_common`). Scratch trees go
3232
//! under `TMPDIR`.
3333
34+
#[path = "common/hermetic.rs"]
35+
mod hermetic;
3436
#[path = "maven_build_common/mod.rs"]
3537
mod maven_build_common;
3638
#[path = "prebuilt_common/mod.rs"]
@@ -186,10 +188,10 @@ fn setup(
186188
impl Ctx {
187189
/// `socket-patch <args> --json --offline --cwd <dir>`; `(exit, envelope)`.
188190
fn socket(&self, dir: &Path, args: &[&str]) -> (Option<i32>, serde_json::Value) {
189-
let mut cmd = Command::new(env!("CARGO_BIN_EXE_socket-patch"));
191+
let mut cmd = hermetic::binary_command();
190192
for (k, _) in std::env::vars_os() {
191193
let k = k.to_string_lossy().into_owned();
192-
if k.starts_with("SOCKET_") || k.starts_with("COURSIER_") {
194+
if k.starts_with("COURSIER_") {
193195
cmd.env_remove(&k);
194196
}
195197
}

‎crates/socket-patch-cli/tests/e2e_scala_cli_vendor.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
2828
#![cfg_attr(windows, allow(dead_code, unused_imports))]
2929

30+
#[path = "common/hermetic.rs"]
31+
mod hermetic_spawn;
3032
#[path = "prebuilt_common/mod.rs"]
3133
mod prebuilt_common;
3234

@@ -214,10 +216,10 @@ fn socket_in_cache(
214216
args: &[&str],
215217
cache: &Path,
216218
) -> (Option<i32>, serde_json::Value) {
217-
let mut cmd = Command::new(env!("CARGO_BIN_EXE_socket-patch"));
219+
let mut cmd = hermetic_spawn::binary_command();
218220
for (k, _) in std::env::vars_os() {
219221
let k = k.to_string_lossy().into_owned();
220-
if k.starts_with("SOCKET_") || k.starts_with("COURSIER_") {
222+
if k.starts_with("COURSIER_") {
221223
cmd.env_remove(&k);
222224
}
223225
}

‎crates/socket-patch-cli/tests/e2e_vex_lockfile/main.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
//! (with the PDM/Hatch and Pipenv/pip helpers beside it); `common_selftest`
2121
//! tests those helpers themselves.
2222
23+
#[path = "../common/hermetic.rs"]
24+
mod hermetic;
2325
#[path = "../prebuilt_common/mod.rs"]
2426
mod prebuilt_common;
2527
#[path = "../sbt_common/mod.rs"]

‎crates/socket-patch-cli/tests/e2e_vex_lockfile/sbt_vendored.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
//! | e | no ledger | nothing attested; the tree check still runs |
2121
2222
use std::path::{Path, PathBuf};
23-
use std::process::Command;
2423
use std::time::{Duration, SystemTime};
2524

2625
use serde_json::Value;
@@ -134,10 +133,10 @@ impl Fx {
134133

135134
/// `socket-patch <args> --json --cwd <proj>` in the isolated home.
136135
fn run(&self, args: &[&str]) -> (Option<i32>, Value) {
137-
let mut cmd = Command::new(env!("CARGO_BIN_EXE_socket-patch"));
136+
let mut cmd = super::hermetic::binary_command();
138137
for (k, _) in std::env::vars_os() {
139138
let k = k.to_string_lossy();
140-
if k.starts_with("SOCKET_") || k.starts_with("COURSIER_") {
139+
if k.starts_with("COURSIER_") {
141140
cmd.env_remove(&*k);
142141
}
143142
}

0 commit comments

Comments
 (0)