From 094567e57a4212ad576fa972a418938423e8db0d Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 23 Jun 2020 20:40:49 +0000 Subject: zlib.test: replaces tests/assets/zlib.bin with inlined version (creating test file on demand), use temp files (instead of current directory) for interim files --- tests/zlib.test | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tests/zlib.test b/tests/zlib.test index e7ffcfe..d3a6dff 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -1006,10 +1006,26 @@ test zlib-12.2 {Patrick Dunnigan's issue} -constraints zlib -setup { removeFile $filedst } -result 56 -test zlib-13.1 {Ticket 8af92dfb66 - zlib stream mis-expansion} -constraints zlib -setup { - set pathin [file join $::tcltest::testsDirectory assets zlib.bin] +set zlibbinf "" +proc _zlibbinf {} { + # inlined zlib.bin file creator: + variable zlibbinf + if {$zlibbinf eq ""} { + set zlibbinf [makeFile {} test-zlib-13.bin] + set f [open $zlibbinf wb] + puts -nonewline $f [zlib decompress [binary decode base64 { + eJx7e+6s1+EAgYaLjK3ratptGmOck0vT/y/ZujHAd0qJelDBXfUPJ3tfrtLbpX+wOOFHmtn03/tizm + /+tXROXU3d203b79p5X6/0cvUyFzTsqOj4sa9r8SrZI5zT7265e2Xzq595Fb9LbpgffVy7cZaJ/d15 + 4U9L7LLM2vdqut8+aSU/r6q9Ltv6+T9mBhTgIK97bH33m/O1C1eBwf9FDKNgaIDaj9wA+5hToA== + }]] + close $f + } + return $zlibbinf +} +test zlib-13.1 {Ticket [8af92dfb66] - zlib stream mis-expansion} -constraints zlib -setup { + set pathin [_zlibbinf] set chanin [open $pathin rb] - set pathout [file join [pwd] zlib.deflated] + set pathout [makeFile {} test-zlib-13.deflated] set chanout [open $pathout wb] zlib push inflate $chanin fcopy $chanin $chanout @@ -1018,16 +1034,16 @@ test zlib-13.1 {Ticket 8af92dfb66 - zlib stream mis-expansion} -constraints zlib } -body { file size $pathout } -cleanup { - file delete $pathout + removeFile $pathout unset chanin pathin chanout pathout } -result 458752 -test zlib-13.2 {Ticket f70ce1fead - zlib multi-stream expansion} -constraints zlib -setup { +test zlib-13.2 {Ticket [f70ce1fead] - zlib multi-stream expansion} -constraints zlib -setup { # Start from the basic asset - set pathin [file join $::tcltest::testsDirectory assets zlib.bin] + set pathin [_zlibbinf] set chanin [open $pathin rb] # Create a multi-stream by copying the asset twice into it. - set pathout [file join [pwd] zlib.multi] + set pathout [makeFile {} test-zlib-13.multi] set chanout [open $pathout wb] fcopy $chanin $chanout seek $chanin 0 start @@ -1038,8 +1054,8 @@ test zlib-13.2 {Ticket f70ce1fead - zlib multi-stream expansion} -constraints zl set pathin $pathout set chanin [open $pathin rb] # And our destinations - set pathout1 [file join [pwd] zlib.1] - set pathout2 [file join [pwd] zlib.2] + set pathout1 [makeFile {} test-zlib-13.multi-1] + set pathout2 [makeFile {} test-zlib-13.multi-2] } -body { # Decode first stream set chanout [open $pathout1 wb] @@ -1057,10 +1073,18 @@ test zlib-13.2 {Ticket f70ce1fead - zlib multi-stream expansion} -constraints zl list [file size $pathout1] [file size $pathout2] } -cleanup { close $chanin - file delete $pathout $pathout1 $pathout2 + removeFile $pathout + removeFile $pathout1 + removeFile $pathout2 unset chanin pathin chanout pathout pathout1 pathout2 } -result {458752 458752} +if {$zlibbinf ne ""} { + removeFile $zlibbinf +} +unset zlibbinf +rename _zlibbinf {} + ::tcltest::cleanupTests return -- cgit v0.12