Artifact a6ea720d4eaf536182911b7ac4d01385327819bb5215a87f56247727498bb300:
- File
db/driver/ncruces/ncruces_test.go
— part of check-in
[6273a0750d]
at
2026-07-22 23:03:24
on branch trunk
— fix: correct go.mod module path to go-libfossil (#76) (#117)
* fix: correct go.mod module path to go-libfossil (#76)
The module directive still declared github.com/danmestas/libfossil after the repository was renamed to go-libfossil. pkg.go.dev/godoc scraping matches the declared module path against its hosting path, so the stale path broke SDK doc generation.
Rename the module path across all four in-repo modules (root, the two db/driver submodules, observer/otel, and docs/site) and every internal import, plus the release workflow, the doc-generation script, and the docs.
No tag has been published under the go-libfossil path yet, so the cross-module requires cannot resolve from the proxy. Add replace directives pointing the in-repo requires at their local directories so GOWORK=off builds and the CI matrix resolve without a published version. These replaces are ignored by downstream consumers and can be dropped once new-path tags are cut.
* Guard releases against replace directives; regenerate SDK docs
The go-libfossil rename bridges the in-repo modules with `replace` directives. Go refuses a main module that carries them, so a tag cut while they are present breaks `go install .../cmd/libfossil@<tag>` and every `@version` fetch of the driver submodules. Add a Release workflow step that fails the job before anything is published if any tracked go.mod still contains a replace directive, so the bridge is a CI-enforced TODO rather than a silent landmine. The step comment records what unblocks a release: re-tag the submodules with the corrected module paths, bump the root requires, then drop the replace blocks.
Regenerate the SDK reference docs. The previous pass only substituted URLs over the pre-existing generated files, leaving stale signatures (Repo.Timeline was still documented as taking LogOpts rather than TimelineOpts). Note that gomarkdoc must be run outside a git worktree — inside one it silently strips every source link.
Also reword the README rename note, which read as though the import path had not changed, and re-sort the ncruces require block. (user: [email protected], size: 2914) [annotate] [blame] [check-ins using]
//go:build !js package ncruces import ( "context" "database/sql" "path/filepath" "strings" "sync" "testing" "time" "github.com/danmestas/go-libfossil/db" ) // TestBuildDSN_TxlockImmediate verifies the registered DSN builder always // emits _txlock=immediate, regardless of how many pragmas are merged in. // Mirrors the modernc driver test for the SHARED→RESERVED upgrade race // documented in libfossil issue #33. func TestBuildDSN_TxlockImmediate(t *testing.T) { t.Parallel() cases := []struct { name string pragmas map[string]string }{ {"no pragmas", nil}, {"empty pragmas", map[string]string{}}, {"with pragmas", map[string]string{"journal_mode": "WAL", "busy_timeout": "5000"}}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { t.Parallel() dsn := buildDSN("/tmp/x.db", tc.pragmas) if !strings.Contains(dsn, "_txlock=immediate") { t.Fatalf("buildDSN missing _txlock=immediate: %q", dsn) } }) } } // TestConcurrentWritersDoNotRace exercises the failure mode from issue #33 // against the ncruces driver. See the modernc-side test for the full // motivation. With _txlock=immediate in the DSN, both writers serialize // at BEGIN and neither fails with SQLITE_BUSY. func TestConcurrentWritersDoNotRace(t *testing.T) { t.Parallel() const iterations = 25 path := filepath.Join(t.TempDir(), "concurrent.db") dsn := buildDSN(path, db.DefaultPragmas()) dbA, err := sql.Open("sqlite3", dsn) if err != nil { t.Fatalf("open A: %v", err) } defer dbA.Close() dbB, err := sql.Open("sqlite3", dsn) if err != nil { t.Fatalf("open B: %v", err) } defer dbB.Close() if _, err := dbA.Exec("CREATE TABLE t(x INTEGER)"); err != nil { t.Fatalf("create table: %v", err) } var ok, fail int var failErrs []error for range iterations { var wg sync.WaitGroup wg.Add(2) errs := make(chan error, 2) begin := make(chan struct{}) work := func(d *sql.DB, val int) { defer wg.Done() <-begin tx, err := d.BeginTx(context.Background(), nil) if err != nil { errs <- err return } var n int if err := tx.QueryRow("SELECT count(*) FROM t").Scan(&n); err != nil { _ = tx.Rollback() errs <- err return } time.Sleep(5 * time.Millisecond) if _, err := tx.Exec("INSERT INTO t VALUES (?)", val); err != nil { _ = tx.Rollback() errs <- err return } errs <- tx.Commit() } go work(dbA, 1) go work(dbB, 2) close(begin) wg.Wait() close(errs) for e := range errs { if e == nil { ok++ } else { fail++ failErrs = append(failErrs, e) } } } if fail != 0 { var sample error if len(failErrs) > 0 { sample = failErrs[0] } t.Fatalf("expected zero SQLITE_BUSY across %d iterations, got fail=%d ok=%d; first error: %v", iterations, fail, ok, sample) } if ok != 2*iterations { t.Fatalf("expected ok=%d, got %d", 2*iterations, ok) } }