Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/doc/tcl-extension-testing.md # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 5 The SQLite TCL extension logic (in the 6 "[tclsqlite.c](/file/src/tclsqlite.c)" source 7 file) is statically linked into "textfixture" executable 8 which is the program used to do most of the testing 9 associated with "make test", "make devtest", and/or 10 "make releasetest". So the functionality of the SQLite 11 TCL extension is thoroughly vetted during normal testing. The 12 procedures below are designed to test the loadable extension 13 aspect of the SQLite TCL extension, and in particular to verify 14 that the "make tclextension-install" build target works and that 15 an ordinary tclsh can subsequently run "package require sqlite3". 16 17 This procedure can also be used as a template for how to set up 18 a local TCL+SQLite development environment. In other words, it 19 can be be used as a guide on how to compile per-user copies of 20 Tcl that are used to develop, test, and debug SQLite. In that 21 case, 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 30 ## 2.0 Testing On Unix-like Systems (Including Mac) 31 32 See also the [](./compile-for-unix.md) document which provides another 33 perspective on how to compile SQLite on unix-like systems. 34 35 ### 2.1 Setup 36 37
    38
  1. 39 [Fossil][] installed. 40
  2. Check out source code and set environment variables: 41
      42
    1. **TCLSOURCE** → 43 The top-level directory of a [Fossil][] check-out of the 44 [TCL source tree][tcl-fossil]. 45
    2. **SQLITESOURCE** → 46 A Fossil check-out of the SQLite source tree. 47
    3. **TCLHOME** → 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
    4. **TCLVERSION** → 54 The `X.Y`-form version of Tcl being used: 8.6, 9.0, 9.1... 55
    56
57 58 ### 2.2 Testing TCL 8.x and 9.x on unix 59 60 From a checked-out copy of [the core Tcl tree][tcl-fossil] 61 62
    63
  1. `TCLVERSION=8.6`
    64 ↑ 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
  2. `TCLHOME=$HOME/tcl/$TCLVERSION` 68
  3. `TCLSOURCE=/path/to/tcl/checkout` 69
  4. `SQLITESOURCE=/path/to/sqlite/checkout` 70
  5. `rm -fr $TCLHOME`
    71 ↑ Ensure that no stale Tcl installation is laying around. 72
  6. `cd $TCLSOURCE` 73
  7. `fossil up core-8-6-branch`
    74 ↑ The branch corresponding to `$TCLVERSION`, e.g. 75 `core-9-0-branch` or `trunk`. 76
  8. `fossil clean -x` 77
  9. `cd unix` 78
  10. `./configure --prefix=$TCLHOME --disable-shared`
    79 ↑ The `--disable-shared` is to avoid the need to set `LD_LIBRARY_PATH` 80 when using this Tcl build. 81
  11. `make install` 82
  12. `cd $SQLITESOURCE` 83
  13. `fossil clean -x` 84
  14. `./configure --with-tcl=$TCLHOME --all` 85
  15. `make tclextension-install`
    86 ↑ Verify extension installed at 87 `$TCLHOME/lib/tcl${TCLVERSION}/sqlite`. 88
  16. `make tclextension-list`
    89 ↑ Verify TCL extension correctly installed. 90
  17. `make tclextension-verify`
    91 ↑ Verify that the correct version is installed. 92
  18. `$TCLHOME/bin/tclsh[89].[0-9] test/testrunner.tcl release --explain`
    93 ↑ Verify thousands of lines of output with no errors. Or 94 consider running "devtest" without --explain instead of "release". 95
96 97 ### 2.3 Cleanup 98 99
    100
  1. `rm -rf $TCLHOME` 101
