Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Disables tests on Apple mobile platforms #95757

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,25 @@ public void UnseekableStreams_RoundTrip(TestTarFormat testFormat)

[Theory]
[MemberData(nameof(GetExactRootDirMatchCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88049", TestPlatforms.iOS | TestPlatforms.tvOS)]
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);
ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Throws_Internal(format, entryType, fileName, inverted: true);
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88049", TestPlatforms.iOS | TestPlatforms.tvOS)]
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work on simulator and maybe catalyst, but should fail on device. As far as I know, there's no way to shrink the app bundle path (where your app gets a tmp directory).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the TempDirectory class, it is possible to specify the full path:

public TempDirectory(string path)
{
    Path = path;
    Directory.CreateDirectory(path);
}

One concern regarding this is permissions and possibility to create a particular directory.

Copy link
Member Author

@kotlarmilos kotlarmilos Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS condition in the library test is evaluated as FALSE on Apple mobile targets. Without the macro condition and with shorter temporary directory using TempDirectory root = new TempDirectory("/Users/helix-runner/tmp"); the tests seem to work on Apple mobile targets.

#else
using TempDirectory root = new TempDirectory();

#endif
string entryFolderPath = Path.Join(root.Path, entryFolderName);
string destinationFolderPath = Path.Join(root.Path, destinationFolderName);

Expand All @@ -303,7 +306,6 @@ public void ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws()
[InlineData(TarEntryFormat.Ustar)]
[InlineData(TarEntryFormat.Pax)]
[InlineData(TarEntryFormat.Gnu)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88049", TestPlatforms.iOS | TestPlatforms.tvOS)]
public void ExtractToDirectory_ExactRootDirMatch_HardLinks_Throws(TarEntryFormat format)
{
ExtractToDirectory_ExactRootDirMatch_Links_Throws(format, TarEntryType.HardLink, inverted: false);
Expand Down Expand Up @@ -359,8 +361,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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir string is 68 chars long. In the tests where we use them, feel free to reduce the names of the files to even shorter lengths if needed (let's see if the CI does not complain). For example, instead of file.txt, you can just use f.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to shrink the path even more. One concern regarding this is permissions and possibility to create a particular directory.

#else
using TempDirectory root = new TempDirectory();

#endif
string entryFolderPath = Path.Join(root.Path, entryFolderName);
string destinationFolderPath = Path.Join(root.Path, destinationFolderName);

Expand Down Expand Up @@ -390,8 +397,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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have control over tempDir? Could it just be tmp, or t?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an arbitrary name and probably we can set even shorter name.

#else
using TempDirectory root = new TempDirectory();

#endif
string entryFolderPath = Path.Join(root.Path, entryFolderName);
string destinationFolderPath = Path.Join(root.Path, destinationFolderName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,25 @@ public async Task UnseekableStreams_RoundTrip_Async(TestTarFormat testFormat)

[Theory]
[MemberData(nameof(GetExactRootDirMatchCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88049", TestPlatforms.iOS | TestPlatforms.tvOS)]
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);
await ExtractToDirectory_ExactRootDirMatch_RegularFile_And_Directory_Throws_Internal_Async(format, entryType, fileName, inverted: true);
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88049", TestPlatforms.iOS | TestPlatforms.tvOS)]
public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws_Async()
{
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);

Expand All @@ -368,7 +371,6 @@ public async Task ExtractToDirectory_ExactRootDirMatch_Directory_Relative_Throws
[InlineData(TarEntryFormat.Ustar)]
[InlineData(TarEntryFormat.Pax)]
[InlineData(TarEntryFormat.Gnu)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88049", TestPlatforms.iOS | TestPlatforms.tvOS)]
public async Task ExtractToDirectory_ExactRootDirMatch_HardLinks_Throws_Async(TarEntryFormat format)
{
await ExtractToDirectory_ExactRootDirMatch_Links_Throws_Async(format, TarEntryType.HardLink, inverted: false);
Expand Down Expand Up @@ -424,8 +426,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);

Expand Down Expand Up @@ -455,8 +462,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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please store the string "/Users/helix-runner/Library/Developer/CoreSimulator/Devices/tempDir" in a field, to avoid repetition?

#else
using TempDirectory root = new TempDirectory();

#endif
string entryFolderPath = Path.Join(root.Path, entryFolderName);
string destinationFolderPath = Path.Join(root.Path, destinationFolderName);

Expand Down
Loading