Skip to content

Commit 33e7a7a

Browse files
committed
rename fixture -> artifact
1 parent 7fad81a commit 33e7a7a

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use std::{
33
io::{self, Write},
44
path::{Path, PathBuf},
55
};
6-
pub struct Fixture {
6+
7+
/// An artifact (e.g., a DLL or shared library) whose content is embedded and needs to be written to disk.
8+
pub struct Artifact {
79
pub name: &'static str,
810
pub content: &'static [u8],
911
pub hash: &'static str,
@@ -12,9 +14,9 @@ pub struct Fixture {
1214
#[cfg(target_os = "macos")]
1315
#[doc(hidden)]
1416
#[macro_export]
15-
macro_rules! fixture {
17+
macro_rules! artifact {
1618
($name: literal) => {
17-
$crate::fixture::Fixture::new(
19+
$crate::artifact::Artifact::new(
1820
$name,
1921
::core::include_bytes!(::core::concat!(::core::env!("OUT_DIR"), "/", $name)),
2022
::core::include_str!(::core::concat!(::core::env!("OUT_DIR"), "/", $name, ".hash")),
@@ -23,9 +25,9 @@ macro_rules! fixture {
2325
}
2426

2527
#[cfg(target_os = "macos")]
26-
pub use fixture;
28+
pub use artifact;
2729

28-
impl Fixture {
30+
impl Artifact {
2931
#[cfg(not(target_os = "linux"))]
3032
pub const fn new(name: &'static str, content: &'static [u8], hash: &'static str) -> Self {
3133
Self { name, content, hash }

crates/fspy/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(once_cell_try)]
33

44
// Persist the injected DLL/shared library somewhere in the filesystem.
5-
mod fixture;
5+
mod artifact;
66

77
pub mod error;
88

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::fixture::{Fixture, fixture};
1+
use crate::artifact::{Artifact, artifact};
22

3-
pub const COREUTILS_BINARY: Fixture = fixture!("coreutils");
4-
pub const OILS_BINARY: Fixture = fixture!("oils-for-unix");
3+
pub const COREUTILS_BINARY: Artifact = artifact!("coreutils");
4+
pub const OILS_BINARY: Artifact = artifact!("oils-for-unix");
55

66
#[cfg(test)]
77
mod tests {

crates/fspy/src/unix/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
mod syscall_handler;
33

44
#[cfg(target_os = "macos")]
5-
mod macos_fixtures;
5+
mod macos_artifacts;
66

77
use std::{io, path::Path};
88

99
#[cfg(target_os = "linux")]
1010
use fspy_seccomp_unotify::supervisor::supervise;
1111
use fspy_shared::ipc::{NativeString, PathAccess, channel::channel};
1212
#[cfg(target_os = "macos")]
13-
use fspy_shared_unix::payload::Fixtures;
13+
use fspy_shared_unix::payload::Artifacts;
1414
use fspy_shared_unix::{
1515
exec::ExecResolveConfig,
1616
payload::{Payload, encode_payload},
@@ -31,7 +31,7 @@ use crate::{
3131
#[derive(Debug, Clone)]
3232
pub struct SpyImpl {
3333
#[cfg(target_os = "macos")]
34-
fixtures: Fixtures,
34+
artifacts: Artifacts,
3535

3636
preload_path: NativeString,
3737
}
@@ -44,9 +44,9 @@ impl SpyImpl {
4444
use const_format::formatcp;
4545
use xxhash_rust::const_xxh3::xxh3_128;
4646

47-
use crate::fixture::Fixture;
47+
use crate::artifact::Artifact;
4848

49-
const PRELOAD_CDYLIB: Fixture = Fixture {
49+
const PRELOAD_CDYLIB: Artifact = Artifact {
5050
name: "fspy_preload",
5151
content: PRELOAD_CDYLIB_BINARY,
5252
hash: formatcp!("{:x}", xxh3_128(PRELOAD_CDYLIB_BINARY)),
@@ -56,10 +56,10 @@ impl SpyImpl {
5656
Ok(Self {
5757
preload_path: preload_cdylib_path.as_path().into(),
5858
#[cfg(target_os = "macos")]
59-
fixtures: {
60-
let coreutils_path = macos_fixtures::COREUTILS_BINARY.write_to(dir, "")?;
61-
let bash_path = macos_fixtures::OILS_BINARY.write_to(dir, "")?;
62-
Fixtures {
59+
artifacts: {
60+
let coreutils_path = macos_artifacts::COREUTILS_BINARY.write_to(dir, "")?;
61+
let bash_path = macos_artifacts::OILS_BINARY.write_to(dir, "")?;
62+
Artifacts {
6363
bash_path: bash_path.as_path().into(),
6464
coreutils_path: coreutils_path.as_path().into(),
6565
}
@@ -78,7 +78,7 @@ impl SpyImpl {
7878
ipc_channel_conf,
7979

8080
#[cfg(target_os = "macos")]
81-
fixtures: self.fixtures.clone(),
81+
artifacts: self.artifacts.clone(),
8282

8383
preload_path: self.preload_path.clone(),
8484

crates/fspy/src/windows/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ use xxhash_rust::const_xxh3::xxh3_128;
2222

2323
use crate::{
2424
ChildTermination, TrackedChild,
25+
artifact::Artifact,
2526
command::Command,
2627
error::SpawnError,
27-
fixture::Fixture,
2828
ipc::{OwnedReceiverLockGuard, SHM_CAPACITY},
2929
};
3030

3131
const PRELOAD_CDYLIB_BINARY: &[u8] = include_bytes!(env!("CARGO_CDYLIB_FILE_FSPY_PRELOAD_WINDOWS"));
32-
const INTERPOSE_CDYLIB: Fixture = Fixture::new(
32+
const INTERPOSE_CDYLIB: Artifact = Artifact::new(
3333
"fsyp_preload",
3434
PRELOAD_CDYLIB_BINARY,
3535
formatcp!("{:x}", xxh3_128(PRELOAD_CDYLIB_BINARY)),

crates/fspy_shared_unix/src/payload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ pub struct Payload {
1212
pub preload_path: NativeString,
1313

1414
#[cfg(target_os = "macos")]
15-
pub fixtures: Fixtures,
15+
pub artifacts: Artifacts,
1616

1717
#[cfg(target_os = "linux")]
1818
pub seccomp_payload: fspy_seccomp_unotify::payload::SeccompPayload,
1919
}
2020

2121
#[cfg(target_os = "macos")]
2222
#[derive(Debug, Encode, Decode, Clone)]
23-
pub struct Fixtures {
23+
pub struct Artifacts {
2424
pub bash_path: NativeString,
2525
pub coreutils_path: NativeString,
2626
// pub interpose_cdylib_path: NativeString,

crates/fspy_shared_unix/src/spawn/macos.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ pub fn handle_exec(
4242
(program_path.parent(), program_path.file_name())
4343
{
4444
if matches!(parent.as_os_str().as_bytes(), b"/bin" | b"/usr/bin") {
45-
let fixtures = &encoded_payload.payload.fixtures;
45+
let artifacts = &encoded_payload.payload.artifacts;
4646
if matches!(file_name.as_bytes(), b"sh" | b"bash") {
47-
command.program = fixtures.bash_path.as_os_str().as_bytes().into();
47+
command.program = artifacts.bash_path.as_os_str().as_bytes().into();
4848
true
4949
} else if COREUTILS_FUNCTIONS.contains(file_name.as_bytes()) {
50-
command.program = fixtures.coreutils_path.as_os_str().as_bytes().into();
50+
command.program = artifacts.coreutils_path.as_os_str().as_bytes().into();
5151
true
5252
} else {
5353
false

0 commit comments

Comments
 (0)