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
13 changes: 0 additions & 13 deletions src/bin/eb-junit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,19 +888,6 @@ mod tests {
assert!(xml.contains("logs/later.log"));
}

#[test]
fn an_empty_successful_run_has_no_cases() {
let text = r#"{
"schema_version": 1, "kind": "result", "site": "example", "target": "cpu",
"build_type": "production", "run_id": "n", "exit_code": 0, "lines": []
}"#;
let xml = render(text).unwrap();
assert!(
xml.contains("tests=\"0\" failures=\"0\" errors=\"0\" skipped=\"0\" time=\"0.000\"")
);
assert!(!xml.contains("<testcase"));
}

#[test]
fn two_files_stay_in_order_and_a_plan_is_refused() {
let a = r#"{"schema_version":1,"kind":"result","site":"example","target":"zen2","build_type":"production","run_id":"a","exit_code":0,"lines":[]}"#;
Expand Down
59 changes: 25 additions & 34 deletions src/bin/eb-retry-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,40 +1028,31 @@ oom=2 fits=1 builds=3 nodes=1

#[test]
fn generated_easystacks_keep_short_easybuild_options() {
let entry = easystack_entry("Big-1.0.eb", &["-f".into()]).unwrap();
let document = serde_yaml::Value::Mapping(serde_yaml::Mapping::from_iter([(
serde_yaml::Value::String("easyconfigs".into()),
serde_yaml::Value::Sequence(vec![entry]),
)]));
let text = serde_yaml::to_string(&document).unwrap();
let lines = easystack::parse(&text).unwrap();
assert_eq!(lines[0].args, ["-f"]);
}

#[test]
fn generated_easystacks_keep_repeated_amend_options() {
let entry = easystack_entry(
"Big-1.0.eb",
&[
"--try-amend=versionsuffix=-a".into(),
"--try-amend".into(),
"toolchain=foss,2025a".into(),
],
)
.unwrap();
let document = serde_yaml::Value::Mapping(serde_yaml::Mapping::from_iter([(
serde_yaml::Value::String("easyconfigs".into()),
serde_yaml::Value::Sequence(vec![entry]),
)]));
let text = serde_yaml::to_string(&document).unwrap();
let lines = easystack::parse(&text).unwrap();
assert_eq!(
lines[0].args,
[
"--try-amend=versionsuffix=-a",
"--try-amend=toolchain=foss,2025a"
]
);
let rows: &[(&[&str], &[&str])] = &[
(&["-f"], &["-f"]),
(
&[
"--try-amend=versionsuffix=-a",
"--try-amend",
"toolchain=foss,2025a",
],
&[
"--try-amend=versionsuffix=-a",
"--try-amend=toolchain=foss,2025a",
],
),
];
for (input, want) in rows {
let owned: Vec<String> = input.iter().map(|arg| (*arg).to_string()).collect();
let entry = easystack_entry("Big-1.0.eb", &owned).unwrap();
let document = serde_yaml::Value::Mapping(serde_yaml::Mapping::from_iter([(
serde_yaml::Value::String("easyconfigs".into()),
serde_yaml::Value::Sequence(vec![entry]),
)]));
let text = serde_yaml::to_string(&document).unwrap();
let lines = easystack::parse(&text).unwrap();
assert_eq!(lines[0].args, *want);
}
}

#[test]
Expand Down
19 changes: 2 additions & 17 deletions src/bin/eb-test-map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,16 +516,9 @@ mod tests {
let path = dir.path().join("test-map.tsv");
let raw = CString::new(path.as_os_str().as_bytes()).unwrap();
assert_eq!(unsafe { libc::mkfifo(raw.as_ptr(), 0o600) }, 0);
let (send, receive) = std::sync::mpsc::channel();
let reader = std::thread::spawn(move || {
send.send(read_map(&path)).unwrap();
});
let error = receive
.recv_timeout(std::time::Duration::from_secs(1))
.expect("map reader blocked")
.unwrap_err();
let reader = std::thread::spawn(move || read_map(&path));
let error = reader.join().unwrap().unwrap_err();
assert!(error.contains("not a regular file"), "{error}");
reader.join().unwrap();
}

#[test]
Expand Down Expand Up @@ -579,12 +572,4 @@ mod tests {
);
assert!(parse_map("GROMACS\n").unwrap_err().contains("no test name"));
}

