@@ -26,37 +26,48 @@ public class UnpackPackTests
2626 "macospkg" ,
2727 "Microsoft.Dotnet.MacOsPkg.dll" ) ;
2828
29- private static readonly string [ ] simplePkgFiles =
29+ const UnixFileMode nonExecutableFileMode = UnixFileMode . OtherRead |
30+ UnixFileMode . GroupRead |
31+ UnixFileMode . UserWrite |
32+ UnixFileMode . UserRead ;
33+ const UnixFileMode executableFileMode = UnixFileMode . OtherExecute |
34+ UnixFileMode . OtherRead |
35+ UnixFileMode . GroupExecute |
36+ UnixFileMode . GroupRead |
37+ UnixFileMode . UserExecute |
38+ UnixFileMode . UserWrite |
39+ UnixFileMode . UserRead ;
40+ private static readonly ( string file , UnixFileMode mode ) [ ] simplePkgFiles =
3041 [
31- "Bom" ,
32- "PackageInfo" ,
33- Path . Combine ( "Payload" , "Sample.txt" )
42+ ( "Bom" , nonExecutableFileMode ) ,
43+ ( "PackageInfo" , nonExecutableFileMode ) ,
44+ ( Path . Combine ( "Payload" , "Sample.txt" ) , nonExecutableFileMode ) ,
3445 ] ;
3546
36- private static readonly string [ ] withAppPkgFiles =
47+ private static readonly ( string file , UnixFileMode mode ) [ ] withAppPkgFiles =
3748 [
38- "Bom" ,
39- "PackageInfo" ,
40- Path . Combine ( "Payload" , "test.app" )
49+ ( "Bom" , nonExecutableFileMode ) ,
50+ ( "PackageInfo" , nonExecutableFileMode ) ,
51+ ( Path . Combine ( "Payload" , "test.app" ) , nonExecutableFileMode ) ,
4152 ] ;
4253
43- private static readonly string [ ] appFiles =
54+ private static readonly ( string file , UnixFileMode mode ) [ ] appFiles =
4455 [
45- Path . Combine ( "Contents" , "Info.plist" ) ,
46- Path . Combine ( "Contents" , "MacOS" , "main" ) ,
47- Path . Combine ( "Contents" , "Resources" , "libexample.dylib" )
56+ ( Path . Combine ( "Contents" , "Info.plist" ) , nonExecutableFileMode ) ,
57+ ( Path . Combine ( "Contents" , "MacOS" , "main" ) , executableFileMode ) ,
58+ ( Path . Combine ( "Contents" , "Resources" , "libexample.dylib" ) , executableFileMode )
4859 ] ;
4960
50- private static readonly string [ ] simpleInstallerFiles =
61+ private static readonly ( string file , UnixFileMode mode ) [ ] simpleInstallerFiles =
5162 [
52- "Distribution" ,
53- "Simple.pkg"
63+ ( "Distribution" , nonExecutableFileMode ) ,
64+ ( "Simple.pkg" , nonExecutableFileMode ) ,
5465 ] ;
5566
56- private static readonly string [ ] withAppInstallerFiles =
67+ private static readonly ( string file , UnixFileMode mode ) [ ] withAppInstallerFiles =
5768 [
58- "Distribution" ,
59- "WithApp.pkg"
69+ ( "Distribution" , nonExecutableFileMode ) ,
70+ ( "WithApp.pkg" , nonExecutableFileMode ) ,
6071 ] ;
6172
6273 public UnpackPackTests ( ITestOutputHelper output ) => this . output = output ;
@@ -177,7 +188,7 @@ private static void ExecuteWithCleanup(Action action, List<string> cleanupPaths)
177188 }
178189 }
179190
180- private void Unpack ( string srcPath , string dstPath , string [ ] expectedFiles )
191+ private void Unpack ( string srcPath , string dstPath , ( string , UnixFileMode ) [ ] expectedFiles )
181192 {
182193 RunPkgProcess ( srcPath , dstPath , "unpack" ) . Should ( ) . BeTrue ( ) ;
183194
@@ -186,7 +197,7 @@ private void Unpack(string srcPath, string dstPath, string[] expectedFiles)
186197 CompareContent ( dstPath , expectedFiles ) ;
187198 }
188199
189- private void Pack ( string srcPath , string dstPath , string [ ] expectedFiles )
200+ private void Pack ( string srcPath , string dstPath , ( string , UnixFileMode ) [ ] expectedFiles )
190201 {
191202 RunPkgProcess ( srcPath , dstPath , "pack" ) . Should ( ) . BeTrue ( ) ;
192203
@@ -231,10 +242,11 @@ private static string GetResourceFilePath(string resourceName)
231242
232243 private static string GetTempAppPath ( ) => $ "{ Path . GetTempFileName ( ) } .app";
233244
234- private static void CompareContent ( string basePath , string [ ] expectedFiles )
245+ #pragma warning disable CA1416
246+ private static void CompareContent ( string basePath , ( string file , UnixFileMode mode ) [ ] expectedFiles )
235247 {
236- string [ ] actualFiles = Directory . GetFiles ( basePath , "*.*" , SearchOption . AllDirectories )
237- . Select ( f => f . Substring ( basePath . Length + 1 ) )
248+ ( string , UnixFileMode ) [ ] actualFiles = Directory . GetFiles ( basePath , "*.*" , SearchOption . AllDirectories )
249+ . Select ( f => ( f . Substring ( basePath . Length + 1 ) , File . GetUnixFileMode ( f ) ) )
238250 . ToArray ( ) ;
239251 actualFiles . Should ( ) . BeEquivalentTo ( expectedFiles ) ;
240252 }
0 commit comments