2016-04-01 00:31:44 -04:00
|
|
|
USING: accessors arrays calendar grouping io.files.info
|
2016-04-04 13:32:42 -04:00
|
|
|
io.files.info.unix io.files.unix io.pathnames kernel literals
|
|
|
|
locals math math.bitwise math.functions sequences strings system
|
|
|
|
tools.test unix unix.groups unix.users ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2015-07-03 12:39:59 -04:00
|
|
|
{ "/usr/libexec/" } [ "/usr/libexec/awk/" parent-directory ] unit-test
|
|
|
|
{ "/etc/" } [ "/etc/passwd" parent-directory ] unit-test
|
|
|
|
{ "/" } [ "/etc/" parent-directory ] unit-test
|
|
|
|
{ "/" } [ "/etc" parent-directory ] unit-test
|
|
|
|
{ "/" } [ "/" parent-directory ] unit-test
|
|
|
|
|
|
|
|
{ f } [ "" root-directory? ] unit-test
|
|
|
|
{ t } [ "/" root-directory? ] unit-test
|
|
|
|
{ t } [ "//" root-directory? ] unit-test
|
|
|
|
{ t } [ "///////" root-directory? ] unit-test
|
|
|
|
|
|
|
|
{ "/" } [ "/" file-name ] unit-test
|
|
|
|
{ "///" } [ "///" file-name ] unit-test
|
|
|
|
|
|
|
|
{ "/" } [ "/" "../.." append-path ] unit-test
|
|
|
|
{ "/" } [ "/" "../../" append-path ] unit-test
|
|
|
|
{ "/lib" } [ "/" "../lib" append-path ] unit-test
|
|
|
|
{ "/lib/" } [ "/" "../lib/" append-path ] unit-test
|
|
|
|
{ "/lib" } [ "/" "../../lib" append-path ] unit-test
|
|
|
|
{ "/lib/" } [ "/" "../../lib/" append-path ] unit-test
|
|
|
|
|
|
|
|
{ "/lib" } [ "/usr/" "/lib" append-path ] unit-test
|
|
|
|
{ "/lib/" } [ "/usr/" "/lib/" append-path ] unit-test
|
|
|
|
{ "/lib/bux" } [ "/usr" "/lib/bux" append-path ] unit-test
|
|
|
|
{ "/lib/bux/" } [ "/usr" "/lib/bux/" append-path ] unit-test
|
|
|
|
{ t } [ "/foo" absolute-path? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
[| path |
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o777 } [
|
|
|
|
path flags{ USER-ALL GROUP-ALL OTHER-ALL } set-file-permissions
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ t } [ path user-read? ] unit-test
|
|
|
|
{ t } [ path user-write? ] unit-test
|
|
|
|
{ t } [ path user-execute? ] unit-test
|
|
|
|
{ t } [ path group-read? ] unit-test
|
|
|
|
{ t } [ path group-write? ] unit-test
|
|
|
|
{ t } [ path group-execute? ] unit-test
|
|
|
|
{ t } [ path other-read? ] unit-test
|
|
|
|
{ t } [ path other-write? ] unit-test
|
|
|
|
{ t } [ path other-execute? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o776 } [
|
|
|
|
path f set-other-execute
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info other-execute? ] unit-test
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o774 } [
|
|
|
|
path f set-other-write
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info other-write? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o770 } [
|
|
|
|
path f set-other-read
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info other-read? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o760 } [
|
|
|
|
path f set-group-execute
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info group-execute? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o740 } [
|
|
|
|
path f set-group-write
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info group-write? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o700 } [
|
|
|
|
path f set-group-read
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info group-read? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o600 } [
|
|
|
|
path f set-user-execute
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info other-execute? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o400 } [
|
|
|
|
path f set-user-write
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info other-write? ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o000 } [
|
|
|
|
path f set-user-read
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ f } [ path file-info other-read? ] unit-test
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ 0o771 } [
|
|
|
|
path flags{ USER-ALL GROUP-ALL OTHER-EXECUTE } set-file-permissions
|
|
|
|
path file-permissions 0o7777 mask
|
|
|
|
] unit-test
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
] with-test-file
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
[| path |
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ t } [
|
|
|
|
path now
|
|
|
|
[ set-file-access-time ] 2keep
|
|
|
|
[ file-info accessed>> ]
|
|
|
|
[ [ [ truncate >integer ] change-second >gmt ] bi@ ] bi* =
|
|
|
|
] unit-test
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ t }
|
|
|
|
[
|
|
|
|
path now
|
|
|
|
[ set-file-modified-time ] 2keep
|
|
|
|
[ file-info modified>> ]
|
|
|
|
[ [ [ truncate >integer ] change-second >gmt ] bi@ ] bi* =
|
|
|
|
] unit-test
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ t }
|
|
|
|
[
|
|
|
|
path now [ dup 2array set-file-times ] 2keep
|
|
|
|
[ file-info [ modified>> ] [ accessed>> ] bi ] dip
|
|
|
|
3array
|
|
|
|
[ [ truncate >integer ] change-second >gmt ] map all-equal?
|
|
|
|
] unit-test
|
2016-04-01 00:31:44 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ } [ path f now 2array set-file-times ] unit-test
|
|
|
|
{ } [ path now f 2array set-file-times ] unit-test
|
|
|
|
{ } [ path f f 2array set-file-times ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ } [ path real-user-name set-file-user ] unit-test
|
|
|
|
{ } [ path real-user-id set-file-user ] unit-test
|
|
|
|
{ } [ path real-group-name set-file-group ] unit-test
|
|
|
|
{ } [ path real-group-id set-file-group ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ t } [ path file-user-name real-user-name = ] unit-test
|
|
|
|
{ t } [ path file-group-name real-group-name = ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ } [ path real-user-id real-group-id set-file-ids ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ } [ path f real-group-id set-file-ids ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ } [ path real-user-id f set-file-ids ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
{ } [ path f f set-file-ids ] unit-test
|
2008-10-08 15:18:50 -04:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
] with-test-file
|
2008-10-18 18:29:38 -04:00
|
|
|
|
2015-07-03 12:39:59 -04:00
|
|
|
{ t } [ 0o4000 uid? ] unit-test
|
|
|
|
{ t } [ 0o2000 gid? ] unit-test
|
|
|
|
{ t } [ 0o1000 sticky? ] unit-test
|
|
|
|
{ t } [ 0o400 user-read? ] unit-test
|
|
|
|
{ t } [ 0o200 user-write? ] unit-test
|
|
|
|
{ t } [ 0o100 user-execute? ] unit-test
|
|
|
|
{ t } [ 0o040 group-read? ] unit-test
|
|
|
|
{ t } [ 0o020 group-write? ] unit-test
|
|
|
|
{ t } [ 0o010 group-execute? ] unit-test
|
|
|
|
{ t } [ 0o004 other-read? ] unit-test
|
|
|
|
{ t } [ 0o002 other-write? ] unit-test
|
|
|
|
{ t } [ 0o001 other-execute? ] unit-test
|
|
|
|
|
|
|
|
{ f } [ 0 uid? ] unit-test
|
|
|
|
{ f } [ 0 gid? ] unit-test
|
|
|
|
{ f } [ 0 sticky? ] unit-test
|
|
|
|
{ f } [ 0 user-read? ] unit-test
|
|
|
|
{ f } [ 0 user-write? ] unit-test
|
|
|
|
{ f } [ 0 user-execute? ] unit-test
|
|
|
|
{ f } [ 0 group-read? ] unit-test
|
|
|
|
{ f } [ 0 group-write? ] unit-test
|
|
|
|
{ f } [ 0 group-execute? ] unit-test
|
|
|
|
{ f } [ 0 other-read? ] unit-test
|
|
|
|
{ f } [ 0 other-write? ] unit-test
|
|
|
|
{ f } [ 0 other-execute? ] unit-test
|
2016-03-23 08:22:31 -04:00
|
|
|
|
|
|
|
! (cwd)
|
2016-03-23 10:25:32 -04:00
|
|
|
{ t } [ 1 (cwd) string? ] unit-test
|
|
|
|
|
|
|
|
os linux? [
|
|
|
|
{ t } [ "/proc/self/exe" read-symbolic-link string? ] unit-test
|
|
|
|
] when
|