@@ -14,9 +14,8 @@ namespace System.IO.Compression.Tests
14
14
{
15
15
public partial class ZipFile_Unix : ZipFileTestBase
16
16
{
17
- [ Theory ]
18
- [ MemberData ( nameof ( Get_Booleans_Data ) ) ]
19
- public async Task UnixCreateSetsPermissionsInExternalAttributes ( bool async )
17
+ [ Fact ]
18
+ public void UnixCreateSetsPermissionsInExternalAttributes ( )
20
19
{
21
20
// '7600' tests that S_ISUID, S_ISGID, and S_ISVTX bits get preserved in ExternalAttributes
22
21
string [ ] testPermissions = new [ ] { "777" , "755" , "644" , "600" , "7600" } ;
@@ -26,29 +25,28 @@ public async Task UnixCreateSetsPermissionsInExternalAttributes(bool async)
26
25
string [ ] expectedPermissions = CreateFiles ( tempFolder . Path , testPermissions ) ;
27
26
28
27
string archivePath = GetTestFilePath ( ) ;
29
- await CallZipFileCreateFromDirectory ( async , tempFolder . Path , archivePath ) ;
30
-
31
- ZipArchive archive = await CallZipFileOpenRead ( async , archivePath ) ;
28
+ ZipFile . CreateFromDirectory ( tempFolder . Path , archivePath ) ;
32
29
33
- Assert . Equal ( expectedPermissions . Length , archive . Entries . Count ) ;
34
-
35
- foreach ( ZipArchiveEntry entry in archive . Entries )
30
+ using ( ZipArchive archive = ZipFile . OpenRead ( archivePath ) )
36
31
{
37
- Assert . EndsWith ( ".txt" , entry . Name , StringComparison . Ordinal ) ;
38
- EnsureExternalAttributes ( entry . Name . Substring ( 0 , entry . Name . Length - 4 ) , entry ) ;
39
- }
32
+ Assert . Equal ( expectedPermissions . Length , archive . Entries . Count ) ;
40
33
41
- void EnsureExternalAttributes ( string permissions , ZipArchiveEntry entry )
42
- {
43
- Assert . Equal ( Convert . ToInt32 ( permissions , 8 ) , ( entry . ExternalAttributes >> 16 ) & 0xFFF ) ;
44
- }
34
+ foreach ( ZipArchiveEntry entry in archive . Entries )
35
+ {
36
+ Assert . EndsWith ( ".txt" , entry . Name , StringComparison . Ordinal ) ;
37
+ EnsureExternalAttributes ( entry . Name . Substring ( 0 , entry . Name . Length - 4 ) , entry ) ;
38
+ }
45
39
46
- await DisposeZipArchive ( async , archive ) ;
40
+ void EnsureExternalAttributes ( string permissions , ZipArchiveEntry entry )
41
+ {
42
+ Assert . Equal ( Convert . ToInt32 ( permissions , 8 ) , ( entry . ExternalAttributes >> 16 ) & 0xFFF ) ;
43
+ }
44
+ }
47
45
48
46
// test that round tripping the archive has the same file permissions
49
47
using ( var extractFolder = new TempDirectory ( Path . Combine ( GetTestFilePath ( ) , "extract" ) ) )
50
48
{
51
- await CallZipFileExtractToDirectory ( async , archivePath , extractFolder . Path ) ;
49
+ ZipFile . ExtractToDirectory ( archivePath , extractFolder . Path ) ;
52
50
53
51
foreach ( string permission in expectedPermissions )
54
52
{
@@ -61,72 +59,57 @@ void EnsureExternalAttributes(string permissions, ZipArchiveEntry entry)
61
59
}
62
60
}
63
61
64
- [ ConditionalTheory ( typeof ( RemoteExecutor ) , nameof ( RemoteExecutor . IsSupported ) ) ]
65
- [ MemberData ( nameof ( Get_Booleans_Data ) ) ]
66
- public void UnixCreateSetsPermissionsInExternalAttributesUMaskZero( bool async )
62
+ [ ConditionalFact ( typeof ( RemoteExecutor ) , nameof ( RemoteExecutor . IsSupported ) ) ]
63
+ public void UnixCreateSetsPermissionsInExternalAttributesUMaskZero ( )
67
64
{
68
- RemoteExecutor. Invoke ( async ( ) =>
65
+ RemoteExecutor . Invoke ( ( ) =>
69
66
{
70
67
umask ( 0 ) ;
71
- await new ZipFile_Unix ( ) . UnixCreateSetsPermissionsInExternalAttributes ( async ) ;
68
+ new ZipFile_Unix ( ) . UnixCreateSetsPermissionsInExternalAttributes ( ) ;
72
69
} ) . Dispose ( ) ;
73
70
}
74
71
75
- [ Theory ]
76
- [ MemberData ( nameof ( Get_Booleans_Data ) ) ]
77
- public async Task UnixExtractSetsFilePermissionsFromExternalAttributes( bool async )
72
+ [ Fact ]
73
+ public void UnixExtractSetsFilePermissionsFromExternalAttributes ( )
78
74
{
79
75
// '7600' tests that S_ISUID, S_ISGID, and S_ISVTX bits don't get extracted to file permissions
80
76
string [ ] testPermissions = new [ ] { "777" , "755" , "644" , "754" , "7600" } ;
81
77
82
78
string archivePath = GetTestFilePath ( ) ;
83
79
using ( FileStream fileStream = new FileStream ( archivePath , FileMode . CreateNew ) )
80
+ using ( ZipArchive archive = new ZipArchive ( fileStream , ZipArchiveMode . Create ) )
84
81
{
85
- ZipArchive archive = await CreateZipArchive ( async , fileStream , ZipArchiveMode . Create ) ;
86
-
87
82
foreach ( string permission in testPermissions )
88
83
{
89
84
ZipArchiveEntry entry = archive . CreateEntry ( permission + ".txt" ) ;
90
85
entry . ExternalAttributes = Convert . ToInt32 ( permission , 8 ) << 16 ;
91
- Stream stream = await OpenEntryStream ( async , entry ) ;
92
- ReadOnlySpan< byte > contents = "contents"u8;
93
- if ( async )
94
- {
95
- await stream . WriteAsync ( contents . ToArray ( ) ) ;
96
- }
97
- else
98
- {
99
- stream . Write ( contents ) ;
100
- }
86
+ using Stream stream = entry . Open ( ) ;
87
+ stream . Write ( "contents"u8 ) ;
101
88
stream . Flush ( ) ;
102
- await DisposeStream ( async , stream ) ;
103
89
}
90
+ }
104
91
105
- await DisposeZipArchive ( async , archive ) ;
92
+ using ( var tempFolder = new TempDirectory ( GetTestFilePath ( ) ) )
93
+ {
94
+ ZipFile . ExtractToDirectory ( archivePath , tempFolder . Path ) ;
106
95
107
- using ( var tempFolder = new TempDirectory ( GetTestFilePath ( ) ) )
96
+ foreach ( string permission in testPermissions )
108
97
{
109
- await CallZipFileExtractToDirectory ( async , archivePath , tempFolder . Path ) ;
110
-
111
- foreach ( string permission in testPermissions )
112
- {
113
- string filename = Path . Combine ( tempFolder . Path , permission + ".txt" ) ;
114
- Assert. True ( File . Exists ( filename ) ) ;
98
+ string filename = Path . Combine ( tempFolder . Path , permission + ".txt" ) ;
99
+ Assert . True ( File . Exists ( filename ) ) ;
115
100
116
- EnsureFilePermissions( filename , permission ) ;
117
- }
101
+ EnsureFilePermissions ( filename , permission ) ;
118
102
}
119
103
}
120
104
}
121
105
122
- [ ConditionalTheory ( typeof ( RemoteExecutor ) , nameof ( RemoteExecutor . IsSupported ) ) ]
123
- [ MemberData ( nameof ( Get_Booleans_Data ) ) ]
124
- public void UnixExtractSetsFilePermissionsFromExternalAttributesUMaskZero( bool async )
106
+ [ ConditionalFact ( typeof ( RemoteExecutor ) , nameof ( RemoteExecutor . IsSupported ) ) ]
107
+ public void UnixExtractSetsFilePermissionsFromExternalAttributesUMaskZero ( )
125
108
{
126
- RemoteExecutor. Invoke ( async ( ) =>
109
+ RemoteExecutor . Invoke ( ( ) =>
127
110
{
128
111
umask ( 0 ) ;
129
- await new ZipFile_Unix ( ) . UnixExtractSetsFilePermissionsFromExternalAttributes ( async ) ;
112
+ new ZipFile_Unix ( ) . UnixExtractSetsFilePermissionsFromExternalAttributes ( ) ;
130
113
} ) . Dispose ( ) ;
131
114
}
132
115
0 commit comments