Skip to content

Commit 7c38d99

Browse files
committed
Tests + Changelog for 0.3.4 release
1 parent d133163 commit 7c38d99

File tree

4 files changed

+85
-10
lines changed

4 files changed

+85
-10
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
Changelog
22
=========
33

4+
[v0.3.4](https://github.com/IvanIsCoding/celq/releases/tag/v0.3.4) - 2026-03-07
5+
------------------------------------------------------------------------
6+
7+
### Fixed
8+
9+
* Fixed `--greppable` so NDJSON input prints all matching results instead of only the last one.
10+
* Fixed conflicting input-format flags so combinations such as `--from-xml --from-yaml` are rejected by the CLI.
11+
12+
### Miscellaneous
13+
14+
* Bumped the TOML parser (`toml` -> 1.0.6).
15+
* Bumped the YAML parser (`serde-saphyr` -> 0.0.21).
16+
417
[v0.3.3](https://github.com/IvanIsCoding/celq/releases/tag/v0.3.1) - 2026-02-05
518
------------------------------------------------------------------------
619

@@ -78,4 +91,4 @@ Changelog
7891
[v0.1.0](https://github.com/IvanIsCoding/celq/releases/tag/v0.1.0) - 2026-01-04
7992
------------------------------------------------------------------------
8093

81-
Initial release with support for JSON and JSON5!
94+
Initial release with support for JSON and JSON5!

src/cli.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,14 @@ impl std::str::FromStr for Argument {
8282
),
8383
group(
8484
ArgGroup::new("input_format")
85-
.args(&["slurp", "from_json5", "from_toml", "from_yaml", "from_gron"])
85+
.args(&[
86+
"slurp",
87+
"from_json5",
88+
"from_toml",
89+
"from_yaml",
90+
"from_xml",
91+
"from_gron",
92+
])
8693
),
8794
group(
8895
ArgGroup::new("output_style")

src/main.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,12 @@ fn main() -> io::Result<()> {
9595
Ok(results) => {
9696
// Print all outputs, unless void mode is enabled
9797
if !cli.void {
98-
if !cli.greppable {
99-
for (output, _) in &results {
98+
for (output, _) in &results {
99+
if cli.greppable {
100+
print!("{}", output);
101+
} else {
100102
println!("{}", output);
101103
}
102-
} else {
103-
let last_gron = results
104-
.last()
105-
.map(|(output, _)| output.as_str())
106-
.unwrap_or("");
107-
println!("{}", last_gron);
108104
}
109105
}
110106

tests/golden.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,42 @@ fn golden_test(args: &[&str], input: &str, out_ex: &str) -> io::Result<()> {
6363
Ok(())
6464
}
6565

66+
#[cfg(all(feature = "from-xml", feature = "from-yaml"))]
67+
fn golden_test_failure(args: &[&str], input: &str, err_ex: &str) -> io::Result<()> {
68+
let mut child = process::Command::new(env!("CARGO_BIN_EXE_celq"))
69+
.args(args)
70+
.stdin(process::Stdio::piped())
71+
.stdout(process::Stdio::piped())
72+
.stderr(process::Stdio::piped())
73+
.spawn()?;
74+
75+
use io::Write;
76+
{
77+
let mut stdin = child.stdin.take().unwrap();
78+
stdin.write_all(input.as_bytes())?;
79+
drop(stdin);
80+
}
81+
82+
let output = child.wait_with_output()?;
83+
84+
assert!(
85+
!output.status.success(),
86+
"Expected failure, but process succeeded with stdout: {}",
87+
String::from_utf8_lossy(&output.stdout)
88+
);
89+
90+
let err_act = str::from_utf8(&output.stderr).expect("invalid UTF-8 in stderr");
91+
let err_act = err_act.replace('\r', "");
92+
assert!(
93+
err_act.contains(err_ex),
94+
"Expected stderr to contain:\n{}\n---\nActual stderr:\n{}\n---",
95+
err_ex,
96+
err_act
97+
);
98+
99+
Ok(())
100+
}
101+
66102
macro_rules! test {
67103
($name:ident, $args:expr, $input:expr, $output:expr) => {
68104
#[test]
@@ -771,6 +807,19 @@ json.person.name = "Bob";
771807
"#
772808
);
773809

810+
#[cfg(feature = "greppable")]
811+
test!(
812+
greppable_ndjson_prints_all_results,
813+
&["--greppable", "-S", "this"],
814+
r#"{"a":1}
815+
{"b":2}"#,
816+
r#"json = {};
817+
json.a = 1;
818+
json = {};
819+
json.b = 2;
820+
"#
821+
);
822+
774823
#[cfg(feature = "greppable")]
775824
test!(
776825
greppable_json5,
@@ -992,6 +1041,16 @@ fn test_slice_fails_without_extensions() -> io::Result<()> {
9921041
Ok(())
9931042
}
9941043

1044+
#[cfg(all(feature = "from-xml", feature = "from-yaml"))]
1045+
#[test]
1046+
fn test_conflicting_input_format_flags_fail() -> io::Result<()> {
1047+
golden_test_failure(
1048+
&["--from-xml", "--from-yaml", "this"],
1049+
"<a>1</a>",
1050+
"the argument '--from-xml' cannot be used with '--from-yaml'",
1051+
)
1052+
}
1053+
9951054
// XML tests
9961055

9971056
// XML with nested elements

0 commit comments

Comments
 (0)