Skip to content

test(c): isolate test_simple_api boxlite home from shared ~/.boxlite#616

Open
G4614 wants to merge 1 commit into
boxlite-ai:mainfrom
G4614:fix/c-test-isolated-home
Open

test(c): isolate test_simple_api boxlite home from shared ~/.boxlite#616
G4614 wants to merge 1 commit into
boxlite-ai:mainfrom
G4614:fix/c-test-isolated-home

Conversation

@G4614
Copy link
Copy Markdown
Contributor

@G4614 G4614 commented May 28, 2026

set BOXLITE_HOME in test_simple_api like test_null_callback (dev only)

@G4614 G4614 force-pushed the fix/c-test-isolated-home branch from 098d535 to 792d76a Compare May 28, 2026 10:21
test_simple_api calls boxlite_simple_new, which uses BoxOptions::default()
— home_dir resolves via default_home_dir() to ~/.boxlite, a shared,
persistent, cross-version directory. A boxlite built with a newer DB schema
leaves a forward-incompatible db there; an older-schema build then fails at
box create with "Schema version mismatch" (migrations only go forward, so a
newer db has no path back). The test was not hermetic — it depended on and
was polluted by shared global state. On a persistent CI runner that keeps
~/.boxlite across runs, a schema bump can break later older-base PRs this way.

The Simple API has no home parameter, so the only lever is BOXLITE_HOME. Run
test_simple_api under a fresh per-invocation home — mktemp -d
/tmp/boxlite-c-simple.XXXXXX, exported as BOXLITE_HOME and removed on exit —
via a shell wrapper in add_test. Each run gets its own db, isolated from
whatever other boxlite versions left on the machine, matching the /tmp temp
-home convention the Rust/Python/Node/Go tests already use.

Verified: make test:integration:c CTEST_FILTER="-R test_simple_api" → 9/9
sub-tests pass, 100%; the per-run /tmp home is cleaned up after.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@G4614 G4614 force-pushed the fix/c-test-isolated-home branch from 792d76a to 6924072 Compare May 28, 2026 10:22
@G4614 G4614 marked this pull request as ready for review May 28, 2026 13:53
@G4614
Copy link
Copy Markdown
Contributor Author

G4614 commented May 28, 2026

Scope note — why this is test-only, and the one user-facing exception:

Schema version mismatch (db/mod.rs:117) only fires when the on-disk DB is newer than the running process; migrations are forward-only, so an upgrade auto-migrates and a normal single-install user never hits it. The common trigger is a dev/CI condition — many branch builds sharing one persistent ~/.boxlite, where a schema-bumping PR poisons the home for every older-base build after it. That's exactly what this isolates.

The one user-facing path is a downgrade: running an older boxlite after a newer one has written ~/.boxlite. It's uncommon, and the error is already actionable ("Upgrade boxlite to a newer version"), so there's nothing to fix in production here — isolating the test's home is the right and complete scope.

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