From 8200cc5892deff530ac8b23bc7bb66d38abc30fa Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Wed, 13 Sep 2023 06:42:54 +0000 Subject: Add !zipfslib constraint for tests that should only run without an attached Tcl lib vfs --- doc/zipfs.n | 4 +++- generic/tclZipfs.c | 4 ++-- tests/zipfs.test | 17 +++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/doc/zipfs.n b/doc/zipfs.n index d57aff3..b59e072 100644 --- a/doc/zipfs.n +++ b/doc/zipfs.n @@ -86,7 +86,9 @@ matching the pattern are returned. By default, or with the \fB-glob\fR option, the pattern is treated as a glob pattern and matching is done as described for the \fBstring match\fR command. Alternatively, the \fB-regexp\fR option may be used to specify matching \fBpattern\fR as a regular expression. The file names -are returned in arbitrary order. +are returned in arbitrary order. Note that path separators are treated as +ordinary characters in the matching. Thus forward slashes should be used +as path separators in the pattern. .TP \fBzipfs mount\fR .TP diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 77bc6b5..ef2abcd 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -1289,12 +1289,12 @@ ZipFSFindTOC( zf->directoryOffset = cdirZipOffset + zf->baseOffset; zf->directorySize = cdirSize; - const unsigned char *const cdirStart = p - cdirSize; /* Start of */ + const unsigned char *const cdirStart = p - cdirSize; /* Start of CD */ /* * Original pointer based validation replaced by simpler checks above. * Ensure still holds. The assigments to p, q are only there for use in - * the asserts. + * the asserts. May be removed at some future date. */ q = zf->data + cdirZipOffset; p -= cdirSize; diff --git a/tests/zipfs.test b/tests/zipfs.test index cce5899..7754432 100644 --- a/tests/zipfs.test +++ b/tests/zipfs.test @@ -512,10 +512,10 @@ namespace eval test_ns_zipfs { testbadmount bad-directory-offset incons-cdoffset.zip "archive directory truncated" testbadmount bad-directory-magic incons-central-magic-bad.zip "wrong header signature" testbadmount bad-local-magic incons-local-magic-bad.zip "Failed to find local header" - testbadmount bad-file-count-high incons-file-count-high.zip "truncated directory" + testbadmount bad-file-count-high incons-file-count-high.zip "truncated directory" + testbadmount bad-file-count-low incons-file-count-low.zip "short file count" # TODO testbadmount bad-directory-crc incons-central-crc.zip "" - # TODO - at open testbadmount bad-file-count-low incons-file-count-low.zip "" testmount basic test.zip testdir/test2 testmount zip-at-end junk-at-start.zip testdir/test2 @@ -722,22 +722,23 @@ namespace eval test_ns_zipfs { cleanup } -result $resultpaths {*}$args } - testzipfslist no-mounts "" {} {} - testzipfslist no-pattern "" {test.zip testmountA} {testmountA testmountA/test testmountA/testdir testmountA/testdir/test2} + # Some tests have !zipfslib constraint because otherwise they dump the entire Tcl library which is mounted on root + testzipfslist no-mounts "" {} {} -constraints !zipfslib + testzipfslist no-pattern "" {test.zip testmountA} {testmountA testmountA/test testmountA/testdir testmountA/testdir/test2} -constraints !zipfslib testzipfslist no-pattern-mount-on-root "" {test.zip {}} {{} test testdir testdir/test2} -constraints knownBug testzipfslist no-pattern-multiple "" {test.zip testmountA test.zip testmountB/subdir} { testmountA testmountA/test testmountA/testdir testmountA/testdir/test2 testmountB/subdir testmountB/subdir/test testmountB/subdir/testdir testmountB/subdir/testdir/test2 - } - testzipfslist glob [list "*2*"] {test.zip testmountA test.zip testmountB/subdir} { + } -constraints !zipfslib + testzipfslist glob [list "*testmount*2*"] {test.zip testmountA test.zip testmountB/subdir} { testmountA/testdir/test2 testmountB/subdir/testdir/test2 } - testzipfslist opt-glob [list -glob "*2*"] {test.zip testmountA test.zip testmountB/subdir} { + testzipfslist opt-glob [list -glob "*testmount*2*"] {test.zip testmountA test.zip testmountB/subdir} { testmountA/testdir/test2 testmountB/subdir/testdir/test2 } - testzipfslist opt-regexp [list -regexp "A|2"] {test.zip testmountA test.zip testmountB/subdir} { + testzipfslist opt-regexp [list -regexp "testmount.*(A|2)"] {test.zip testmountA test.zip testmountB/subdir} { testmountA testmountA/test testmountA/testdir testmountA/testdir/test2 testmountB/subdir/testdir/test2 } -- cgit v0.12