Skip to content

Commit

Permalink
Add version to slurm output, fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars T Hansen committed Jan 15, 2025
1 parent ecf7f20 commit 8ef8e26
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ pub fn test_json() {
a.push_o(o);
a.push_e();
a.push_s(r#"stri\ng"#.to_string());
let expect =
concat!(r#"[{"o":{},"a":[],"s":"hello, \"sir\"","u":123,"i":-12,"f":12.5},,"stri\\ng"]"#,
"\n",
);
let expect = concat!(
r#"[{"o":{},"a":[],"s":"hello, \"sir\"","u":123,"i":-12,"f":12.5},,"stri\\ng"]"#,
"\n",
);
let mut output = Vec::new();
write_json(&mut output, &Value::A(a));
let got = String::from_utf8_lossy(&output);
Expand Down Expand Up @@ -355,7 +355,10 @@ pub fn test_csv() {
ab.push_u(x);
}
o.push_a("x", ab);
let expect = concat!(r#"o=,a=1||2,"s=hello, ""sir""",u=123,i=-12,f=12.5,x=)(t*1b"#, "\n");
let expect = concat!(
r#"o=,a=1||2,"s=hello, ""sir""",u=123,i=-12,f=12.5,x=)(t*1b"#,
"\n"
);
let mut output = Vec::new();
write_csv(&mut output, &Value::O(o));
let got = String::from_utf8_lossy(&output);
Expand Down
5 changes: 4 additions & 1 deletion src/slurmjobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ fn format_jobs(
let fields = &field_store[..field_names.len()];

let mut output_line = output::Object::new();
output_line.push_s("v", VERSION.to_string());
if !json {
output_line.push_s("v", VERSION.to_string());
}
for (i, name) in field_names.iter().enumerate() {
let mut val = fields[i].to_string();
let is_zero = val.is_empty()
Expand Down Expand Up @@ -203,6 +205,7 @@ fn format_jobs(
}
if json {
let mut envelope = output::Object::new();
envelope.push_s("v", VERSION.to_string());
envelope.push_a("jobs", jobs);
output::write_json(writer, &output::Value::O(envelope));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/slurm-syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi

# Check that sacct is available, or we should do nothing

if [[ !$(command -v sacct) ]]; then
if [[ $(command -v sacct) == "" ]]; then
echo "No sacct"
exit 0
fi
Expand Down

0 comments on commit 8ef8e26

Please sign in to comment.