mirror of
https://github.com/redis/redis.git
synced 2026-06-04 14:16:31 -04:00
Support Tcl 9.0 in Redis test suite (#14787)
## Summary
This PR adds support for running the Redis test suite using Tcl 9.0.
## Changes
- **runtest**: Added `9.0` to the list of Tcl versions the script
searches for.
- **Version Requirements**: Updated `package require Tcl` from `8.5` to
`8.5-10` in key test files. In Tcl, a simple version requirement like
`8.5` is interpreted as "8.5 or higher within major version 8".
Specifying the range `8.5-10` allows Tcl 9.0 to be used if the code is
compatible.
- **Tcl Precision**: Wrapped `set tcl_precision 17` in a conditional
check `if {$tcl_version < 9.0}`. In Tcl 9.0, `tcl_precision` has been
removed as double-to-string conversions are now lossless by default.
- Adjusts the Tcl Redis client to preserve binary arguments under Tcl 9
by only UTF-8 converting strings that contain non-byte characters before
building the RESP command.
## Testing
Verified that `tclsh9.0` successfully parses the updated `package
require` and handles the conditional `tcl_precision` assignment. This
allows the test suite to run on modern Linux distributions where Tcl 9.0
is the default version.
This commit is contained in:
parent
33319b80a7
commit
707757e478
7 changed files with 16 additions and 11 deletions
2
runtest
2
runtest
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
TCL_VERSIONS="8.5 8.6 8.7"
|
||||
TCL_VERSIONS="8.5 8.6 8.7 9.0"
|
||||
TCLSH=""
|
||||
|
||||
for VERSION in $TCL_VERSIONS; do
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
# (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the
|
||||
# GNU Affero General Public License v3 (AGPLv3).
|
||||
|
||||
package require Tcl 8.5
|
||||
package require Tcl 8.5-10
|
||||
|
||||
set tcl_precision 17
|
||||
if {$tcl_version < 9.0} { set tcl_precision 17 }
|
||||
source ../support/redis.tcl
|
||||
source ../support/util.tcl
|
||||
source ../support/aofmanifest.tcl
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
# $c get foo
|
||||
# $c close
|
||||
|
||||
package require Tcl 8.5
|
||||
package require Tcl 8.5-10
|
||||
package provide redis_cluster 0.1
|
||||
|
||||
namespace eval redis_cluster {}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#
|
||||
# vwait forever
|
||||
|
||||
package require Tcl 8.5
|
||||
package require Tcl 8.5-10
|
||||
package provide redis 0.1
|
||||
|
||||
source [file join [file dirname [info script]] "response_transformers.tcl"]
|
||||
|
|
@ -165,6 +165,11 @@ proc ::redis::__dispatch__raw__ {id method argv} {
|
|||
set cmd "*[expr {[llength $argv]+1}]\r\n"
|
||||
append cmd "$[string length $method]\r\n$method\r\n"
|
||||
foreach a $argv {
|
||||
# In Tcl 9.0, only convert to UTF-8 if the string contains non-byte characters
|
||||
# to preserve binary data while handling unicode correctly
|
||||
if {$::tcl_version >= 9.0 && [string match "*\[^\u0000-\u00ff\]*" $a]} {
|
||||
set a [encoding convertto utf-8 $a]
|
||||
}
|
||||
append cmd "$[string length $a]\r\n$a\r\n"
|
||||
}
|
||||
::redis::redis_write $fd $cmd
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
# changes in many files) we decided to transform the response to RESP2
|
||||
# when running with --force-resp3
|
||||
|
||||
package require Tcl 8.5
|
||||
package require Tcl 8.5-10
|
||||
|
||||
namespace eval response_transformers {}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
# Portions of this file are available under BSD3 terms; see REDISCONTRIBUTIONS for more information.
|
||||
#
|
||||
|
||||
package require Tcl 8.5
|
||||
package require Tcl 8.5-10
|
||||
|
||||
set tcl_precision 17
|
||||
if {$tcl_version < 9.0} { set tcl_precision 17 }
|
||||
source tests/support/redis.tcl
|
||||
source tests/support/aofmanifest.tcl
|
||||
source tests/support/server.tcl
|
||||
|
|
@ -333,7 +333,7 @@ proc test_server_cron {} {
|
|||
}
|
||||
|
||||
proc accept_test_clients {fd addr port} {
|
||||
fconfigure $fd -encoding binary
|
||||
fconfigure $fd -translation binary
|
||||
fileevent $fd readable [list read_from_test_client $fd]
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ proc the_end {} {
|
|||
# to read the command, execute, reply... all this in a loop.
|
||||
proc test_client_main server_port {
|
||||
set ::test_server_fd [socket localhost $server_port]
|
||||
fconfigure $::test_server_fd -encoding binary
|
||||
fconfigure $::test_server_fd -translation binary
|
||||
send_data_packet $::test_server_fd ready [pid]
|
||||
while 1 {
|
||||
set bytes [gets $::test_server_fd]
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ start_server {tags {"other"}} {
|
|||
} else {
|
||||
set fd2 [socket [srv host] [srv port]]
|
||||
}
|
||||
fconfigure $fd2 -encoding binary -translation binary
|
||||
fconfigure $fd2 -translation binary
|
||||
if {!$::singledb} {
|
||||
puts -nonewline $fd2 "SELECT 9\r\n"
|
||||
flush $fd2
|
||||
|
|
|
|||
Loading…
Reference in a new issue