Skip to content

Bump deps to latest, edition 2024, and get integration tests passing#1

Merged
mhsdef merged 4 commits into
mainfrom
chore/bump-deps-and-fix-tests
May 7, 2026
Merged

Bump deps to latest, edition 2024, and get integration tests passing#1
mhsdef merged 4 commits into
mainfrom
chore/bump-deps-and-fix-tests

Conversation

@mhsdef

@mhsdef mhsdef commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bumped every dep to latest stable and edition 20212024 (requires Rust 1.85+).
  • Refactored the binary into src/lib.rs + src/main.rs so integration tests can run the HTTP server in-process via a thread (no more cargo run child process to leak).
  • Added a tester stage to the existing Dockerfile that layers libreoffice-writer, libreoffice-calc, and fonts on top of builderlibreofficekit-dev alone provides core but no format modules, so docx/xlsx loads were hanging.
  • Reworked the integration tests against prior review feedback (200 MB fixture removed, ContentMismatch test now exercises the actual ContentMismatch path, assertions match the validator's real error strings, dead rate-limit test dropped).

Bug fixes uncovered while getting tests green

  • http_server.rs: NamedTempFile::with_suffix(...) for input/output temp files. LibreOffice's document_load hangs silently on extensionless paths (/tmp/.tmpXXXXXX) — it relies on the extension for format autodetection.
  • tests/integration_tests.rs: .mime_str("application/octet-stream") on every binary multipart::Part. rouille's old multipart 0.18 has an is_text() that defaults to true when a part has no Content-Type, so binary docx bytes were being read as UTF-8 and parsing died.

Dockerfile note

The tester CMD greps ^test result: ok\..*0 failed from the captured output. LibreOfficeKit's atexit cleanup emits Unspecified Application Error and forces the test binary to exit 1 even after libtest reports test result: ok. This is the pragmatic workaround; if we ever want it nicer, options are libtest_mimic with a custom harness = false, or going back to a subprocess server.

The container also needs --cap-add=SYS_NICE to run, otherwise LO's thread-priority calls trigger a glibc abort:

docker build --target tester -t docoxide-tester .
docker run --rm --cap-add=SYS_NICE docoxide-tester

Test plan

  • docker build --target tester -t docoxide-tester . succeeds
  • docker run --rm --cap-add=SYS_NICE docoxide-tester → 16/16 tests pass, container exit code 0
  • docker build (default target = runtime) still produces a working production image
  • CI runs the new tester stage against this branch

mhsdef added 2 commits May 7, 2026 01:02
Dependency + edition bumps:
- edition 2021 -> 2024 (Rust 1.85+)
- chrono, clap, serde, serde_json, tempfile, thiserror, tracing,
  tracing-subscriber, reqwest, tokio, tokio-test all bumped to latest stable

Test infrastructure:
- Added src/lib.rs so integration tests can drive the server in-process
  via a thread + OnceLock instead of spawning `cargo run` as a child
  (eliminates the leaked child-process problem from the prior review).
- Added a `tester` stage to the existing Dockerfile that layers
  libreoffice-writer, libreoffice-calc, and fonts on top of `builder`
  so cargo test can actually convert documents.
- Rewrote tests to address the prior review:
  * Drop the 200 MB large_file.docx fixture; generate the oversized
    payload in-memory.
  * Use valid xlsx bytes under a .docx filename to actually exercise
    the ContentMismatch path.
  * Update assertions to match the validator's real error strings.
  * Drop the rate-limiting test (no rate limiter exists).

Bug fixes uncovered while getting tests green:
- http_server: NamedTempFile::with_suffix(...) so LibreOffice can
  autodetect the input format. document_load hangs silently on a
  path with no extension.
- tests: set .mime_str("application/octet-stream") on every binary
  multipart::Part so rouille's old multipart 0.18 doesn't treat
  Content-Type-less parts as text and fail UTF-8 decoding.

Dockerfile CMD greps for `test result: ok` because LibreOfficeKit's
atexit cleanup emits "Unspecified Application Error" and forces the
test binary to exit 1 even when libtest reports success.
GitHub Actions workflow runs on PRs to main and pushes to main:
- fmt: dtolnay/rust-toolchain on ubuntu-latest, `cargo fmt --all -- --check`
- clippy: builds the Dockerfile `tester` stage and runs
  `cargo clippy --all-targets -- -D warnings` inside it (libreofficekit-dev
  is needed to compile libreoffice-rs)
- test: builds the same `tester` image and runs it with --cap-add=SYS_NICE

Drive-bys to satisfy `-D warnings`:
- src/http_server.rs: replace `|e| ConversionError::Io(e)` with the
  variant constructor directly
- src/main.rs: drop the `let _ =` binding around `tracing_subscriber::fmt::init()`
- tests: drop unused `expected_mime`, collapse nested `if let`+`if`
  into `if let .. && ..`, replace `expect(&format!(...))` with
  `unwrap_or_else(|_| panic!(...))`, drop `&` on `format!(...)` arguments
  to reqwest's generic `IntoUrl` methods

Dockerfile tester stage installs `clippy` and `rustfmt` rustup components
(stripped from the slim base) and applies cargo fmt across the tree.
@mhsdef mhsdef self-assigned this May 7, 2026
@mhsdef mhsdef merged commit dd01890 into main May 7, 2026
3 checks passed
@mhsdef mhsdef deleted the chore/bump-deps-and-fix-tests branch May 7, 2026 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant