Skip to content

Commit

Permalink
Merge 8.7: Disable more file permissions tests for WSL (not supported…
Browse files Browse the repository at this point in the history
… in WSL/NTFS)
  • Loading branch information
apnadkarni committed Mar 2, 2023
2 parents 0a95d9a + 4d67456 commit e3e5fcc
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 35 deletions.
6 changes: 4 additions & 2 deletions tests/chanio.test
Expand Up @@ -50,6 +50,8 @@ namespace eval ::tcl::test::io {
testConstraint notWinCI [expr {
$::tcl_platform(platform) ne "windows" || ![info exists ::env(CI)]}]
testConstraint notOSX [expr {$::tcl_platform(os) ne "Darwin"}]
# File permissions broken on wsl without some "exotic" wsl configuration
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]
testConstraint specialfiles [expr {[file exists /dev/zero] || [file exists NUL]}]

# You need a *very* special environment to do some tests. In particular,
Expand Down Expand Up @@ -5348,7 +5350,7 @@ test chan-io-40.1 {POSIX open access modes: RDWR} -setup {
} -result {zzy abzzy}
test chan-io-40.2 {POSIX open access modes: CREAT} -setup {
file delete $path(test3)
} -constraints {unix} -body {
} -constraints {unix notWsl} -body {
set f [open $path(test3) {WRONLY CREAT} 0o600]
file stat $path(test3) stats
set x [format 0o%03o [expr {$stats(mode) & 0o777}]]
Expand All @@ -5361,7 +5363,7 @@ test chan-io-40.2 {POSIX open access modes: CREAT} -setup {
} -result {0o600 {line 1}}
test chan-io-40.3 {POSIX open access modes: CREAT} -setup {
file delete $path(test3)
} -constraints {unix umask} -body {
} -constraints {unix umask notWsl} -body {
# This test only works if your umask is 2, like ouster's.
chan close [open $path(test3) {WRONLY CREAT}]
file stat $path(test3) stats
Expand Down
8 changes: 5 additions & 3 deletions tests/cmdAH.test
Expand Up @@ -28,6 +28,8 @@ testConstraint linkDirectory [expr {
&& [lindex [file system [temporaryDirectory]] 1] eq "NTFS")
}]
testConstraint notWine [expr {![info exists ::env(CI_USING_WINE)]}]
# File permissions broken on wsl without some "exotic" wsl configuration
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]

