@@ -40,11 +40,13 @@ public void DotDotWorks1 ()
40
40
public void RelativePathsInSymlinks1 ( )
41
41
{
42
42
using ( var dir = new DisposableTempDirectory ( ) ) {
43
- var expectedPath = Path . GetDirectoryName ( Path . GetDirectoryName ( Path . GetDirectoryName ( dir . DirectoryPath ) ) ) ;
43
+ var sourcePath = PathWithoutLeadingSlash ( Path . GetDirectoryName ( Path . GetDirectoryName ( Path . GetDirectoryName ( dir . DirectoryPath ) ) ) ) ;
44
+ var expectedPath = Path . Combine ( "/private" , sourcePath ) ;
44
45
45
46
var link1 = Path . Combine ( dir . DirectoryPath , "link1" ) ;
46
47
symlink ( "../../.." , link1 ) ;
47
48
var finalPath = PosixHelpers . RealPath ( link1 ) ;
49
+
48
50
ClassicAssert . AreEqual ( expectedPath , finalPath , "1" ) ;
49
51
}
50
52
}
@@ -53,7 +55,8 @@ public void RelativePathsInSymlinks1 ()
53
55
public void RelativePathsInSymlinks2 ( )
54
56
{
55
57
using ( var dir = new DisposableTempDirectory ( ) ) {
56
- var expectedPath = Path . GetDirectoryName ( Path . GetDirectoryName ( Path . GetDirectoryName ( dir . DirectoryPath ) ) ) ;
58
+ var sourcePath = PathWithoutLeadingSlash ( Path . GetDirectoryName ( Path . GetDirectoryName ( Path . GetDirectoryName ( dir . DirectoryPath ) ) ) ) ;
59
+ var expectedPath = Path . Combine ( "/private" , sourcePath ) ;
57
60
58
61
var link2 = Path . Combine ( dir . DirectoryPath , "link2" ) ;
59
62
symlink ( Path . Combine ( dir . DirectoryPath , ".." , ".." , ".." ) , link2 ) ;
@@ -65,5 +68,10 @@ public void RelativePathsInSymlinks2 ()
65
68
// Mono.Unix can't create symlinks with relative paths, so P/Invoke instead.
66
69
[ DllImport ( "/usr/lib/libSystem.dylib" ) ]
67
70
static extern int symlink ( string path1 , string path2 ) ;
71
+
72
+ static string PathWithoutLeadingSlash ( string path )
73
+ {
74
+ return path . StartsWith ( '/' ) ? path . Substring ( 1 ) : path ;
75
+ }
68
76
}
69
77
}
0 commit comments