Skip to content

Local Testing

This guide is for testing a local checkout of Graft.

Build the CLI:

Terminal window
cargo build -p graft-tool --bin graft --release

Build the SQLite extension:

Terminal window
cargo build -p graft-ext --release

Common artifact paths:

target/release/graft
target/release/libgraft_ext.dylib # macOS
target/release/libgraft_ext.so # Linux
Terminal window
which graft
graft --help
graft sql --help

Run a full workflow:

Terminal window
tmp=$(mktemp -d)
cd "$tmp"
graft init
graft sql "CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT); INSERT INTO users(name) VALUES ('Alice');"
graft add app.db
graft commit -m "initial"
graft sql "INSERT INTO users(name) VALUES ('Bob');"
graft status
graft add app.db
graft commit -m "add bob"
graft diff HEAD~1 HEAD app.db

Expected final diff shape:

modified: app.db
from: 2 page(s), 1 range(s)
to: 2 page(s), 1 range(s)

In the SQLite shell:

.load /absolute/path/to/target/release/libgraft_ext
.open "file:/tmp/graft-ext-demo/app.db?vfs=graft"
PRAGMA graft_init;
CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO users(name) VALUES ('Alice');
PRAGMA graft_status;

If you edit the database with plain sqlite3 app.db without the Graft VFS, Graft will not observe those writes as VFS writes. For repository-mode testing, prefer graft sql or an SQLite connection opened with vfs=graft.

Terminal window
cargo fmt --check
cargo check -p graft-sqlite -p graft-tool
cargo test -p graft-tool
cargo test -p graft-test --test sqlite -- --test-threads=1