global env
set cmdAHwd [pwd]
Expand Down Expand Up @@ -1003,7 +1005,7 @@ test cmdAH-16.2 {Tcl_FileObjCmd: readable} {
-result 1
}
test cmdAH-16.3 {Tcl_FileObjCmd: readable} {
-constraints {unix notRoot testchmod}
-constraints {unix notRoot testchmod notWsl}
-setup {testchmod 0o333 $gorpfile}
-body {file readable $gorpfile}
-result 0
Expand Down Expand Up @@ -1036,7 +1038,7 @@ set gorpfile [makeFile abcde gorp.file]
test cmdAH-18.1 {Tcl_FileObjCmd: executable} -returnCodes error -body {
file executable a b
} -result {wrong # args: should be "file executable name"}
test cmdAH-18.2 {Tcl_FileObjCmd: executable} {notRoot} {
test cmdAH-18.2 {Tcl_FileObjCmd: executable} {notRoot notWsl} {
file executable $gorpfile
} 0
test cmdAH-18.3 {Tcl_FileObjCmd: executable} {unix testchmod} {
Expand Down Expand Up @@ -1583,7 +1585,7 @@ test cmdAH-28.4 {Tcl_FileObjCmd: stat} -setup {
file stat $gorpfile stat
list $stat(nlink) $stat(size) $stat(type)
} -result {1 12 file}
test cmdAH-28.5 {Tcl_FileObjCmd: stat} -constraints {unix} -setup {
test cmdAH-28.5 {Tcl_FileObjCmd: stat} -constraints {unix notWsl} -setup {
unset -nocomplain stat
} -body {
file stat $gorpfile stat
Expand Down
38 changes: 19 additions & 19 deletions tests/fCmd.test
Expand Up @@ -43,7 +43,7 @@ if {[testConstraint win]} {
testConstraint notInCIenv [expr {![info exists ::env(CI)] || !$::env(CI)}]

# File permissions broken on wsl without some "exotic" wsl configuration
testConstraint notInWsl [expr {[llength [array names ::env *WSL*]] == 0}]
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]

set tmpspace /tmp;# default value
# Find a group that exists on this Unix system, or else skip tests that
Expand Down Expand Up @@ -452,7 +452,7 @@ test fCmd-4.10 {TclFileMakeDirsCmd: exists, is dir} -setup {
} -result {1 1}
test fCmd-4.11 {TclFileMakeDirsCmd: doesn't exist: errno != ENOENT} -setup {
cleanup
} -constraints {unix notRoot testchmod notInWsl} -returnCodes error -body {
} -constraints {unix notRoot testchmod notWsl} -returnCodes error -body {
file mkdir td1/td2/td3
testchmod 0 td1/td2
file mkdir td1/td2/td3/td4
Expand All @@ -470,7 +470,7 @@ test fCmd-4.13 {TclFileMakeDirsCmd: doesn't exist: errno == ENOENT} -setup {
test fCmd-4.14 {TclFileMakeDirsCmd: TclpCreateDirectory fails} -setup {
cleanup
file delete -force foo
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir foo
file attr foo -perm 0o40000
file mkdir foo/tf1
Expand Down Expand Up @@ -596,7 +596,7 @@ test fCmd-6.5 {CopyRenameOneFile: lstat(target) != 0} -setup {
} -result {tf2}
test fCmd-6.6 {CopyRenameOneFile: errno != ENOENT} -setup {
cleanup
} -constraints {unix notRoot testchmod notInWsl} -body {
} -constraints {unix notRoot testchmod notWsl} -body {
file mkdir td1
testchmod 0 td1
createfile tf1
Expand Down Expand Up @@ -715,7 +715,7 @@ test fCmd-6.22 {CopyRenameOneFile: copy/rename: !S_ISDIR(source)} -setup {
} -result [file join $tmpspace tf1]
test fCmd-6.23 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
cleanup $tmpspace
} -constraints {xdev notRoot notInWsl} -body {
} -constraints {xdev notRoot notWsl} -body {
file mkdir td1/td2/td3
file attributes td1 -permissions 0
file rename td1 $tmpspace
Expand Down Expand Up @@ -767,7 +767,7 @@ test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
} -match glob -result {error renaming "td1" to "/tmp/tcl*/td1": file already exists}
test fCmd-6.28 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
cleanup $tmpspace
} -constraints {notRoot xdev notInWsl} -body {
} -constraints {notRoot xdev notWsl} -body {
file mkdir td1/td2/td3
file attributes td1/td2/td3 -permissions 0
file rename td1 $tmpspace
Expand All @@ -784,7 +784,7 @@ test fCmd-6.29 {CopyRenameOneFile: TclpCopyDirectory passed} -setup {
} -result [file join $tmpspace td1 td2]
test fCmd-6.30 {CopyRenameOneFile: TclpRemoveDirectory failed} -setup {
cleanup $tmpspace
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir foo/bar
file attr foo -perm 0o40555
file rename foo/bar $tmpspace
Expand Down Expand Up @@ -859,7 +859,7 @@ test fCmd-8.3 {file copy and path translation: ensure correct error} -body {

test fCmd-9.1 {file rename: comprehensive: EACCES} -setup {
cleanup
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir td1
file mkdir td2
file attr td2 -perm 0o40000
Expand All @@ -885,7 +885,7 @@ test fCmd-9.3 {file rename: comprehensive: file to new name} -setup {
} -result {{tf3 tf4} 1 0}
test fCmd-9.4 {file rename: comprehensive: dir to new name} -setup {
cleanup
} -constraints {unix notRoot testchmod notDarwin9 notInWsl} -body {
} -constraints {unix notRoot testchmod notDarwin9 notWsl} -body {
file mkdir td1 td2
testchmod 0o555 td2
file rename td1 td3
Expand All @@ -906,7 +906,7 @@ test fCmd-9.5 {file rename: comprehensive: file to self} -setup {
} -result {tf1 tf2 1 0}
test fCmd-9.6 {file rename: comprehensive: dir to self} -setup {
cleanup
} -constraints {unix notRoot testchmod notInWsl} -body {
} -constraints {unix notRoot testchmod notWsl} -body {
file mkdir td1
file mkdir td2
testchmod 0o555 td2
Expand Down Expand Up @@ -1100,7 +1100,7 @@ test fCmd-10.2 {file copy: comprehensive: file to new name} -setup {
} -result {{tf1 tf2 tf3 tf4} tf1 tf2 1 0}
test fCmd-10.3 {file copy: comprehensive: dir to new name} -setup {
cleanup
} -constraints {unix notRoot testchmod notInWsl} -body {
} -constraints {unix notRoot testchmod notWsl} -body {
file mkdir [file join td1 tdx]
file mkdir [file join td2 tdy]
testchmod 0o555 td2
Expand Down Expand Up @@ -1177,7 +1177,7 @@ test fCmd-10.5 {file copy: comprehensive: dir to empty dir} -setup {
} -result [subst {{td1 td2 tdd1 tdd2 tdd3 tdd4 tds1 tds2 tds3 tds4} {1 {error copying "td1" to "[file join td2 td1]": file already exists}} {1 {error copying "tds1" to "[file join tdd1 tds1]": file already exists}} 1 1 1}]
test fCmd-10.6 {file copy: comprehensive: dir to non-empty dir} -setup {
cleanup
} -constraints {notRoot unixOrWin testchmod notInWsl} -body {
} -constraints {notRoot unixOrWin testchmod notWsl} -body {
file mkdir tds1
file mkdir tds2
file mkdir [file join tdd1 tds1 xxx]
Expand All @@ -1201,7 +1201,7 @@ test fCmd-10.7 {file rename: comprehensive: file to new name and dir} -setup {
} -result [subst {{tf1 tf2} {[file join td1 tf3] [file join td1 tf4]} 1 0}]
test fCmd-10.8 {file rename: comprehensive: dir to new name and dir} -setup {
cleanup
} -constraints {unix notRoot testchmod notInWsl} -body {
} -constraints {unix notRoot testchmod notWsl} -body {
file mkdir td1
file mkdir td2
file mkdir td3
Expand Down Expand Up @@ -1398,7 +1398,7 @@ test fCmd-12.7 {renamefile: renaming directory into offspring} -setup {
} -result {1}
test fCmd-12.8 {renamefile: generic error} -setup {
catch {file delete -force -- tfa}
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir tfa
file mkdir tfa/dir
file attributes tfa -permissions 0o555
Expand Down Expand Up @@ -1585,7 +1585,7 @@ test fCmd-14.7 {copyfile: copy directory succeeding} -setup {
} -result {1 1}
test fCmd-14.8 {copyfile: copy directory failing} -setup {
catch {file delete -force -- tfa}
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir tfa/dir/a/b/c
file attributes tfa/dir -permissions 0
catch {file copy tfa tfa2}
Expand Down Expand Up @@ -1730,7 +1730,7 @@ test fCmd-16.8 {remove a normal file} -constraints {notRoot} -setup {
} -result {1}
test fCmd-16.9 {error while deleting file} -setup {
catch {file delete -force -- tfa}
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir tfa
createfile tfa/a
file attributes tfa -permissions 0o555
Expand Down Expand Up @@ -1761,7 +1761,7 @@ test fCmd-16.11 {TclFileDeleteCmd: removing a nonexistant file} -setup {
# More coverage tests for mkpath()
test fCmd-17.1 {mkdir stat failing on target but not ENOENT} -setup {
catch {file delete -force -- tfa1}
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir tfa1
file attributes tfa1 -permissions 0o555
catch {file mkdir tfa1/tfa2}
Expand Down Expand Up @@ -1971,7 +1971,7 @@ test fCmd-19.1 {remove empty directory} -constraints {notRoot} -setup {
} -result {0}
test fCmd-19.2 {rmdir error besides EEXIST} -setup {
catch {file delete -force -- tfa}
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir tfa
file mkdir tfa/a
file attributes tfa -permissions 0o555
Expand Down Expand Up @@ -1999,7 +1999,7 @@ test fCmd-19.3 {recursive remove} -constraints {notRoot} -setup {
#
test fCmd-20.1 {TraverseUnixTree : failure opening a subdirectory directory} -setup {
catch {file delete -force -- tfa}
} -constraints {unix notRoot notInWsl} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir tfa
file mkdir tfa/a
file attributes tfa/a -permissions 00000
Expand Down
6 changes: 4 additions & 2 deletions tests/io.test
Expand Up @@ -49,6 +49,8 @@ testConstraint testservicemode [llength [info commands testservicemode]]
testConstraint notWinCI [expr {
$::tcl_platform(platform) ne "windows" || ![info exists ::env(CI)]}]
testConstraint notOSX [expr {$::tcl_platform(os) ne "Darwin"}]
# File permissions broken on wsl without some "exotic" wsl configuration
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]

# You need a *very* special environment to do some tests. In
# particular, many file systems do not support large-files...
Expand Down Expand Up @@ -5896,7 +5898,7 @@ test io-40.1 {POSIX open access modes: RDWR} {
close $f
set x
} {zzy abzzy}
test io-40.2 {POSIX open access modes: CREAT} {unix} {
test io-40.2 {POSIX open access modes: CREAT} {unix notWsl} {
file delete $path(test3)
set f [open $path(test3) {WRONLY CREAT} 0o600]
file stat $path(test3) stats
Expand All @@ -5908,7 +5910,7 @@ test io-40.2 {POSIX open access modes: CREAT} {unix} {
close $f
set x
} {0o600 {line 1}}
test io-40.3 {POSIX open access modes: CREAT} {unix umask} {
test io-40.3 {POSIX open access modes: CREAT} {unix umask notWsl} {
# This test only works if your umask is 2, like ouster's.
file delete $path(test3)
set f [open $path(test3) {WRONLY CREAT}]
Expand Down
11 changes: 7 additions & 4 deletions tests/tcltest.test
Expand Up @@ -22,6 +22,9 @@ if {"::tcltest" ni [namespace children]} {
namespace import -force ::tcltest::*
}

# File permissions broken on wsl without some "exotic" wsl configuration
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]

namespace eval ::tcltest::test {

namespace import ::tcltest::*
Expand Down Expand Up @@ -306,7 +309,7 @@ test tcltest-5.3 {testConstraint - constraint empty (tcltest::safeFetch)} {
#}

test tcltest-5.5 {InitConstraints: list of built-in constraints} \
-constraints {!singleTestInterp} \
-constraints {!singleTestInterp notWsl} \
-setup {tcltest::InitConstraints} \
-body { lsort [array names ::tcltest::testConstraints] } \
-result [lsort {
Expand Down Expand Up @@ -557,7 +560,7 @@ switch -- $::tcl_platform(platform) {
}
}
test tcltest-8.3 {tcltest a.tcl -tmpdir notReadableDir} {
-constraints {unix notRoot}
-constraints {unix notRoot notWsl}
-body {
child msg $a -tmpdir $notReadableDir
return $msg
Expand All @@ -573,7 +576,7 @@ testConstraint notFAT [expr {
}]
# FAT/NTFS permissions are fairly hopeless; ignore this test if that FS is used
test tcltest-8.4 {tcltest a.tcl -tmpdir notWriteableDir} {
-constraints {unixOrWin notRoot notFAT}
-constraints {unixOrWin notRoot notFAT notWsl}
-body {
child msg $a -tmpdir $notWriteableDir
return $msg
Expand Down Expand Up @@ -646,7 +649,7 @@ test tcltest-8.11 {tcltest a.tcl -testdir thisdirectoryisafile} {
-result {*not a directory*}
}
test tcltest-8.12 {tcltest a.tcl -testdir notReadableDir} {
-constraints {unix notRoot}
-constraints {unix notRoot notWsl}
-body {
child msg $a -testdir $notReadableDir
return $msg
Expand Down
12 changes: 7 additions & 5 deletions tests/unixFCmd.test
Expand Up @@ -18,6 +18,8 @@ if {"::tcltest" ni [namespace children]} {
catch [list package require -exact tcl::test [info patchlevel]]

testConstraint testchmod [llength [info commands testchmod]]
# File permissions broken on wsl without some "exotic" wsl configuration
testConstraint notWsl [expr {[llength [array names ::env *WSL*]] == 0}]

# These tests really need to be run from a writable directory, which
# it is assumed [temporaryDirectory] is.
Expand Down Expand Up @@ -94,7 +96,7 @@ if {[testConstraint unix] && [testConstraint notRoot]} {

test unixFCmd-1.1 {TclpRenameFile: EACCES} -setup {
cleanup
} -constraints {unix notRoot} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir td1/td2/td3
file attributes td1/td2 -permissions 0
file rename td1/td2/td3 td2
Expand Down Expand Up @@ -135,7 +137,7 @@ test unixFCmd-1.6 {TclpRenameFile: ENOTDIR} {emptyTest unix notRoot} {
} {}
test unixFCmd-1.7 {TclpRenameFile: EXDEV} -setup {
cleanup
} -constraints {unix notRoot} -body {
} -constraints {unix notRoot notWsl} -body {
file mkdir foo/bar
file attr foo -perm 0o40555
file rename foo/bar /tmp
Expand Down Expand Up @@ -219,7 +221,7 @@ test unixFCmd-2.4 {TclpCopyFile: src is fifo} -setup {
} -result {fifo fifo}
test unixFCmd-2.5 {TclpCopyFile: copy attributes} -setup {
cleanup
} -constraints {unix notRoot} -body {
} -constraints {unix notRoot notWsl} -body {
close [open tf1 a]
file attributes tf1 -permissions 0o472
file copy tf1 tf2
Expand Down Expand Up @@ -334,7 +336,7 @@ test unixFCmd-16.3 {SetOwnerAttribute - invalid owner} -setup {

test unixFCmd-17.1 {SetPermissionsAttribute} -setup {
catch {file delete -force -- foo.test}
} -constraints {unix notRoot} -body {
} -constraints {unix notRoot notWsl} -body {
close [open foo.test w]
list [file attributes foo.test -permissions 0] \
[file attributes foo.test -permissions]
Expand Down Expand Up @@ -366,7 +368,7 @@ test unixFCmd-17.4 {SetPermissionsAttribute} -setup {
close [open foo.test w]
set ::i 4
proc permcheck {testnum permList expected} {
test $testnum {SetPermissionsAttribute} {unix notRoot} {
test $testnum {SetPermissionsAttribute} {unix notRoot notWsl} {
set result {}
foreach permstr $permList {
file attributes foo.test -permissions $permstr
Expand Down

0 comments on commit e3e5fcc

Please sign in to comment.