https://github.com/antirez/redis/blob/46a51cdcdc0bd92473163068c2ec3bef4dffe63c/tests/test_helper.tcl#L213

behavior

unittests wont work in external mode.

[exception]: Executing test client: couldn't open socket: connection refused.
couldn't open socket: connection refused
    while executing
"socket $server $port"
    (procedure "redis" line 2)
    invoked from within
"redis $::host $::port"
    (procedure "start_server" line 11)
    invoked from within
"start_server {
    tags {"list"}
    overrides {
        "list-max-ziplist-value" 16
        "list-max-ziplist-entries" 256
    }
} {
    source "test..."
    (file "tests/unit/type/list.tcl" line 1)
    invoked from within
"source $path"
    (procedure "execute_tests" line 4)
    invoked from within
"execute_tests $data"
    (procedure "test_client_main" line 10)
    invoked from within
"test_client_main $::test_server_port "

reproduce

1) run a redis server on port 12345 2) tclsh tests/test_helper.tcl --host 127.0.0.1 --port 12345 --single unit/type/list --clients 1

reason

the actual port program tries to connect is 12445, read the code around, we can find the port is added by 100, and passed to the client process.

this line, the {*}$::argv definitely should be moved to the last of the line, or it will be overwritten.

related

I found someone asked this question on stackoverflow. https://stackoverflow.com/questions/10390008/using-external-redis-server-for-testing-tcl-scripts?rq=1 It is unbelievable that in such a popular open-source project, there is no one who ever successfully run unitttests in external mode.

Comment From: enjoy-binbin

I tested it and it works now