102 103 104 ## 3.0 Testing On Windows 105 106 See also the [](./compile-for-windows.md) document which provides another 107 perspective 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
    114
  1. 115 [Fossil][] installed. 116
  2. 117 Unix-like command-line tools installed. Example: 118 [unxutils](https://unxutils.sourceforge.net/) 119
  3. [Visual Studio](https://visualstudio.microsoft.com/vs/community/) 120 installed. VS2015 or later required. 121
  4. Check out source code and set environment variables. 122
      123
    1. **TCLSOURCE** → 124 The top-level directory of a Fossil check-out of the TCL source tree. 125
    2. **SQLITESOURCE** → 126 A Fossil check-out of the SQLite source tree. 127
    3. **TCLBUILD** → 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
    4. **ORIGINALPATH** → 132 The original value of %PATH%. In other words, set as follows: 133 `set ORIGINALPATH %PATH%` 134
    135
136 137 ### 3.2 Testing TCL 8.6 on Windows 138 139
    140
  1. `mkdir %TCLBUILD%\tcl86` 141
  2. `cd %TCLSOURCE%\win` 142
  3. `fossil up core-8-6-16`
    143 ↑ Or some other version of Tcl8.6. 144
  4. `fossil clean -x` 145
  5. `set INSTALLDIR=%TCLBUILD%\tcl86` 146
  6. `nmake /f makefile.vc release`
    147 ⇅ You *must* invoke the "release" and "install" targets 148 using separate "nmake" commands or tclsh86t.exe won't be 149 installed. 150
  7. `nmake /f makefile.vc install` 151
  8. `cd %SQLITESOURCE%` 152
  9. `fossil clean -x` 153
  10. `set TCLDIR=%TCLBUILD%\tcl86` 154
  11. `set PATH=%TCLBUILD%\tcl86\bin;%ORIGINALPATH%` 155
  12. `set TCLSH_CMD=%TCLBUILD%\tcl86\bin\tclsh86t.exe` 156
  13. `nmake /f Makefile.msc tclextension-install`
    157 ↑ Verify extension installed at %TCLBUILD%\\tcl86\\lib\\tcl8.6\\sqlite3.* 158
  14. `nmake /f Makefile.msc tclextension-verify` 159
  15. `tclsh86t test/testrunner.tcl release --explain`
    160 ↑ Verify thousands of lines of output with no errors. Or 161 consider running "devtest" without --explain instead of "release". 162
163 164 ### 3.3 Testing TCL 9.0 on Windows 165 166
    167
  1. `mkdir %TCLBUILD%\tcl90` 168
  2. `cd %TCLSOURCE%\win` 169
  3. `fossil up core-9-0-0`
    170 ↑ Or some other version of Tcl9 171
  4. `fossil clean -x` 172
  5. `set INSTALLDIR=%TCLBUILD%\tcl90` 173
  6. `nmake /f makefile.vc release`
    174 ⇅ You *must* invoke the "release" and "install" targets 175 using separate "nmake" commands or tclsh90.exe won't be 176 installed. 177
  7. `nmake /f makefile.vc install` 178
  8. `cd %SQLITESOURCE%` 179
  9. `fossil clean -x` 180
  10. `set TCLDIR=%TCLBUILD%\tcl90` 181
  11. `set PATH=%TCLBUILD%\tcl90\bin;%ORIGINALPATH%` 182
  12. `set TCLSH_CMD=%TCLBUILD%\tcl90\bin\tclsh90.exe` 183
  13. `nmake /f Makefile.msc tclextension-install`
    184 ↑ Verify extension installed at %TCLBUILD%\\tcl90\\lib\\sqlite3.* 185
  14. `nmake /f Makefile.msc tclextension-verify` 186
  15. `tclsh90 test/testrunner.tcl release --explain`
    187 ↑ Verify thousands of lines of output with no errors. Or 188 consider running "devtest" without --explain instead of "release". 189
190 191 ### 3.4 Cleanup 192 193
    194
  1. `rm -rf %TCLBUILD%` 195
196 197 ## 4.0 Testing the TEA(ish) Build (unix only) 198 199 This part requires following the setup instructions for Unix systems, 200 at the top of this document. 201 202 The former TEA, now TEA(ish), build of this extension uses the same 203 code as the builds described above but is provided in a form more 204 convenient for downstream Tcl users. 205 206 It lives in `autoconf/tea` and, as part of the `autoconf` bundle, 207 _cannot be tested directly from the canonical tree_. Instead it has to 208 be packaged. 209 210 ### 4.1 Teaish Setup 211 212 Follow the same Tcl- and environment-related related setup described 213 in the first section of this document, up to and including the 214 installation of Tcl (unless, of course, it was already installed using 215 those same instructions). 216 217 ### 4.2 Teaish Testing 218 219
    220
  1. `cd $SQLITESOURCE` 221
  2. Run either `make snapshot-tarball` or `make amalgamation-tarball` 222 ↑ 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
  3. `cd mkpkg_tmp/tea` 229
  4. `./configure --with-tcl=$TCLHOME` 230
  5. `make test install`
    231 ↑ Should run to completion without any errors. 232
  6. `make uninstall`
    233 ↑ 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
240 241 When actively developing and testing the teaish build, which requires 242 going through the tarball generation, there's a caveat about the 243 `mkpkg_tmp_dir` dir: it will be deleted every time a tarball is 244 built, the shell console which is parked in that 245 directory for testing needs to add `cd $PWD &&` to the start of the 246 build 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
    259
  1. `rm -rf $TCLHOME` 260
  2. `cd $SQLITESOURCE; rm -fr mkpkg_tmp_dir; fossil clean -x` 261
262 263 [Fossil]: https://fossil-scm.org/home 264 [tcl-fossil]: https://core.tcl-lang.org/tcl