@@ -29,8 +29,6 @@ import XCTest
29
29
final class AttributesTests : XCTestCase {
30
30
31
31
func testType( ) throws {
32
- expect ( Path . root. appending ( " /tmp " ) . type) == . symlink
33
-
34
32
try Path . temporary { dir in
35
33
expect ( dir. type) == . directory
36
34
expect ( dir. appending ( " nonexist " ) . type) == . unknown
@@ -41,6 +39,10 @@ final class AttributesTests: XCTestCase {
41
39
let pipe = dir. appending ( " pipe " )
42
40
try CLI . run ( " mkfifo " , pipe. path. quoted)
43
41
expect ( pipe. type) == . pipe
42
+
43
+ let symlink = dir. appending ( " link " )
44
+ try CLI . run ( " ln -s " , file. path. quoted, symlink. path. quoted)
45
+ expect ( symlink. type) == . symlink
44
46
}
45
47
}
46
48
@@ -51,8 +53,12 @@ final class AttributesTests: XCTestCase {
51
53
52
54
try file. touch ( )
53
55
expect ( attributes) . notTo ( beNil ( ) )
56
+ expect ( attributes. modificationDate) . notTo ( beNil ( ) )
57
+
58
+ #if os(macOS)
54
59
expect ( attributes. modificationDate) < file. attributes!. modificationDate
55
60
expect ( attributes. creationDate) < file. attributes!. modificationDate
61
+ #endif
56
62
}
57
63
}
58
64
@@ -64,17 +70,20 @@ final class AttributesTests: XCTestCase {
64
70
let attributes = file. attributes!
65
71
66
72
expect ( attributes) . notTo ( beNil ( ) )
67
- expect ( attributes. extensionHidden) == false
68
- expect ( attributes. groupName) == " staff "
69
- if #available( OSX 10 . 12 , * ) {
70
- expect ( attributes. userName) == ProcessInfo . processInfo. userName
71
- }
72
- expect ( attributes. permissions. rawValue) == 0o644
73
+ try expect ( attributes. groupName) == CLI . run ( " groups $(whoami) | cut -d' ' -f1 | tr -d $' \n ' " )
74
+ try expect ( attributes. userName) == CLI . run ( " whoami | tr -d $' \n ' " )
73
75
expect ( attributes. size) == 1
76
+
77
+ #if os(macOS)
78
+ expect ( attributes. permissions. rawValue) == 0o644
79
+ #else
80
+ expect ( attributes. permissions. rawValue) == 0o600
81
+ #endif
74
82
}
75
83
}
76
84
77
85
func testModifyAttributes( ) throws {
86
+ #if os(macOS)
78
87
try Path . temporary { dir in
79
88
let file = try dir. touch ( " data " ) . write ( text: " a " )
80
89
var attributes = file. attributes!
@@ -97,9 +106,11 @@ final class AttributesTests: XCTestCase {
97
106
expect ( attributes. permissions. rawValue) == 0o777
98
107
expect ( attributes. groupName) == " staff "
99
108
}
109
+ #endif
100
110
}
101
111
102
112
func testModifyAttributes_macOS( ) throws {
113
+ #if os(macOS)
103
114
try Path . temporary { dir in
104
115
let file = try dir. touch ( " data " ) . write ( text: " a " )
105
116
var attributes = file. attributes!
@@ -111,5 +122,6 @@ final class AttributesTests: XCTestCase {
111
122
try attributes. reload ( )
112
123
expect ( attributes. extensionHidden) == true
113
124
}
125
+ #endif
114
126
}
115
127
}
0 commit comments