The repository now has two distinct kinds of files under
tests/:
*.test: real tcltest test cases that are
executed by tests/all.tcllegacy/*.tcl: legacy example scripts that are useful as
references, but are not part of the automated suiteLast update: 2026-05-16
tests/all.tcl tries to load TclCurl from the build tree
first and falls back to an installed package if needed.
By default, tests/all.tcl enables tcltest’s
start verbosity, so each test prints a line when it begins
running. You can still override that from the command line with
-verbose.
To run the server-backed suite from a normal working tree, use this sequence:
tclsh testservers/testserver.tcltclsh tests/all.tcl-file:tclsh tests/all.tcl -file http.test-exitserver:tclsh tests/all.tcl -exitserverIf one of the configured protocol endpoints is not reachable, the corresponding server-backed tests are skipped.
testservers/testserver.tclThe local server framework accepts the following general command form:
tclsh testservers/testserver.tcl \
?--host host? \
?--httpport port? ?--httpsport port? ?--ftpport port? ?--proxyport port? \
?--certfile path? ?--keyfile path? \
?--service protocol:port? ... \
?--docroot path? ?--ftproot path? ?--keepdocroot? \
?--logfile path? \
?--startservers protocol[,protocol,...]|all? \
?--quiet? ?--debug?
By default, testservers/testserver.tcl starts four
services:
127.0.0.1:8990127.0.0.1:9443127.0.0.1:8991127.0.0.1:8992The HTTP test server keeps its explicit dynamic routes for protocol
behaviors such as redirects, request inspection, and authentication. For
GET and HEAD requests that do not match one of
those routes, it falls back to static file serving rooted at
TCLCURL_TEST_DOC_ROOT or --docroot.
Unless --keepdocroot is given, the server removes the
configured document root when it shuts down.
The server framework appends timestamped per-request log lines to
/tmp/tclcurl.log by default. Override that path with
--logfile when you want to keep the request log
elsewhere.
tests/all.tcltests/all.tcl accepts a small set of TclCurl-specific
options together with the usual tcltest command-line
filters and output controls. The general form is:
tclsh tests/all.tcl \
?--httpserver path/to/server.tcl? \
?--httpport port? ?--httpsport port? ?--ftpport port? ?--proxyport port? \
?--docroot path? ?--ftproot path? \
?--certfile path? ?--keyfile path? \
?--exitserver? ?--debug? \
?--file pattern? ?--notfile pattern? ?--match pattern? ?--skip pattern? \
?--verbose level...?
When the Tcl HTTP test server is wired in, the server script path precedence is:
--httpserver /path/to/server.tclTCLCURL_TEST_HTTP_SERVER_SCRIPTtestservers/testserver.tcltestservers/testserver.tcl accepts
--httpport, --httpsport,
--ftpport, and --proxyport to override the
default ports 8990, 9443, 8991,
and 8992.
tests/all.tcl accepts the same double-dash options
--httpport, --httpsport,
--ftpport, and --proxyport. It also accepts
--docroot, --ftproot, --certfile,
and --keyfile, and maps them to the corresponding
TCLCURL_TEST_* environment overrides used by the test
support layer. When you need both entry points to target the same
services, pass matching values to each script.
The Tcl test support layer uses protocol-specific base URLs. You can
override them before running make test or
tclsh tests/all.tcl:
TCLCURL_TEST_HTTP_BASE_URL: base URL for the running
Tcl HTTP test server, default http://127.0.0.1:8990/TCLCURL_TEST_HTTPS_BASE_URL: base URL for the running
Tcl HTTPS test server, default https://127.0.0.1:9443/TCLCURL_TEST_FTP_BASE_URL: base URL for the running Tcl
FTP test server, default ftp://127.0.0.1:8991/TCLCURL_TEST_PROXY_BASE_URL: base URL for the running
Tcl HTTP proxy test server, default
http://127.0.0.1:8992/TCLCURL_TEST_DOC_ROOT: shared document root used by the
Tcl test servers, default /tmp/tclcurlTCLCURL_TEST_FTP_ROOT: root directory used by the Tcl
FTP test server, default TCLCURL_TEST_DOC_ROOTTCLCURL_TEST_HTTPS_CERT_FILE: path to the certificate
file used by the Tcl HTTPS test server, default
tests/certs/server.crtTCLCURL_TEST_HTTPS_KEY_FILE: path to the private key
file used by the Tcl HTTPS test server, default
tests/certs/server.keyTCLCURL_TEST_HTTP_SERVER_SCRIPT: path to the Tcl test
server framework script, used when no -httpserver CLI
override is given; default testservers/testserver.tclIn order to test the https series of tests you have to create a self-signed pair of key/certificate to be stored in tests/certs
If you want to keep the credentials elsewhere, either:
testservers/testserver.tcl with
--certfile /path/to/server.crt --keyfile /path/to/server.keytests/all.tcl --certfile /path/to/server.crt --keyfile /path/to/server.keyTCLCURL_TEST_HTTPS_CERT_FILE and
TCLCURL_TEST_HTTPS_KEY_FILE mkdir -p tests/certs
openssl req -x509 -newkey rsa:2048 -sha256 -days 3650 -nodes \
-keyout tests/certs/server.key \
-out tests/certs/server.crt \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
tests/http_common.tcl contains transport-oriented
scenario helpers that are shared by http.test,
https.test, redir.test, and
cookies.test.
The common layer currently covers:
-writeprocgetinfo transfer metadata-followlocation,
-maxredirs, -autoreferer, and
-postredir-post,
-postfields, -postfieldsize,
-upload, -readproc, and
-range-timeout and
-timeoutms-cookiefile,
-cookielist, -cookiejar, and
-cookiesessionTests that are primarily about easy-handle lifecycle or share-handle
lifecycle stay in the protocol-specific files instead of being pulled
into http_common.tcl.
tests/http.test focuses on TclCurl behaviors exercised
over plain HTTP:
-bodyvar-headervar-writeprocgetinfo transfer metadatareset and
duphandle-failonerror and
-errorbuffer-post,
-postfields, -postfieldsize,
-upload, -readproc, and
-range-timeout and
-timeoutmstests/output.test covers output routing:
-file and resetting it to the default destination-writeheader and resetting it to the default
destination-stderr and resetting it to the default
destinationtests/progress.test covers transfer callbacks and
related controls:
-command-progressproc-buffersizetests/negotiation.test covers HTTP negotiation-oriented
options:
-httpversion-encoding-transferencoding-contentdecoding-transferdecodingtests/https.test covers the TLS-specific aspects of the
same HTTP behaviors:
-cainfo pointing at the local
self-signed certificatetests/http_common.tcltests/ftp.test covers the local Tcl FTP server:
LIST / NLST-dirlistonly-quote / -postquote-ftpcreatemissingdirs-resumefromtests/redir.test and tests/cookies.test are
thin wrappers around the shared transport scenarios, kept as separate
files for readability and focused tcltest runs.
tests/mime.test currently covers multipart form
submission through -httppost:
The HTTPS server requires:
tls packagetests/certs/server.crttests/certs/server.keyYou can override those paths:
--certfile /path/to/server.crt --keyfile /path/to/server.keyTCLCURL_TEST_HTTPS_CERT_FILE
and TCLCURL_TEST_HTTPS_KEY_FILEThese files are intentionally not required to live in the repository. When they are missing, HTTPS-backed tests are skipped.
One simple way to generate them locally is:
mkdir -p tests/certs
openssl req -x509 -newkey rsa:2048 -sha256 -days 3650 -nodes \
-keyout tests/certs/server.key \
-out tests/certs/server.crt \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"The current suite already covers the core HTTP, HTTPS, and FTP behaviors used by TclCurl, but some areas are still being expanded. If you are looking for the parts of the option surface that are most likely to gain broader automated coverage next, the main groups are:
-connecttimeout-resolve,
-ipresolve, -interface, -port,
and -tcpnodelay-userpwd, -username,
-password, -httpauth, and
-proxyauthOther areas that are also expected to grow over time include:
-debugproc-httppost,
including contentheader, overridden filename,
and filecontentgetinfo,
curl::curlConfig, easystrerror,
multistrerror, and sharestrerrorAlthough the local test framework now covers a substantial part of TclCurl’s single-transfer behavior, some categories still have more limited automated coverage.
The main remaining limitations are:
curl/tests/dataIn practice, this means that the absence of a test in one of those areas does not necessarily indicate lack of support in TclCurl. It more often means that the local test framework has not yet been extended to exercise that behavior in a reproducible way.