S039: connector test waits for the arrival instead of racing the answer; full suite green after S044
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
parent
6d0ab7807b
commit
7b19a32b0d
4 changed files with 83 additions and 5 deletions
|
|
@ -157,7 +157,7 @@ async fn connector_checks() {
|
|||
assert_eq!(code(&r), 200, "{r}");
|
||||
assert!(r.contains("\"accepted\":1") && r.contains("\"refused\":[]"), "{r}");
|
||||
assert!(!r.to_ascii_lowercase().contains("access-control"));
|
||||
let a = rx.try_recv().expect("arrival");
|
||||
let a = next(&mut rx).await;
|
||||
let l = &a.links[0];
|
||||
assert_eq!(l.name.as_deref(), Some("a.zip"));
|
||||
assert_eq!(l.page.as_deref(), Some("https://example.com/"));
|
||||
|
|
@ -199,7 +199,7 @@ async fn connector_checks() {
|
|||
let body = r#"{"url":"https://h.test/f","headers":{"X-A":"1\r\nX-B: 2","Connection":"close","Range":"bytes=5-","Accept-Encoding":"gzip","If-None-Match":"x","Authorization":"Bearer t"}}"#;
|
||||
let r = post(p, "", "application/json", body);
|
||||
assert_eq!(code(&r), 200, "{r}");
|
||||
let l = &rx.try_recv().unwrap().links[0];
|
||||
let l = &next(&mut rx).await.links[0];
|
||||
for d in ["X-A", "Connection", "Range", "Accept-Encoding", "If-None-Match"] {
|
||||
assert!(l.dropped.iter().any(|x| x == d), "{d} not dropped: {:?}", l.dropped);
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ async fn connector_checks() {
|
|||
let r = post(p, "", "application/json", &list.to_string());
|
||||
assert_eq!(code(&r), 200, "{r}");
|
||||
assert!(r.contains("\"accepted\":1"), "{r}");
|
||||
let l = &rx.try_recv().unwrap().links[0];
|
||||
let l = &next(&mut rx).await.links[0];
|
||||
assert_eq!(l.url, "https://h/f");
|
||||
assert!(l.secret.as_ref().unwrap().login.is_some());
|
||||
// 9: names
|
||||
|
|
@ -219,12 +219,12 @@ async fn connector_checks() {
|
|||
let _ = ok;
|
||||
let b = serde_json::json!({"url":"https://h.test/f","filename":n}).to_string();
|
||||
post(p, "", "application/json", &b);
|
||||
let nm = rx.try_recv().unwrap().links[0].name.clone().unwrap_or_default();
|
||||
let nm = next(&mut rx).await.links[0].name.clone().unwrap_or_default();
|
||||
assert!(!nm.contains('/') && !nm.starts_with('.') && !nm.contains('\0'), "{n:?} -> {nm:?}");
|
||||
}
|
||||
let b = serde_json::json!({"url":"https://h.test/f","filename":"n".repeat(400)}).to_string();
|
||||
post(p, "", "application/json", &b);
|
||||
assert!(rx.try_recv().unwrap().links[0].name.clone().unwrap_or_default().len() <= 255);
|
||||
assert!(next(&mut rx).await.links[0].name.clone().unwrap_or_default().len() <= 255);
|
||||
// 12: GET /
|
||||
let r = send(p, format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{p}\r\nConnection: close\r\n\r\n").as_bytes());
|
||||
assert_eq!(code(&r), 200);
|
||||
|
|
@ -350,3 +350,10 @@ async fn incoming_task_10() {
|
|||
assert_eq!(secrets.load(&name).await.unwrap().cookies.as_deref(), Some("k=v"));
|
||||
assert!(!task.headers.iter().any(|(k, _)| k.eq_ignore_ascii_case("cookie")));
|
||||
}
|
||||
|
||||
/// The next arrival; the answer can reach the client a moment before the arrival reaches the channel.
|
||||
async fn next(
|
||||
rx: &mut tokio::sync::mpsc::UnboundedReceiver<medlar_core::connector::Arrival>,
|
||||
) -> medlar_core::connector::Arrival {
|
||||
tokio::time::timeout(Duration::from_secs(3), rx.recv()).await.expect("arrival in time").expect("open")
|
||||
}
|
||||
|
|
|
|||
13
packaging/install.sh
Executable file
13
packaging/install.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
# Installs Medlar for the current user: ~/.local/bin, ~/.local/share/{applications,icons,metainfo}. No root.
|
||||
set -eu
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
prefix=${PREFIX:-$HOME/.local}
|
||||
install -Dm755 "$here/bin/medlar" "$prefix/bin/medlar"
|
||||
install -Dm644 "$here/share/medlar.svg" "$prefix/share/icons/hicolor/scalable/apps/medlar.svg"
|
||||
install -Dm644 "$here/share/medlar.metainfo.xml" "$prefix/share/metainfo/medlar.metainfo.xml"
|
||||
mkdir -p "$prefix/share/applications"
|
||||
sed "s|^Exec=medlar|Exec=$prefix/bin/medlar|" "$here/share/medlar.desktop" > "$prefix/share/applications/medlar.desktop"
|
||||
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$prefix/share/applications" || true
|
||||
echo "Medlar installed in $prefix/bin/medlar"
|
||||
case ":$PATH:" in *":$prefix/bin:"*) ;; *) echo "Note: $prefix/bin is not on your PATH." ;; esac
|
||||
12
packaging/uninstall.sh
Executable file
12
packaging/uninstall.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
# Removes what install.sh put in place. Downloads and settings (~/.config/medlar, ~/.local/share/medlar) stay unless you pass --purge.
|
||||
set -eu
|
||||
prefix=${PREFIX:-$HOME/.local}
|
||||
rm -f "$prefix/bin/medlar" "$prefix/share/applications/medlar.desktop" \
|
||||
"$prefix/share/icons/hicolor/scalable/apps/medlar.svg" "$prefix/share/metainfo/medlar.metainfo.xml"
|
||||
if [ "${1:-}" = "--purge" ]; then
|
||||
rm -rf "${XDG_CONFIG_HOME:-$HOME/.config}/medlar" "${XDG_DATA_HOME:-$HOME/.local/share}/medlar" \
|
||||
"${XDG_STATE_HOME:-$HOME/.local/state}/medlar" "${XDG_CACHE_HOME:-$HOME/.cache}/medlar"
|
||||
echo "Settings and data removed. Downloaded files were not touched."
|
||||
fi
|
||||
echo "Medlar removed."
|
||||
46
tools/package.sh
Executable file
46
tools/package.sh
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
# Builds dist/Medlar-<version>-Linux-x86_64.tar.gz, dist/Medlar-<version>-x86_64.AppImage and dist/SHA256SUMS-<version>.
|
||||
# Nothing is downloaded. appimagetool comes from ~/Projects/Mulberry/dist and runs extracted (no FUSE, no runtime fetch).
|
||||
# Not bundled: system libraries (only libc, libm, libgcc_s are linked), yt-dlp, ffmpeg. Never writes to releases/.
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
cd "$root"
|
||||
ver=$(sed -n '/^\[workspace.package\]/,/^$/s/^version = "\(.*\)"/\1/p' Cargo.toml)
|
||||
[ "${SKIP_BUILD:-}" = 1 ] || nice cargo build --release -q -j 2 -p medlar
|
||||
bin=$root/target/release/medlar
|
||||
[ "$("$bin" --version)" = "medlar $ver" ] || [ -n "$("$bin" --version | grep -F "$ver")" ] || { echo "binary version differs from $ver" >&2; exit 1; }
|
||||
out=$root/dist; rm -rf "$out"; mkdir -p "$out"
|
||||
work=$(mktemp -d); trap 'rm -rf "$work"' EXIT
|
||||
|
||||
# tar.gz
|
||||
t=$work/medlar-$ver
|
||||
mkdir -p "$t/bin" "$t/share"
|
||||
cp "$bin" "$t/bin/medlar"
|
||||
cp assets/medlar.svg assets/medlar.desktop assets/medlar.metainfo.xml "$t/share/"
|
||||
cp packaging/install.sh packaging/uninstall.sh README.md "$t/"
|
||||
cp assets/Rubik-OFL.txt "$t/share/"
|
||||
chmod +x "$t/install.sh" "$t/uninstall.sh"
|
||||
tar -C "$work" --owner=0 --group=0 -czf "$out/Medlar-$ver-Linux-x86_64.tar.gz" "medlar-$ver"
|
||||
|
||||
# AppImage
|
||||
a=$work/AppDir
|
||||
mkdir -p "$a/usr/bin" "$a/usr/share/applications" "$a/usr/share/icons/hicolor/scalable/apps" "$a/usr/share/metainfo"
|
||||
cp "$bin" "$a/usr/bin/medlar"
|
||||
cp assets/medlar.desktop "$a/usr/share/applications/"; cp assets/medlar.desktop "$a/"
|
||||
cp assets/medlar.svg "$a/"; cp assets/medlar.svg "$a/usr/share/icons/hicolor/scalable/apps/"
|
||||
cp assets/medlar.metainfo.xml "$a/usr/share/metainfo/"
|
||||
cat > "$a/AppRun" <<'RUN'
|
||||
#!/bin/sh
|
||||
here=$(dirname "$(readlink -f "$0")")
|
||||
# A file called `portable` beside the .AppImage keeps all data in medlar-data/ beside it.
|
||||
if [ -n "${APPIMAGE:-}" ] && [ -e "$(dirname "$APPIMAGE")/portable" ] && [ -z "${MEDLAR_HOME:-}" ]; then
|
||||
export MEDLAR_HOME="$(dirname "$APPIMAGE")/medlar-data"
|
||||
fi
|
||||
exec "$here/usr/bin/medlar" "$@"
|
||||
RUN
|
||||
chmod +x "$a/AppRun"
|
||||
cp ~/Projects/Mulberry/dist/appimagetool "$work/appimagetool"
|
||||
(cd "$work" && ./appimagetool --appimage-extract >/dev/null)
|
||||
ARCH=x86_64 "$work/squashfs-root/AppRun" --no-appstream "$a" "$out/Medlar-$ver-x86_64.AppImage" >"$work/ait.log" 2>&1 || { tail -20 "$work/ait.log"; exit 1; }
|
||||
(cd "$out" && sha256sum Medlar-"$ver"-* > "SHA256SUMS-$ver")
|
||||
ls -l "$out"
|
||||
Loading…
Reference in a new issue