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
5 changes: 0 additions & 5 deletions crates/socket-patch-cli/tests/cli/shared_helper_copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const PENDING_PRIVATE_HELPERS: &[&str] = &[
"apply/apply_network.rs",
"cli/api_client_errors_e2e.rs",
"diff_created_file_e2e.rs",
"e2e_vex_redirect.rs",
"e2e_vex_vendor.rs",
"get/global_packages_e2e.rs",
"in_process_agent_reapply.rs",
"in_process_alternate_installers.rs",
"in_process_cargo_apply.rs",
Expand All @@ -31,16 +29,13 @@ const PENDING_PRIVATE_HELPERS: &[&str] = &[
"in_process_pypi_multi_release.rs",
"in_process_remote_ecosystems_apply.rs",
"in_process_remove_repair_lifecycle.rs",
"mode_migration_npm.rs",
"remove_rollback_api_overrides.rs",
"repair/covgap_commands_repair.rs",
"repair/covgap_commands_repair_vendor.rs",
"repair/repair_invariants.rs",
"rollback/rollback_multicopy_blob_gate.rs",
"scan/covgap_commands_fetch_stage.rs",
"scan_rollout_e2e.rs",
"scan_vendor_e2e.rs",
"vendor_ecosystem_fixtures/mod.rs",
"vex_e2e_common/mod.rs",
"vlt_e2e_common/mod.rs",
"vlt_hosted_common/mod.rs",
Expand Down
8 changes: 4 additions & 4 deletions crates/socket-patch-cli/tests/e2e_vex_redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
//! lockfile still resolves the dependency from its hosted patch (a reverted
//! lockfile with the ledger left behind must not keep attesting).

#[path = "common/mod.rs"]
mod common;
use common::binary;

#[path = "vex_e2e_common/mod.rs"]
mod vex_e2e_common;

Expand Down Expand Up @@ -93,10 +97,6 @@ fn write_hosted_package_lock(cwd: &Path, deps: &[(&str, &str, &str)], pinned: bo
.unwrap();
}

fn binary() -> &'static str {
env!("CARGO_BIN_EXE_socket-patch")
}

/// CLI invocation with the ambient `SOCKET_*` environment scrubbed (explicit
/// flags must be the sole source of truth).
fn cli() -> Command {
Expand Down
7 changes: 2 additions & 5 deletions crates/socket-patch-cli/tests/get/global_packages_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
//! that crashes, swallows the PURL, or silently reports success no
//! longer slips through.

use std::path::{Path, PathBuf};
use std::path::Path;
use std::process::Command;

use crate::cache_env;

fn binary() -> PathBuf {
env!("CARGO_BIN_EXE_socket-patch").into()
}
use crate::common::binary;

/// Build a `socket-patch` `Command` with the ambient `SOCKET_*` env
/// surface scrubbed (mirrors `common::run_with_env`). The binary binds
Expand Down
16 changes: 4 additions & 12 deletions crates/socket-patch-cli/tests/mode_migration_npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
//! the registry is unreachable for the fixture install; all assertions after
//! that are hard.

#[path = "common/mod.rs"]
mod common;
use common::{binary, cache_env, git_sha256, hermetic};

#[path = "prebuilt_common/mod.rs"]
mod prebuilt_common;

Expand All @@ -32,10 +36,6 @@ use socket_patch_core::hash::git_sha256::compute_git_sha256_from_bytes;
use wiremock::matchers::{method, path, path_regex};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/cache_env.rs"]
mod cache_env;
#[path = "common/hermetic.rs"]
mod hermetic;
// yarn legs: release selection (classic) + the manifest-less VEX matrices.
#[path = "vex_e2e_common/mod.rs"]
mod vex_e2e_common;
Expand All @@ -60,10 +60,6 @@ const YARN_BERRY: &str = "yarn@4.12.0";
// ── self-contained helpers (harness patterns shared with the redirect /
// vendor yarn capstones) ──────────────────────────────────────────────────

fn binary() -> PathBuf {
PathBuf::from(env!("CARGO_BIN_EXE_socket-patch"))
}

/// Probe corepack from a NEUTRAL temp dir: a `packageManager` field in an
/// ancestor `package.json` makes corepack refuse to run a different package
/// manager, which would spuriously fail the gate.
Expand Down Expand Up @@ -134,10 +130,6 @@ fn copy_dir_recursive(src: &Path, dst: &Path) {
}
}

fn git_sha256(content: &[u8]) -> String {
compute_git_sha256_from_bytes(content)
}

/// Write `.socket/manifest.json` + the after-hash blob so `vendor --offline`
/// runs fully offline (npm-family file keys carry the `package/` prefix).
fn stage_patch(proj: &Path, before: &[u8], after: &[u8]) {
Expand Down
18 changes: 5 additions & 13 deletions crates/socket-patch-cli/tests/scan_rollout_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
//! three packages per run, most severe first, in hosted, agent and vendored
//! mode; a fourth run changes nothing. Mock API, the built binary.

#[path = "common/mod.rs"]
mod common;
use common::{binary, git_sha256};

#[path = "prebuilt_common/mod.rs"]
mod prebuilt_common;

use std::path::{Path, PathBuf};
use std::path::Path;
use std::process::Command;

use serde_json::{json, Value};
use sha2::{Digest, Sha256};
use wiremock::matchers::{method, path, path_regex};
use wiremock::{Mock, MockServer, ResponseTemplate};

Expand All @@ -36,10 +39,6 @@ const ORDER: [&str; 9] = [
"roll-e", "roll-b", "roll-g", "roll-c", "roll-d", "roll-h", "roll-a", "roll-i", "roll-f",
];

fn binary() -> PathBuf {
env!("CARGO_BIN_EXE_socket-patch").into()
}

fn uuid(name: &str) -> String {
let n = PACKAGES.iter().position(|(p, _)| *p == name).unwrap() + 1;
format!("{n:08x}-1111-4111-8111-{n:012x}")
Expand All @@ -64,13 +63,6 @@ fn after(name: &str) -> Vec<u8> {
format!("module.exports = '{name} after';\n").into_bytes()
}

fn git_sha256(content: &[u8]) -> String {
let mut hasher = Sha256::new();
hasher.update(format!("blob {}\0", content.len()).as_bytes());
hasher.update(content);
hex::encode(hasher.finalize())
}

fn b64(bytes: &[u8]) -> String {
use base64::Engine;
base64::engine::general_purpose::STANDARD.encode(bytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ mod prebuilt_common;
use std::path::{Path, PathBuf};
use std::process::Command;

use sha2::{Digest, Sha256};
use sha2::Digest as _;

pub fn git_sha256(content: &[u8]) -> String {
let mut hasher = Sha256::new();
hasher.update(format!("blob {}\0", content.len()).as_bytes());
hasher.update(content);
hex::encode(hasher.finalize())
}
use crate::common::git_sha256;

/// Every ecosystem fixture, by name.
pub const ALL: &[&str] = &[
Expand Down
8 changes: 4 additions & 4 deletions crates/socket-patch-cli/tests/vendor_group_commit_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
//! files (a hand edit after the crash) is set aside whole, never
//! half-applied.

#[path = "common/mod.rs"]
mod common;

#[path = "vendor_ecosystem_fixtures/mod.rs"]
mod fx;

#[path = "common/envelope.rs"]
mod envelope;

use envelope::{event_triples, parse_json_envelope};
use common::envelope::{event_triples, parse_json_envelope};
use fx::{masked_tree, Fixture};

const OFF: (&str, &str) = ("SOCKET_PATCH_SWITCH_OFF", "group_commit");
Expand Down
3 changes: 3 additions & 0 deletions crates/socket-patch-cli/tests/vendor_ledger_schema_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
//! far smaller than the inline text, the others stay version 1, and the
//! revert is exact.

#[path = "common/mod.rs"]
mod common;

#[path = "vendor_ecosystem_fixtures/mod.rs"]
mod fx;

Expand Down
Loading