interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / doc / tcl-extension-testing.md

264 lines · 9686 bytes Raw Blame History Rendered
1# Test Procedures For The SQLite TCL Extension
2
3## 1.0 Background
4
5The SQLite TCL extension logic (in the
6"[tclsqlite.c](/file/src/tclsqlite.c)" source
7file) is statically linked into "textfixture" executable
8which is the program used to do most of the testing
9associated with "make test", "make devtest", and/or
10"make releasetest". So the functionality of the SQLite
11TCL extension is thoroughly vetted during normal testing. The
12procedures below are designed to test the loadable extension
13aspect of the SQLite TCL extension, and in particular to verify
14that the "make tclextension-install" build target works and that
15an ordinary tclsh can subsequently run "package require sqlite3".
16
17This procedure can also be used as a template for how to set up
18a local TCL+SQLite development environment. In other words, it
19can be be used as a guide on how to compile per-user copies of
20Tcl that are used to develop, test, and debug SQLite. In that
21case, perhaps make minor changes to the procedure such as:
22
23 * Make TCLBUILD directory is permanent.
24 * Enable debugging symbols on the Tcl library build.
25 * Reduce the optimization level to -O0 for easier debugging.
26 * Also compile "wish" to go with each "tclsh".
27
28
29<a id="unix"></a>
30## 2.0 Testing On Unix-like Systems (Including Mac)
31
32See also the [](./compile-for-unix.md) document which provides another
33perspective on how to compile SQLite on unix-like systems.
34
35### 2.1 Setup
36
37<ol type="1">
38<li value="1">
39 [Fossil][] installed.
40<li> Check out source code and set environment variables:
41 <ol type="a">
42 <li> **TCLSOURCE** &rarr;
43 The top-level directory of a [Fossil][] check-out of the
44 [TCL source tree][tcl-fossil].
45 <li> **SQLITESOURCE** &rarr;
46 A Fossil check-out of the SQLite source tree.
47 <li> **TCLHOME** &rarr;
48 A directory that does not exist at the start of the test and which
49 will be deleted at the end of the test, and that will contain the
50 test builds of the TCL libraries and the SQLite TCL Extensions.
51 It is the top-most installation directory, i.e. the one provided
52 to Tcl's `./configure --prefix=/path/to/tcl`.
53 <li> **TCLVERSION** &rarr;
54 The `X.Y`-form version of Tcl being used: 8.6, 9.0, 9.1...
55 </ol>
56</ol>
57
58### 2.2 Testing TCL 8.x and 9.x on unix
59
60From a checked-out copy of [the core Tcl tree][tcl-fossil]
61
62<ol type="1">
63<li value="3">`TCLVERSION=8.6` <br>
64 &uarr; A version of your choice. This process has been tested with
65 values of 8.6, 9.0, and 9.1 (as of 2025-04-16). The out-of-life
66 version 8.5 fails some of `make devtest` for undetermined reasons.
67<li>`TCLHOME=$HOME/tcl/$TCLVERSION`
68<li>`TCLSOURCE=/path/to/tcl/checkout`
69<li>`SQLITESOURCE=/path/to/sqlite/checkout`
70<li>`rm -fr $TCLHOME` <br>
71 &uarr; Ensure that no stale Tcl installation is laying around.
72<li> `cd $TCLSOURCE`
73<li> `fossil up core-8-6-branch` <br>
74 &uarr; The branch corresponding to `$TCLVERSION`, e.g.
75 `core-9-0-branch` or `trunk`.
76<li> `fossil clean -x`
77<li> `cd unix`
78<li> `./configure --prefix=$TCLHOME --disable-shared` <br>
79 &uarr; The `--disable-shared` is to avoid the need to set `LD_LIBRARY_PATH`
80 when using this Tcl build.
81<li> `make install`
82<li> `cd $SQLITESOURCE`
83<li> `fossil clean -x`
84<li> `./configure --with-tcl=$TCLHOME --all`
85<li> `make tclextension-install` <br>
86 &uarr; Verify extension installed at
87 `$TCLHOME/lib/tcl${TCLVERSION}/sqlite<SQLITE_VERSION>`.
88<li> `make tclextension-list` <br>
89 &uarr; Verify TCL extension correctly installed.
90<li> `make tclextension-verify` <br>
91 &uarr; Verify that the correct version is installed.
92<li> `$TCLHOME/bin/tclsh[89].[0-9] test/testrunner.tcl release --explain` <br>
93 &uarr; Verify thousands of lines of output with no errors. Or
94 consider running "devtest" without --explain instead of "release".
95</ol>
96
97### 2.3 Cleanup
98
99<ol type="1">
100<li value="29"> `rm -rf $TCLHOME`
101</ol>
102
103<a id="windows"></a>
104## 3.0 Testing On Windows
105
106See also the [](./compile-for-windows.md) document which provides another
107perspective on how to compile SQLite on Windows.
108
109### 3.1 Setup for Windows
110
111(These docs are not as up-to-date as the Unix docs, above.)
112
113<ol type="1">
114<li value="1">
115 [Fossil][] installed.
116<li>
117 Unix-like command-line tools installed. Example:
118 [unxutils](https://unxutils.sourceforge.net/)
119<li> [Visual Studio](https://visualstudio.microsoft.com/vs/community/)
120 installed. VS2015 or later required.
121<li> Check out source code and set environment variables.
122 <ol type="a">
123 <li> **TCLSOURCE** &rarr;
124 The top-level directory of a Fossil check-out of the TCL source tree.
125 <li> **SQLITESOURCE** &rarr;
126 A Fossil check-out of the SQLite source tree.
127 <li> **TCLBUILD** &rarr;
128 A directory that does not exist at the start of the test and which
129 will be deleted at the end of the test, and that will contain the
130 test builds of the TCL libraries and the SQLite TCL Extensions.
131 <li> **ORIGINALPATH** &rarr;
132 The original value of %PATH%. In other words, set as follows:
133 `set ORIGINALPATH %PATH%`
134 </ol>
135</ol>
136
137### 3.2 Testing TCL 8.6 on Windows
138
139<ol type="1">
140<li value="5"> `mkdir %TCLBUILD%\tcl86`
141<li> `cd %TCLSOURCE%\win`
142<li> `fossil up core-8-6-16` <br>
143 &uarr; Or some other version of Tcl8.6.
144<li> `fossil clean -x`
145<li> `set INSTALLDIR=%TCLBUILD%\tcl86`
146<li> `nmake /f makefile.vc release` <br>
147 &udarr; You *must* invoke the "release" and "install" targets
148 using separate "nmake" commands or tclsh86t.exe won't be
149 installed.
150<li> `nmake /f makefile.vc install`
151<li> `cd %SQLITESOURCE%`
152<li> `fossil clean -x`
153<li> `set TCLDIR=%TCLBUILD%\tcl86`
154<li> `set PATH=%TCLBUILD%\tcl86\bin;%ORIGINALPATH%`
155<li> `set TCLSH_CMD=%TCLBUILD%\tcl86\bin\tclsh86t.exe`
156<li> `nmake /f Makefile.msc tclextension-install` <br>
157 &uarr; Verify extension installed at %TCLBUILD%\\tcl86\\lib\\tcl8.6\\sqlite3.*
158<li> `nmake /f Makefile.msc tclextension-verify`
159<li>`tclsh86t test/testrunner.tcl release --explain` <br>
160 &uarr; Verify thousands of lines of output with no errors. Or
161 consider running "devtest" without --explain instead of "release".
162</ol>
163
164### 3.3 Testing TCL 9.0 on Windows
165
166<ol>
167<li value="20"> `mkdir %TCLBUILD%\tcl90`
168<li> `cd %TCLSOURCE%\win`
169<li> `fossil up core-9-0-0` <br>
170 &uarr; Or some other version of Tcl9
171<li> `fossil clean -x`
172<li> `set INSTALLDIR=%TCLBUILD%\tcl90`
173<li> `nmake /f makefile.vc release` <br>
174 &udarr; You *must* invoke the "release" and "install" targets
175 using separate "nmake" commands or tclsh90.exe won't be
176 installed.
177<li> `nmake /f makefile.vc install`
178<li> `cd %SQLITESOURCE%`
179<li> `fossil clean -x`
180<li> `set TCLDIR=%TCLBUILD%\tcl90`
181<li> `set PATH=%TCLBUILD%\tcl90\bin;%ORIGINALPATH%`
182<li> `set TCLSH_CMD=%TCLBUILD%\tcl90\bin\tclsh90.exe`
183<li> `nmake /f Makefile.msc tclextension-install` <br>
184 &uarr; Verify extension installed at %TCLBUILD%\\tcl90\\lib\\sqlite3.*
185<li> `nmake /f Makefile.msc tclextension-verify`
186<li> `tclsh90 test/testrunner.tcl release --explain` <br>
187 &uarr; Verify thousands of lines of output with no errors. Or
188 consider running "devtest" without --explain instead of "release".
189</ol>
190
191### 3.4 Cleanup
192
193<ol type="1">
194<li value="35"> `rm -rf %TCLBUILD%`
195</ol>
196
197## 4.0 Testing the TEA(ish) Build (unix only)
198
199This part requires following the setup instructions for Unix systems,
200at the top of this document.
201
202The former TEA, now TEA(ish), build of this extension uses the same
203code as the builds described above but is provided in a form more
204convenient for downstream Tcl users.
205
206It lives in `autoconf/tea` and, as part of the `autoconf` bundle,
207_cannot be tested directly from the canonical tree_. Instead it has to
208be packaged.
209
210### 4.1 Teaish Setup
211
212Follow the same Tcl- and environment-related related setup described
213in the first section of this document, up to and including the
214installation of Tcl (unless, of course, it was already installed using
215those same instructions).
216
217### 4.2 Teaish Testing
218
219<ol>
220<li>`cd $SQLITESOURCE`
221<li>Run either `make snapshot-tarball` or `make amalgamation-tarball`
222 &uarr;
223 Those steps will leave behind a temp dir called `mkpkg_tmp_dir`,
224 under which the extension is most readily reached. It can optionally
225 be extracted from the generated tarball, but that tarball was
226 generated from this dir, and reusing this dir is a time saver
227 during development.
228<li> `cd mkpkg_tmp/tea`
229<li> `./configure --with-tcl=$TCLHOME`
230<li> `make test install` <br>
231 &uarr; Should run to completion without any errors.
232<li> `make uninstall` <br>
233 &uarr; Will uninstall the extension. This _can_ be run
234 in the same invocation as the `install` target, but only
235 if the `-j#` make flag is _not_ used. If it is, the
236 install/uninstall steps will race and make a mess of things.
237 Parallel builds do not help in this build, anyway, as there's
238 only a single C file to compile.
239</ol>
240
241When actively developing and testing the teaish build, which requires
242going through the tarball generation, there's a caveat about the
243`mkpkg_tmp_dir` dir: it will be deleted every time a tarball is
244built, the shell console which is parked in that
245directory for testing needs to add `cd $PWD &&` to the start of the
246build commands, like:
247
248>
249```
250[user@host:.../mkpkg_tmp_dir/tea]$ \
251 cd $PWD && ./configure CFLAGS=-O0 --with-tcl=$TCLHOME \
252 && make test install uninstall
253```
254
255### 4.3 Teaish Cleanup
256
257
258<ol type="1">
259<li> `rm -rf $TCLHOME`
260<li> `cd $SQLITESOURCE; rm -fr mkpkg_tmp_dir; fossil clean -x`
261</ol>
262
263[Fossil]: https://fossil-scm.org/home
264[tcl-fossil]: https://core.tcl-lang.org/tcl