Help us shape the future of Go! Take the 2026 Go Developer Survey

tclextract

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tclextract pulls literal SQL test cases out of SQLite's TCL test scripts (test/*.test in the SQLite source tree).

It recognizes the dominant test commands, which all take the SQL as their second word:

do_execsql_test  <name> {SQL} ?{expected}?
do_catchsql_test <name> {SQL} {expected}
do_eqp_test      <name> {SQL} {plan}

plus the older style used by e.g. tokenize.test, but only when the body is exactly one execsql/catchsql call:

do_test <name> {catchsql {SQL}} {expected}
do_test <name> {execsql {SQL}} {expected}

Only the name and the SQL block are used; expected values are re-derived from a real SQLite build by cmd/regenerate-parse, so TCL expectations are ignored. Extraction is deliberately conservative: any case whose SQL block is not a plain TCL brace literal — it contains `$` (variable substitution), `[` (command substitution), or `\` (backslash escapes change brace counting) — is skipped and counted, never guessed at.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(base string, src []byte) ([]Case, Stats)

File extracts all cases from one TCL test script. base names the script (e.g. "select1") and seeds generated case names.

Types

type Case

type Case struct {
	Name string // TCL test name, or a generated one if the name was dynamic
	SQL  string // literal SQL, outer braces removed, normalized to end in "\n"
}

Case is one extracted test case.

type Stats

type Stats struct {
	Found          int // command occurrences seen
	Extracted      int
	SkippedSubst   int // SQL contained $, [ or \
	SkippedForm    int // SQL argument was not a brace literal / malformed command
	GeneratedNames int // dynamic test names replaced with file-local ones
}

Stats reports what extraction skipped, so coverage loss is visible.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL