Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

app record: say what it shows for one skipped curl example (#1280)

jakalijeyc43bbe109f69
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 714e9c9d..d38d7036 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -103,6 +103,8 @@
included (`:save!` names `save!`, not `save`; `:+` and `:[]=` stay listed); before,
`:soundex_str` also matched `soundex` as a substring, so the export was listed twice (found
porting the `text` gem's `soundex.rb`, by @cfreyes7).
+- `app record --http` says "nothing checks what it shows" for one README `curl` line it cannot read,
+ not "what it show" (#1260 by @jakalijey).
- Kotlin: a call of `HashMap(...)`, `HashSet(...)`, `hashMapOf(...)` or `hashSetOf(...)` is a hash
iteration order risk, with no import needed, and only `java.util.HashMap`/`HashSet` and
`kotlin.collections.HashMap`/`HashSet` imports count. Before, only an import line was read, so
diff --git a/src/http.rs b/src/http.rs
index e43fa78a..d3ff3e3a 100644
--- a/src/http.rs
+++ b/src/http.rs
@@ -1977,17 +1977,7 @@ pub(crate) fn record(
});
let skipped_lines = skipped_lines.into_inner();
if !skipped_lines.is_empty() {
- eprintln!(
- "skipped {} curl example{} the recorder cannot read (an option it does not know, or a shell operator), so nothing checks what {} show: {}",
- skipped_lines.len(),
- if skipped_lines.len() == 1 { "" } else { "s" },
- if skipped_lines.len() == 1 {
- "it"
- } else {
- "they"
- },
- skipped_lines.join(" | ")
- );
+ eprintln!("{}", skipped_curl_warning(&skipped_lines));
}
let inputs = match opts.inputs {
Some(path) => read_inputs(path, repo)?,
@@ -2825,10 +2815,46 @@ fn decode_base64_strict(input: &str) -> Result<Vec<u8>> {
Ok(out)
}
+/// What `app record` says about README `curl` lines it could not read: nothing checks them.
+fn skipped_curl_warning(lines: &[String]) -> String {
+ let (plural, what) = if lines.len() == 1 {
+ ("", "it shows")
+ } else {
+ ("s", "they show")
+ };
+ format!(
+ "skipped {} curl example{plural} the recorder cannot read (an option it does not know, or a shell operator), so nothing checks what {what}: {}",
+ lines.len(),
+ lines.join(" | ")
+ )
+}
+
#[cfg(test)]
mod tests {
use super::*;
+ #[test]
+ fn the_skipped_curl_warning_agrees_with_its_count() {
+ let one = skipped_curl_warning(&["curl --frobnicate http://localhost:8080/b".into()]);
+ assert!(
+ one.starts_with("skipped 1 curl example the recorder"),
+ "{one}"
+ );
+ assert!(
+ one.ends_with("what it shows: curl --frobnicate http://localhost:8080/b"),
+ "{one}"
+ );
+ let two = skipped_curl_warning(&["curl -Z a".into(), "curl a | jq".into()]);
+ assert!(
+ two.starts_with("skipped 2 curl examples the recorder"),
+ "{two}"
+ );
+ assert!(
+ two.ends_with("what they show: curl -Z a | curl a | jq"),
+ "{two}"
+ );
+ }
+
/// A child that another thread spawns holds a copy of every socket until it execs, so a probe
/// that listened would still accept connections after it returned.
#[cfg(target_os = "linux")]