Skip to content

Commit

Permalink
Remove some unnused macros from maelstrom-test.
Browse files Browse the repository at this point in the history
This whole crate should go away someday. Instead, we should have construction
macros that live their related types.
  • Loading branch information
nfachan committed Jan 14, 2025
1 parent f0ae96b commit 50f09bb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 77 deletions.
4 changes: 2 additions & 2 deletions crates/maelstrom-client-base/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ mod tests {
use enumset::enum_set;
use indoc::indoc;
use maelstrom_base::{proc_mount, tmp_mount};
use maelstrom_test::{path_buf_vec, string, string_vec, utf8_path_buf};
use maelstrom_test::{path_buf, string, string_vec, utf8_path_buf};
use maplit::btreemap;
use std::{ffi::OsStr, os::unix::ffi::OsStrExt as _};

Expand Down Expand Up @@ -1468,7 +1468,7 @@ mod tests {
fn images(name: &str) -> ImageConfig {
match name {
"image1" => ImageConfig {
layers: path_buf_vec!["42", "43"],
layers: vec![path_buf!("42"), path_buf!("43")],
working_directory: Some("/foo".into()),
environment: Some(string_vec!["FOO=image-foo", "BAZ=image-baz",]),
},
Expand Down
2 changes: 1 addition & 1 deletion crates/maelstrom-test-runner/src/metadata/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ mod tests {
container_container_parent, container_spec, image_container_parent, spec::SymlinkSpec,
tar_layer_spec,
};
use maelstrom_test::{non_root_utf8_path_buf, string, utf8_path_buf};
use maelstrom_test::{string, utf8_path_buf};
use maplit::btreemap;

fn parse_test_directive(toml: &str) -> Result<Directive<String>, toml::de::Error> {
Expand Down
72 changes: 0 additions & 72 deletions crates/maelstrom-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,75 +125,20 @@ macro_rules! outcome {
[$n:expr] => { maelstrom_base::JobOutcome::Completed(completed![$n]) };
}

#[macro_export]
macro_rules! digest_hash_set {
[$($e:expr),*] => {
::std::collections::HashSet::from_iter([$(maelstrom_base::digest!($e)),*])
};
}

#[macro_export]
macro_rules! path_buf {
($e:expr) => {
std::path::Path::new($e).to_path_buf()
};
}

#[macro_export]
macro_rules! path_buf_vec {
[$($e:expr),*] => {
vec![$($crate::path_buf!($e)),*]
};
}

#[macro_export]
macro_rules! path_buf_nonempty {
[$($e:expr),*] => {
nonempty![$($crate::path_buf!($e)),*]
};
}

#[macro_export]
macro_rules! utf8_path_buf {
($e:expr) => {
maelstrom_base::Utf8PathBuf::from($e)
};
}

#[macro_export]
macro_rules! non_root_utf8_path_buf {
($e:expr) => {
maelstrom_base::NonRootUtf8PathBuf::try_from(maelstrom_base::Utf8PathBuf::from($e)).unwrap()
};
}

#[macro_export]
macro_rules! utf8_path_buf_vec {
[$($e:expr),*] => {
vec![$($crate::utf8_path_buf!($e)),*]
};
}

#[macro_export]
macro_rules! long_path {
($prefix:expr, $n:expr) => {
format!("{}/{:0>64x}", $prefix, $n).into()
};
($prefix:expr, $n:expr, $s:expr) => {
format!("{}/{:0>64x}.{}", $prefix, $n, $s).into()
};
}

#[macro_export]
macro_rules! short_path {
($prefix:expr, $n:expr) => {
format!("{}/{:0>16x}", $prefix, $n).into()
};
($prefix:expr, $n:expr, $s:expr) => {
format!("{}/{:0>16x}.{}", $prefix, $n, $s).into()
};
}

#[macro_export]
macro_rules! boxed_u8 {
($n:expr) => {
Expand All @@ -218,23 +163,6 @@ macro_rules! string_vec {
};
}

#[macro_export]
macro_rules! string_nonempty {
[$($e:expr),*] => {
nonempty![$($e.to_string()),*]
};
[$($e:expr),*,] => {
nonempty![$($e.to_string()),*]
};
}

#[macro_export]
macro_rules! timeout {
($n:literal) => {
maelstrom_base::Timeout::new($n)
};
}

#[macro_export]
macro_rules! millis {
($millis:expr) => {
Expand Down
3 changes: 1 addition & 2 deletions crates/maelstrom-util/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1939,10 +1939,9 @@ mod tests {
#[test]
fn cache_path() {
let fixture = Fixture::new(10, fs! {});
let cache_path: PathBuf = long_path!("/z/sha256/apple", 42);
assert_eq!(
fixture.cache.cache_path(&apple!(42)).into_path_buf(),
cache_path
PathBuf::from(format!("/z/sha256/apple/{:0>64x}", 42)),
);
}

Expand Down

0 comments on commit 50f09bb

Please sign in to comment.