From 64bde996ce8bd6224d0a3e63cbd6e96ad402a7e5 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 7 Dec 2023 19:21:20 +0100 Subject: [PATCH 1/6] [tests] Use shorter path for temp directory on Apple mobile platforms --- ...TarFile.ExtractToDirectory.Stream.Tests.cs | 21 ++++++++++++++++--- ...le.ExtractToDirectoryAsync.Stream.Tests.cs | 21 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs index 3cec81f62a501f..ee6fa888b1a721 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs @@ -219,8 +219,13 @@ public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws() string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + // the folder used to store files needs to have a shorter path on Apple mobile platforms, + // because the TempDirectory gets created in folder with a path longer than 100 bytes + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); +#else using TempDirectory root = new TempDirectory(); - +#endif string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -295,8 +300,13 @@ private void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Thro string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + // the folder used to store files needs to have a shorter path on Apple mobile platforms, + // because the TempDirectory gets created in folder with a path longer than 100 bytes + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); +#else using TempDirectory root = new TempDirectory(); - +#endif string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -326,8 +336,13 @@ private void ExtractToDirectory_ExactRootDirMatch_Links_Throws(TarEntryFormat fo string linkTargetFileName = "file.txt"; string linkFileName = "link"; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + // the folder used to store files needs to have a shorter path on Apple mobile platforms, + // because the TempDirectory gets created in folder with a path longer than 100 bytes + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); +#else using TempDirectory root = new TempDirectory(); - +#endif string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs index a765f4f911eb77..237ac60a5e1f51 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs @@ -284,8 +284,13 @@ public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + // the folder used to store files needs to have a shorter path on Apple mobile platforms, + // because the TempDirectory gets created in folder with a path longer than 100 bytes + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); +#else using TempDirectory root = new TempDirectory(); - +#endif string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -360,8 +365,13 @@ private async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Director string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + // the folder used to store files needs to have a shorter path on Apple mobile platforms, + // because the TempDirectory gets created in folder with a path longer than 100 bytes + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); +#else using TempDirectory root = new TempDirectory(); - +#endif string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -391,8 +401,13 @@ private Task ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(TarEntryFor string linkTargetFileName = "file.txt"; string linkFileName = "link"; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + // the folder used to store files needs to have a shorter path on Apple mobile platforms, + // because the TempDirectory gets created in folder with a path longer than 100 bytes + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); +#else using TempDirectory root = new TempDirectory(); - +#endif string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); From cb1fc0d716b11af412d0daed13e2c3d49a1a3944 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 8 Dec 2023 12:26:08 +0100 Subject: [PATCH 2/6] [tests] Test shorter temporary directory path --- .../TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs | 6 +++--- .../TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs index ee6fa888b1a721..a1554ccdfe7f36 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs @@ -222,7 +222,7 @@ public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws() #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -303,7 +303,7 @@ private void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Thro #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -339,7 +339,7 @@ private void ExtractToDirectory_ExactRootDirMatch_Links_Throws(TarEntryFormat fo #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); #else using TempDirectory root = new TempDirectory(); #endif diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs index 237ac60a5e1f51..085808a3bd556a 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs @@ -287,7 +287,7 @@ public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -368,7 +368,7 @@ private async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Director #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -404,7 +404,7 @@ private Task ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(TarEntryFor #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); #else using TempDirectory root = new TempDirectory(); #endif From 3ed4185115a5c308c9baa605039cdb0772e807c4 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 8 Dec 2023 14:39:15 +0100 Subject: [PATCH 3/6] [tests] Test shorter temporary directory path --- .../TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs | 6 +++--- .../TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs index a1554ccdfe7f36..35ab28d4778789 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs @@ -222,7 +222,7 @@ public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws() #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -303,7 +303,7 @@ private void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Thro #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -339,7 +339,7 @@ private void ExtractToDirectory_ExactRootDirMatch_Links_Throws(TarEntryFormat fo #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); #else using TempDirectory root = new TempDirectory(); #endif diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs index 085808a3bd556a..08cf245d0c20ee 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs @@ -287,7 +287,7 @@ public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -368,7 +368,7 @@ private async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Director #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); #else using TempDirectory root = new TempDirectory(); #endif @@ -404,7 +404,7 @@ private Task ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(TarEntryFor #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/Library/Developer/tmp"); + using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); #else using TempDirectory root = new TempDirectory(); #endif From d926db8f98929a31a52d78fd94975ab2ebe9ba78 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 8 Dec 2023 17:15:09 +0100 Subject: [PATCH 4/6] [tests] Test macros condition for temp directory --- .../TarFile.ExtractToDirectory.Stream.Tests.cs | 15 +++------------ ...arFile.ExtractToDirectoryAsync.Stream.Tests.cs | 15 +++------------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs index 35ab28d4778789..a82600dd694327 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs @@ -219,13 +219,10 @@ public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws() string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); -#else - using TempDirectory root = new TempDirectory(); -#endif + string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -300,13 +297,10 @@ private void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Thro string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); -#else - using TempDirectory root = new TempDirectory(); -#endif + string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -336,13 +330,10 @@ private void ExtractToDirectory_ExactRootDirMatch_Links_Throws(TarEntryFormat fo string linkTargetFileName = "file.txt"; string linkFileName = "link"; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); -#else - using TempDirectory root = new TempDirectory(); -#endif + string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs index 08cf245d0c20ee..e53ab932a61803 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs @@ -284,13 +284,10 @@ public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); -#else - using TempDirectory root = new TempDirectory(); -#endif + string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -365,13 +362,10 @@ private async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Director string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); -#else - using TempDirectory root = new TempDirectory(); -#endif + string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -401,13 +395,10 @@ private Task ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(TarEntryFor string linkTargetFileName = "file.txt"; string linkFileName = "link"; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // the folder used to store files needs to have a shorter path on Apple mobile platforms, // because the TempDirectory gets created in folder with a path longer than 100 bytes using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); -#else - using TempDirectory root = new TempDirectory(); -#endif + string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); From ed50c89d7f676efe8dcff97b731849e274d0450f Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 11 Dec 2023 12:18:43 +0100 Subject: [PATCH 5/6] [tests] Disable tests on Apple mobile platforms --- .../TarFile.ExtractToDirectory.Stream.Tests.cs | 18 ++++++------------ ...ile.ExtractToDirectoryAsync.Stream.Tests.cs | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs index a82600dd694327..78d07a76f5246b 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs @@ -207,6 +207,7 @@ public void PaxNameCollision_DedupInExtendedAttributes() [Theory] [MemberData(nameof(GetExactRootDirMatchCases))] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "The temporary directory on Apple mobile platforms exceeds the path length limit.")] public void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Throws(TarEntryFormat format, TarEntryType entryType, string fileName) { ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Throws_Internal(format, entryType, fileName, inverted: false); @@ -214,14 +215,12 @@ public void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Throw } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "The temporary directory on Apple mobile platforms exceeds the path length limit.")] public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws() { string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; - - // the folder used to store files needs to have a shorter path on Apple mobile platforms, - // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -242,6 +241,7 @@ public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws() [InlineData(TarEntryFormat.Ustar)] [InlineData(TarEntryFormat.Pax)] [InlineData(TarEntryFormat.Gnu)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "The temporary directory on Apple mobile platforms exceeds the path length limit.")] public void ExtractToDirectory_ExactRootDirMatch_HardLinks_Throws(TarEntryFormat format) { ExtractToDirectory_ExactRootDirMatch_Links_Throws(format, TarEntryType.HardLink, inverted: false); @@ -296,10 +296,7 @@ private void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Thro string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; - - // the folder used to store files needs to have a shorter path on Apple mobile platforms, - // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -329,10 +326,7 @@ private void ExtractToDirectory_ExactRootDirMatch_Links_Throws(TarEntryFormat fo string linkTargetFileName = "file.txt"; string linkFileName = "link"; - - // the folder used to store files needs to have a shorter path on Apple mobile platforms, - // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs index e53ab932a61803..540267399105c6 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs @@ -272,6 +272,7 @@ public async Task PaxNameCollision_DedupInExtendedAttributesAsync() [Theory] [MemberData(nameof(GetExactRootDirMatchCases))] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "The temporary directory on Apple mobile platforms exceeds the path length limit.")] public async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Throws_Async(TarEntryFormat format, TarEntryType entryType, string fileName) { await ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Throws_Internal_Async(format, entryType, fileName, inverted: false); @@ -279,14 +280,12 @@ public async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "The temporary directory on Apple mobile platforms exceeds the path length limit.")] public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws_Async() { string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; - - // the folder used to store files needs to have a shorter path on Apple mobile platforms, - // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -307,6 +306,7 @@ public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws [InlineData(TarEntryFormat.Ustar)] [InlineData(TarEntryFormat.Pax)] [InlineData(TarEntryFormat.Gnu)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "The temporary directory on Apple mobile platforms exceeds the path length limit.")] public async Task ExtractToDirectory_ExactRootDirMatch_HardLinks_Throws_Async(TarEntryFormat format) { await ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(format, TarEntryType.HardLink, inverted: false); @@ -361,10 +361,7 @@ private async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Director string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; - - // the folder used to store files needs to have a shorter path on Apple mobile platforms, - // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); @@ -394,10 +391,7 @@ private Task ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(TarEntryFor string linkTargetFileName = "file.txt"; string linkFileName = "link"; - - // the folder used to store files needs to have a shorter path on Apple mobile platforms, - // because the TempDirectory gets created in folder with a path longer than 100 bytes - using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); string destinationFolderPath = Path.Join(root.Path, destinationFolderName); From d12f7b88315a936fe7e46aa2aaffe0bf129171e6 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 11 Dec 2023 12:23:13 +0100 Subject: [PATCH 6/6] [tests] Fix lint --- .../tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs | 3 +++ .../TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs index 78d07a76f5246b..3c33adeb028cbe 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs @@ -220,6 +220,7 @@ public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws() { string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); @@ -296,6 +297,7 @@ private void ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Thro string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); @@ -326,6 +328,7 @@ private void ExtractToDirectory_ExactRootDirMatch_Links_Throws(TarEntryFormat fo string linkTargetFileName = "file.txt"; string linkFileName = "link"; + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs index 540267399105c6..2ec99926dcc182 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectoryAsync.Stream.Tests.cs @@ -285,6 +285,7 @@ public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws { string entryFolderName = "folder"; string destinationFolderName = "folderSibling"; + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); @@ -361,6 +362,7 @@ private async Task ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Director string entryFolderName = inverted ? "folderSibling" : "folder"; string destinationFolderName = inverted ? "folder" : "folderSibling"; + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName); @@ -391,6 +393,7 @@ private Task ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(TarEntryFor string linkTargetFileName = "file.txt"; string linkFileName = "link"; + using TempDirectory root = new TempDirectory(); string entryFolderPath = Path.Join(root.Path, entryFolderName);