-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various fixes for merged test runners on Mono (#67665)
- Loading branch information
1 parent
c61cb71
commit c160754
Showing
21 changed files
with
260 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/tasks/TestExclusionListTasks/PatchExclusionListInApks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
namespace TestExclusionListTasks; | ||
|
||
public class PatchExclusionListInApks : Task | ||
{ | ||
[Required] | ||
public ITaskItem[]? ApkPaths { get; set; } | ||
|
||
[Required] | ||
public ITaskItem[]? ExcludedTests { get; set; } | ||
|
||
public string? AndroidSdk { get; set; } | ||
|
||
public string? MinApiLevel { get; set; } | ||
|
||
public string? BuildToolsVersion { get; set; } | ||
|
||
public string? KeyStorePath { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
var apkBuilder = new ApkBuilder(Log); | ||
apkBuilder.AndroidSdk = AndroidSdk; | ||
apkBuilder.MinApiLevel = MinApiLevel; | ||
apkBuilder.BuildToolsVersion = BuildToolsVersion; | ||
apkBuilder.KeyStorePath = KeyStorePath; | ||
|
||
string testExclusionList = string.Join( | ||
'\n', | ||
(ExcludedTests ?? Enumerable.Empty<ITaskItem>()).Select(t => t.ItemSpec)); | ||
foreach (ITaskItem apk in ApkPaths ?? Enumerable.Empty<ITaskItem>()) | ||
{ | ||
string apkPath = apk.GetMetadata("FullPath")!; | ||
apkBuilder.OutputDir = Path.GetDirectoryName(apkPath)!; | ||
using (ZipArchive apkArchive = ZipFile.Open(apkPath, ZipArchiveMode.Update)) | ||
{ | ||
ZipArchiveEntry assetsZipEntry = apkArchive.GetEntry("assets/assets.zip")!; | ||
using ZipArchive assetsArchive = new ZipArchive(assetsZipEntry.Open(), ZipArchiveMode.Update); | ||
ZipArchiveEntry testExclusionListEntry = assetsArchive.GetEntry("TestExclusionList.txt")!; | ||
using StreamWriter textExclusionListWriter = new StreamWriter(testExclusionListEntry.Open()); | ||
textExclusionListWriter.WriteLine(testExclusionList); | ||
} | ||
apkBuilder.ZipAndSignApk(apkPath); | ||
} | ||
return true; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/tasks/TestExclusionListTasks/TestExclusionListTasks.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>$(TargetFrameworkForNETCoreTasks)</TargetFramework> | ||
<OutputType>Library</OutputType> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> | ||
<Nullable>enable</Nullable> | ||
<NoWarn>$(NoWarn),CA1050</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="PatchExclusionListInApks.cs" /> | ||
<Compile Include="../AndroidAppBuilder/ApkBuilder.cs" /> | ||
<Compile Include="../Common/Utils.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.