Fossil SCM

Add test-cases for function file_relative_name(), three then failing without [565ba734d2]

jan.nijtmans 2014-04-10 08:36 trunk
Commit 1762a72f0e295183c8742f2bbf5621bf104f884c
1 file changed +20
--- test/file1.test
+++ test/file1.test
@@ -24,10 +24,19 @@
2424
fossil test-simplify-name $path
2525
test simplify-name-$testname.$i {$::RESULT=="\[$path\] -> \[$result\]"}
2626
incr i
2727
}
2828
}
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
+}
2938
3039
simplify-name 100 . . .// . .. .. ..///// ..
3140
simplify-name 101 {} {} / / ///////// / ././././ .
3241
simplify-name 102 x x /x /x ///x //x
3342
simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b
@@ -38,5 +47,16 @@
3847
3948
if {$::tcl_platform(os)=="Windows NT"} {
4049
simplify-name 108 //?/a:/a/b a:/a/b //?/UNC/a/b //a/b //?/ {}
4150
simplify-name 109 \\\\?\\a:\\a\\b a:/a/b \\\\?\\UNC\\a\\b //a/b \\\\?\\ {}
4251
}
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}
4363
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button