2016-03-30 19:47:32 -04:00
|
|
|
USING: io.backend io.directories io.files.private io.files.temp
|
2018-07-07 12:59:59 -04:00
|
|
|
io.files.unique io.pathnames kernel locals math multiline
|
|
|
|
namespaces sequences system tools.test ;
|
2008-12-14 21:03:00 -05:00
|
|
|
|
2015-07-02 20:28:17 -04:00
|
|
|
{ "passwd" } [ "/etc/passwd" file-name ] unit-test
|
|
|
|
{ "awk" } [ "/usr/libexec/awk/" file-name ] unit-test
|
|
|
|
{ "awk" } [ "/usr/libexec/awk///" file-name ] unit-test
|
|
|
|
{ "" } [ "" file-name ] unit-test
|
|
|
|
|
|
|
|
{ "freetype6.dll" } [ "resource:freetype6.dll" file-name ] unit-test
|
|
|
|
{ "freetype6.dll" } [ "resource:/freetype6.dll" file-name ] unit-test
|
|
|
|
|
|
|
|
{ "/usr/lib" } [ "/usr" "lib" append-path ] unit-test
|
|
|
|
{ "/usr/lib" } [ "/usr/" "lib" append-path ] unit-test
|
|
|
|
{ "/usr/lib" } [ "/usr" "./lib" append-path ] unit-test
|
|
|
|
{ "/usr/lib/" } [ "/usr" "./lib/" append-path ] unit-test
|
|
|
|
{ "/lib" } [ "/usr" "../lib" append-path ] unit-test
|
|
|
|
{ "/lib/" } [ "/usr" "../lib/" append-path ] unit-test
|
|
|
|
|
|
|
|
{ "" } [ "" "." append-path ] unit-test
|
2008-12-14 21:03:00 -05:00
|
|
|
[ "" ".." append-path ] must-fail
|
|
|
|
|
2015-07-02 20:28:17 -04:00
|
|
|
{ "/" } [ "/" "./." append-path ] unit-test
|
|
|
|
{ "/" } [ "/" "././" append-path ] unit-test
|
|
|
|
{ "/a/b/lib" } [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test
|
|
|
|
{ "/a/b/lib/" } [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test
|
2008-12-14 21:03:00 -05:00
|
|
|
|
|
|
|
[ "" "../lib/" append-path ] must-fail
|
2015-07-02 20:28:17 -04:00
|
|
|
{ "lib" } [ "" "lib" append-path ] unit-test
|
|
|
|
{ "lib" } [ "" "./lib" append-path ] unit-test
|
2008-12-14 21:03:00 -05:00
|
|
|
|
|
|
|
[ "foo/bar/." parent-directory ] must-fail
|
|
|
|
[ "foo/bar/./" parent-directory ] must-fail
|
|
|
|
[ "foo/bar/baz/.." parent-directory ] must-fail
|
|
|
|
[ "foo/bar/baz/../" parent-directory ] must-fail
|
|
|
|
|
|
|
|
[ "." parent-directory ] must-fail
|
|
|
|
[ "./" parent-directory ] must-fail
|
|
|
|
[ ".." parent-directory ] must-fail
|
|
|
|
[ "../" parent-directory ] must-fail
|
|
|
|
[ "../../" parent-directory ] must-fail
|
|
|
|
[ "foo/.." parent-directory ] must-fail
|
|
|
|
[ "foo/../" parent-directory ] must-fail
|
|
|
|
[ "" parent-directory ] must-fail
|
2015-07-02 20:28:17 -04:00
|
|
|
{ "." } [ "boot.x86.64.image" parent-directory ] unit-test
|
2008-12-14 21:03:00 -05:00
|
|
|
|
2015-07-02 20:28:17 -04:00
|
|
|
{ "bar/foo" } [ "bar/baz" "..///foo" append-path ] unit-test
|
|
|
|
{ "bar/baz/foo" } [ "bar/baz" ".///foo" append-path ] unit-test
|
|
|
|
{ "bar/foo" } [ "bar/baz" "./..//foo" append-path ] unit-test
|
|
|
|
{ "bar/foo" } [ "bar/baz" "./../././././././///foo" append-path ] unit-test
|
2008-12-14 21:03:00 -05:00
|
|
|
|
2015-07-02 20:28:17 -04:00
|
|
|
{ t } [ "resource:core" absolute-path? ] unit-test
|
|
|
|
{ f } [ "" absolute-path? ] unit-test
|
2008-12-14 21:03:00 -05:00
|
|
|
|
2016-04-04 13:32:42 -04:00
|
|
|
[| path |
|
|
|
|
{ } [ 2 [ path touch-file ] times ] unit-test
|
|
|
|
] with-test-file
|
2008-12-14 21:03:00 -05:00
|
|
|
|
|
|
|
! aum's bug
|
2016-03-03 17:36:48 -05:00
|
|
|
H{
|
|
|
|
{ current-directory "." }
|
|
|
|
{ "resource-path" ".." }
|
|
|
|
} [
|
2008-12-14 21:03:00 -05:00
|
|
|
[ "../core/bootstrap/stage2.factor" ]
|
2010-02-17 19:06:13 -05:00
|
|
|
[ "resource:core/bootstrap/stage2.factor" absolute-path ]
|
2008-12-14 21:03:00 -05:00
|
|
|
unit-test
|
2016-03-02 20:18:42 -05:00
|
|
|
] with-variables
|
2008-12-14 21:03:00 -05:00
|
|
|
|
2015-07-02 20:28:17 -04:00
|
|
|
{ t } [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test
|
2009-02-18 14:33:55 -05:00
|
|
|
|
|
|
|
! Regression test for bug in file-extension
|
2015-07-02 20:28:17 -04:00
|
|
|
{ f } [ "/funny.directory/file-with-no-extension" file-extension ] unit-test
|
|
|
|
{ "" } [ "/funny.directory/file-with-no-extension." file-extension ] unit-test
|
2011-12-21 11:35:05 -05:00
|
|
|
|
2012-01-10 21:25:53 -05:00
|
|
|
! Testing ~ special pathname
|
2015-07-02 20:28:17 -04:00
|
|
|
{ t } [ os windows? "~\\" "~/" ? absolute-path home = ] unit-test
|
|
|
|
{ t } [ "~/" home [ normalize-path ] same? ] unit-test
|
2012-01-10 21:25:53 -05:00
|
|
|
|
2015-07-02 20:28:17 -04:00
|
|
|
{ t } [ "~" absolute-path home = ] unit-test
|
|
|
|
{ t } [ "~" home [ normalize-path ] same? ] unit-test
|
2012-01-10 21:25:53 -05:00
|
|
|
|
2015-07-02 20:28:17 -04:00
|
|
|
{ t } [ "~" home [ "foo" append-path ] bi@ [ normalize-path ] same? ] unit-test
|
|
|
|
{ t } [ os windows? "~\\~/" "~/~/" ? "~" "~" append-path [ path-components ] same? ] unit-test
|
2018-07-07 12:59:59 -04:00
|
|
|
|
|
|
|
! Absolute paths
|
|
|
|
os windows? [
|
|
|
|
{ "c:/" } [ "c:/" canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/." canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/.." canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/Users/.." canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/Users/../" canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/Users/../." canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/Users/.././" canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/Users/.././././././" canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/Users/../././/////./././/././././//././././././." canonicalize-path ] unit-test
|
|
|
|
{ "c:/" } [ "c:/Users/../../../..////.././././././/../" canonicalize-path ] unit-test
|
|
|
|
{ "c:/Users" } [ "c:/Users/../../../Users" canonicalize-path ] unit-test
|
|
|
|
|
|
|
|
{ "c:/Users" } [ "c:/Users" canonicalize-path ] unit-test
|
|
|
|
{ "c:/Users" } [ "c:/Users/." canonicalize-path ] unit-test
|
|
|
|
{ "c:/Users\\foo\\bar" } [ "c:/Users/foo/bar" canonicalize-path ] unit-test
|
|
|
|
] [
|
|
|
|
{ "/" } [ "/" canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/." canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/.." canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/.." canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/../" canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/../." canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/.././" canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/.././././././" canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/../././/////./././/././././//././././././." canonicalize-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/../../../..////.././././././/../" canonicalize-path ] unit-test
|
|
|
|
{ "/Users" } [ "/Users/../../../Users" canonicalize-path ] unit-test
|
|
|
|
|
|
|
|
{ "/Users" } [ "/Users" canonicalize-path ] unit-test
|
|
|
|
{ "/Users" } [ "/Users/." canonicalize-path ] unit-test
|
|
|
|
{ "/Users/foo/bar" } [ "/Users/foo/bar" canonicalize-path ] unit-test
|
|
|
|
] if
|
|
|
|
|
|
|
|
|
|
|
|
! Relative paths
|
|
|
|
{ "." } [ f canonicalize-path ] unit-test
|
|
|
|
{ "." } [ "" canonicalize-path ] unit-test
|
|
|
|
{ "." } [ "." canonicalize-path ] unit-test
|
|
|
|
{ "." } [ "./" canonicalize-path ] unit-test
|
|
|
|
{ "." } [ "./." canonicalize-path ] unit-test
|
|
|
|
{ ".." } [ ".." canonicalize-path ] unit-test
|
|
|
|
{ ".." } [ "../" canonicalize-path ] unit-test
|
|
|
|
{ ".." } [ "../." canonicalize-path ] unit-test
|
|
|
|
{ ".." } [ ".././././././//." canonicalize-path ] unit-test
|
|
|
|
|
|
|
|
{ t } [ "../.." canonicalize-path { "../.." "..\\.." } member? ] unit-test
|
|
|
|
{ t } [ "../../" canonicalize-path { "../.." "..\\.." } member? ] unit-test
|
|
|
|
{ t } [ "../.././././/./././" canonicalize-path { "../.." "..\\.." } member? ] unit-test
|
|
|
|
|
|
|
|
|
|
|
|
! Root paths
|
|
|
|
os windows? [
|
|
|
|
{ "d:\\" } [ "d:\\" root-path ] unit-test
|
|
|
|
{ "d:\\" } [ "d:\\\\\\\\//////" root-path ] unit-test
|
|
|
|
{ "c:\\" } [ "c:\\Users\\merlen" root-path ] unit-test
|
|
|
|
{ "c:\\" } [ "c:\\\\\\//Users//\\//merlen//" root-path ] unit-test
|
|
|
|
{ "d:\\" } [ "d:\\././././././/../../../" root-path ] unit-test
|
|
|
|
{ "d:\\" } [ "d:\\merlen\\dog" root-path ] unit-test
|
|
|
|
|
|
|
|
{ "d:\\" } [ "\\\\?\\d:\\" root-path ] unit-test
|
|
|
|
{ "d:\\" } [ "\\\\?\\d:\\\\\\\\//////" root-path ] unit-test
|
|
|
|
{ "c:\\" } [ "\\\\?\\c:\\Users\\merlen" root-path ] unit-test
|
|
|
|
{ "c:\\" } [ "\\\\?\\c:\\\\\\//Users//\\//merlen//" root-path ] unit-test
|
|
|
|
{ "d:\\" } [ "\\\\?\\d:\\././././././/../../../" root-path ] unit-test
|
|
|
|
{ "d:\\" } [ "\\\\?\\d:\\merlen\\dog" root-path ] unit-test
|
|
|
|
] [
|
|
|
|
{ "/" } [ "/" root-path ] unit-test
|
|
|
|
{ "/" } [ "//" root-path ] unit-test
|
|
|
|
{ "/" } [ "/Users" root-path ] unit-test
|
|
|
|
{ "/" } [ "//Users" root-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/foo/bar////././." root-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/foo/bar////.//../../../../../../////./." root-path ] unit-test
|
|
|
|
{ "/" } [ "/Users/////" root-path ] unit-test
|
|
|
|
] if
|