#[test]
fn reframe_selectors_escape_regex_characters() {
assert_eq!(
escape_regex_literal("gromacs+gpu(v2)"),
"gromacs\\+gpu\\(v2\\)"
);
}
}
10 changes: 2 additions & 8 deletions src/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ mod tests {
let dir = tempfile::tempdir().unwrap();
let output = dir.path().join("mod.lua");
std::fs::write(&output, "module\n").unwrap();
let kept = output.display().to_string();
let prior = Prior {
digest: "aa".into(),
lines: vec![
Expand All @@ -405,7 +406,7 @@ mod tests {
PriorLine {
easyconfig: "Foo-1.0.eb".into(),
status: "success".into(),
outputs: vec![output.display().to_string()],
outputs: vec![kept],
},
],
};
Expand All @@ -416,11 +417,7 @@ mod tests {
&prior,
);
assert!(skip.is_empty(), "{skip:?}");
}

#[test]
fn a_successful_shard_is_skipped_when_its_outputs_remain() {
let dir = tempfile::tempdir().unwrap();
let foo = dir.path().join("foo.lua");
std::fs::write(&foo, "module\n").unwrap();
let prior = Prior {
Expand All @@ -445,10 +442,7 @@ mod tests {
&prior,
);
assert_eq!(skip.into_iter().collect::<Vec<_>>(), ["shard-01"]);
}

#[test]
fn a_missing_output_is_not_skipped() {
let prior = Prior {
digest: "aa".into(),
lines: vec![PriorLine {
Expand Down
25 changes: 14 additions & 11 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ pub fn copy_atomic_checked<E>(
)
}

#[cfg(test)]
fn atomic_create_attempts() -> u32 {
2
}

#[cfg(not(test))]
fn atomic_create_attempts() -> u32 {
1000
}

fn publish_atomic_with<T, E>(
path: &Path,
populate: impl FnOnce(&mut std::fs::File, &Path) -> Result<T, E>,
Expand All @@ -244,7 +254,7 @@ fn publish_atomic_with<T, E>(
let name = atomic_output_name(&destination);
let local_identity = local_writer_identity();
remove_stale_atomic_temporary_files(parent, name, &local_identity);
for attempt in 0..1000u32 {
for attempt in 0..atomic_create_attempts() {
let temporary = parent.join(atomic_temp_file_name(
name,
&local_identity,
Expand Down Expand Up @@ -1217,15 +1227,8 @@ mod tests {
let fifo = dir.path().join("input.fifo");
let raw = CString::new(fifo.as_os_str().as_bytes()).unwrap();
assert_eq!(unsafe { libc::mkfifo(raw.as_ptr(), 0o600) }, 0);
let (send, receive) = std::sync::mpsc::channel();
let reader = std::thread::spawn(move || {
send.send(read_text_file(&fifo)).unwrap();
});
let error = receive
.recv_timeout(std::time::Duration::from_secs(5))
.expect("FIFO reader blocked")
.unwrap_err();
reader.join().unwrap();
let reader = std::thread::spawn(move || read_text_file(&fifo));
let error = reader.join().unwrap().unwrap_err();
assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);

let error = read_text_file(dir.path()).unwrap_err();
Expand Down Expand Up @@ -1270,7 +1273,7 @@ mod tests {
let path = dir.path().join("result.json");
std::fs::write(&path, b"complete old bytes\n").unwrap();
let identity = local_writer_identity();
for attempt in 0..1000u32 {
for attempt in 0..atomic_create_attempts() {
std::fs::write(
dir.path().join(atomic_temp_file_name(
"result.json",
Expand Down
43 changes: 0 additions & 43 deletions tests/attest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,49 +660,6 @@ fn the_list_variable_does_not_conflict_with_the_recorded_list() {
assert_eq!(typed.status.code(), Some(2));
}

#[test]
fn malformed_verify_input_names_the_producer_and_path() {
let tree = Tree::new();
let root = tree.path();
let mut site = bare_site(root);
site.push_str(&format!(
"\n[attest]\nenabled = true\nlog_dir = \"{r}/log\"\nkey = \"{r}/key.pem\"\norigin = \"example.org/inputs\"\ntrusted = [\"example.org/inputs+abcd+AAAA\"]\neasyconfigs = [\"{r}/easyconfigs\"]\n",
r = root.display()
));
std::fs::create_dir_all(root.join("easyconfigs")).unwrap();
std::fs::write(root.join("key.pem"), "k\n").unwrap();
std::fs::write(root.join("site.toml"), site).unwrap();
std::fs::write(root.join("list.txt"), "Foo-1.0.eb\n").unwrap();
let from = root.join("plan.json");
std::fs::write(&from, "{").unwrap();

let output = tree.run(
&[
"verify",
"--site",
root.join("site.toml").to_str().unwrap(),
"--list",
root.join("list.txt").to_str().unwrap(),
"--target",
"cpu",
"--build-type",
"production",
"--from",
from.to_str().unwrap(),
],
&[],
);

assert_eq!(output.status.code(), Some(2));
assert_eq!(
String::from_utf8_lossy(&output.stderr),
format!(
"ERROR [main] -: eb-pipeline plan wrote invalid JSON to {}: EOF while parsing an object at line 1 column 1\n",
from.display()
)
);
}

#[test]
fn a_stale_record_temporary_does_not_block_attestation() {
let tree = Tree::new();
Expand Down
Loading
Loading