Fossil SCM
Add test-cases for function file_relative_name(), three then failing without [565ba734d2]
Commit
1762a72f0e295183c8742f2bbf5621bf104f884c
Parent
565ba734d2a6c1d…
1 file changed
+20
+20
| --- test/file1.test | ||
| +++ test/file1.test | ||
| @@ -24,10 +24,19 @@ | ||
| 24 | 24 | fossil test-simplify-name $path |
| 25 | 25 | test simplify-name-$testname.$i {$::RESULT=="\[$path\] -> \[$result\]"} |
| 26 | 26 | incr i |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | + | |
| 30 | +proc relative-name {testname args} { | |
| 31 | + set i 1 | |
| 32 | + foreach {subdir path result} $args { | |
| 33 | + fossil test-relative-name --chdir $subdir $path | |
| 34 | + test relative-name-$testname.$i {$::RESULT==$result} | |
| 35 | + incr i | |
| 36 | + } | |
| 37 | +} | |
| 29 | 38 | |
| 30 | 39 | simplify-name 100 . . .// . .. .. ..///// .. |
| 31 | 40 | simplify-name 101 {} {} / / ///////// / ././././ . |
| 32 | 41 | simplify-name 102 x x /x /x ///x //x |
| 33 | 42 | simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b |
| @@ -38,5 +47,16 @@ | ||
| 38 | 47 | |
| 39 | 48 | if {$::tcl_platform(os)=="Windows NT"} { |
| 40 | 49 | simplify-name 108 //?/a:/a/b a:/a/b //?/UNC/a/b //a/b //?/ {} |
| 41 | 50 | simplify-name 109 \\\\?\\a:\\a\\b a:/a/b \\\\?\\UNC\\a\\b //a/b \\\\?\\ {} |
| 42 | 51 | } |
| 52 | + | |
| 53 | +# Those directories are only needed for the testcase being able to "--chdir" to it. | |
| 54 | +file mkdir test1 | |
| 55 | +file mkdir test1/test2 | |
| 56 | + | |
| 57 | +relative-name 100 . . . test1 [pwd] .. test1 [pwd]/ .. test1 [pwd]/test ../test | |
| 58 | +relative-name 101 test1/test2 [pwd] ../.. test1/test2 [pwd]/ ../.. test1/test2 [pwd]/test ../../test | |
| 59 | +relative-name 102 test1 [pwd]/test ../test . [pwd]/file1 ./file1 . [pwd]/file1/file2 ./file1/file2 | |
| 60 | + | |
| 61 | +catch {file delete test1/test2} | |
| 62 | +catch {file delete test1} | |
| 43 | 63 |
| --- test/file1.test | |
| +++ test/file1.test | |
| @@ -24,10 +24,19 @@ | |
| 24 | fossil test-simplify-name $path |
| 25 | test simplify-name-$testname.$i {$::RESULT=="\[$path\] -> \[$result\]"} |
| 26 | incr i |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | simplify-name 100 . . .// . .. .. ..///// .. |
| 31 | simplify-name 101 {} {} / / ///////// / ././././ . |
| 32 | simplify-name 102 x x /x /x ///x //x |
| 33 | simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b |
| @@ -38,5 +47,16 @@ | |
| 38 | |
| 39 | if {$::tcl_platform(os)=="Windows NT"} { |
| 40 | simplify-name 108 //?/a:/a/b a:/a/b //?/UNC/a/b //a/b //?/ {} |
| 41 | simplify-name 109 \\\\?\\a:\\a\\b a:/a/b \\\\?\\UNC\\a\\b //a/b \\\\?\\ {} |
| 42 | } |
| 43 |
| --- test/file1.test | |
| +++ test/file1.test | |
| @@ -24,10 +24,19 @@ | |
| 24 | fossil test-simplify-name $path |
| 25 | test simplify-name-$testname.$i {$::RESULT=="\[$path\] -> \[$result\]"} |
| 26 | incr i |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | proc relative-name {testname args} { |
| 31 | set i 1 |
| 32 | foreach {subdir path result} $args { |
| 33 | fossil test-relative-name --chdir $subdir $path |
| 34 | test relative-name-$testname.$i {$::RESULT==$result} |
| 35 | incr i |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | simplify-name 100 . . .// . .. .. ..///// .. |
| 40 | simplify-name 101 {} {} / / ///////// / ././././ . |
| 41 | simplify-name 102 x x /x /x ///x //x |
| 42 | simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b |
| @@ -38,5 +47,16 @@ | |
| 47 | |
| 48 | if {$::tcl_platform(os)=="Windows NT"} { |
| 49 | simplify-name 108 //?/a:/a/b a:/a/b //?/UNC/a/b //a/b //?/ {} |
| 50 | simplify-name 109 \\\\?\\a:\\a\\b a:/a/b \\\\?\\UNC\\a\\b //a/b \\\\?\\ {} |
| 51 | } |
| 52 | |
| 53 | # Those directories are only needed for the testcase being able to "--chdir" to it. |
| 54 | file mkdir test1 |
| 55 | file mkdir test1/test2 |
| 56 | |
| 57 | relative-name 100 . . . test1 [pwd] .. test1 [pwd]/ .. test1 [pwd]/test ../test |
| 58 | relative-name 101 test1/test2 [pwd] ../.. test1/test2 [pwd]/ ../.. test1/test2 [pwd]/test ../../test |
| 59 | relative-name 102 test1 [pwd]/test ../test . [pwd]/file1 ./file1 . [pwd]/file1/file2 ./file1/file2 |
| 60 | |
| 61 | catch {file delete test1/test2} |
| 62 | catch {file delete test1} |
| 63 |