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

[mono] iOS Test runner #34976

Merged
merged 15 commits into from
Apr 17, 2020
Merged

[mono] iOS Test runner #34976

merged 15 commits into from
Apr 17, 2020

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Apr 14, 2020

It's currently WIP, it doesn't use runtime packs yet but it's already possible to run any test suite (well, any without remote-executor based tests inside, see dotnet/arcade#5129 such tests usually have <IncludeRemoteExecutor>true</IncludeRemoteExecutor> inside csprojs). It uses dotnet/xharness test runner, copies everything including the whole BCL into a test folder and runs the AOT/Bundle generation.

Steps to run a test suite:

# make sure everything is built for iOS (can be arm64 instead of x64 for devices and fullAOT)
./build.sh -c Release -os iOS -arch x64 -subset Mono+Libs+Libs.Tests /p:DisableCrossgen=true

# TestName can be any test suite, e.g. System.Collections.Tests
./dotnet.sh msbuild src/mono/mono.proj /t:BuildAppleTestBundle \
/p:Configuration=Release /p:TestName=System.Buffers.Tests \
/p:TargetOS=iOS /p:TargetArchitecture=x64

for x64 it should build everything and launch an iphone simulator with tests. For arm64 devices it needs xharness tool (with mlaunch inside - it's not yet there) and a provisioning profile.
If you want to try arm64 now you can run the script above ^ (replace x64 with arm64) and open the xcode project (generated) and deploy to a personal device with auto-generated provisioning. Some tests might crash on arm64, e.g.:

Assertion at /Users/egorbo/prj/runtime-3/src/mono/mono/metadata/class.c:1845, 
condition `method->is_inflated' not met

or some missing *aotdata stuff. Arm64 needs some work.

image

I guess the expected workflow is the following:

cd src/libraries/System.Buffers/tests
dotnet publish -c Release -r ios-x64
dotnet tool xharness test ios --app path/to/app/bunndle.app

@EgorBo
Copy link
Member Author

EgorBo commented Apr 14, 2020

@dotnet dotnet deleted a comment Apr 14, 2020
@dotnet dotnet deleted a comment Apr 14, 2020
@safern
Copy link
Member

safern commented Apr 14, 2020

Adding my 2 cents here. I think we should unify this with our current testing infrastructure/targets to run libraries tests instead of diverging paths by having some stuff under mono and some other under libraries.

We could use a lot of what we have by adding some targets/commands to execute the app bundler and invoking the tests and what not.

@steveisok
Copy link
Member

@safern At the very least, I would expect this PR to drive towards that.

@safern
Copy link
Member

safern commented Apr 15, 2020

@safern At the very least, I would expect this PR to drive towards that.

Yes, I think it should as a first step.

@marek-safar
Copy link
Contributor

I think we should unify this with our current testing infrastructure/targets to run libraries tests instead of diverging paths by having some stuff under mono and some other under libraries.

@safern what would you like to be moved and to where? For now, only very specific libraries configurations are supported but the same infrastructure will be used for all other tests in dotnet/runtime so not sure if it makes sense to move it libraries as it's not libraries specific.

src/mono/msbuild/AppleAppBuilder/Xcode.cs Show resolved Hide resolved
<Error Condition="!Exists('$(TestDir)')" Text="TestDir=$(TestDir) doesn't exist" />
<Error Condition="!Exists('$(BclDir)')" Text="BclDir=$(BclDir) doesn't exist" />

<Copy SourceFiles="@(AppleTestRunnerBinaries)" DestinationFolder="$(TestDir)\%(RecursiveDir)" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should be done here

src/mono/msbuild/AppleTestRunner/AppleTestRunner.csproj Outdated Show resolved Hide resolved
src/mono/msbuild/AppleTestRunner/AppleTestRunner.cs Outdated Show resolved Hide resolved
@safern
Copy link
Member

safern commented Apr 15, 2020

@safern what would you like to be moved and to where? For now, only very specific libraries configurations are supported but the same infrastructure will be used for all other tests in dotnet/runtime so not sure if it makes sense to move it libraries as it's not libraries specific

I’d like to have this hooked up under /eng/testing and have the targets and all underlying logic there. Even though it will not be used by all configurations what we’re running are libraries tests. I don’t like all this manual copying of files and duplicating path calculation and all things involved here. We could hook it up in the infra we already have to run tests and everything would be much simpler. Instead of having to run specific mono targets I envision this as dotnet build /t:test /p:TargetOS=iOS /p:TargetArchitecture=x64 on a test project and the test project will be executed on the simulator.

Or build libs.tests -test -os iOS -arch x64 and all the tests will be executed on the simulator. I want to be consistent on how we run tests for all configurations this makes dev experience easier rather than having to remember different commands and what project to call etc.

I think this is fine as is for the purpose of this PR, but we should eventually hook it up as o suggest above. I can definitely help with that, I started taking a look at how all this works yesterday and I think it is possible.

@marek-safar
Copy link
Contributor

@steveisok could you ensure @safern concerns are addressed

@safern
Copy link
Member

safern commented Apr 15, 2020

cc: @ViktorHofer @danmosemsft

@steveisok
Copy link
Member

steveisok commented Apr 15, 2020

@safern After talking w/ Egor & Alex, I'd like to land this PR so that we have a runner to use. Then in a separate PR, we can hook into what you outlined. We have additional ongoing work that I'd like to come together as well (in-tree runtime pack, AOT targets, etc).

@safern
Copy link
Member

safern commented Apr 15, 2020

@safern After talking w/ Egor & Alex, I'd like to land this PR so that we have a runner to use. Then in a separate PR, we can hook into what you outlined.

Yeah I don't want to block this PR. I just wanted to raise my concerns as a heads up that we should envision hooking it up the same way we already run libraries tests and of course happy to help with doing that.

src/mono/mono.proj Outdated Show resolved Hide resolved
}
}

public class SimpleTestRunner : iOSApplicatonEntryPoint, IDevice
Copy link
Member

Choose a reason for hiding this comment

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

iOSApplicatonEntryPoint -- is this a typo? iOSApplicationEntryPoint

Copy link
Member

Choose a reason for hiding this comment

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

ah, it's in dotnet/xharness. I didn't know about this repo 😸

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

also, while you are there could you please add events for "test is started", "test is finished (with result)" ?

Copy link
Member

Choose a reason for hiding this comment

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

@danmosemsft I'm known for my typos, I'll get that fixed! @EgorBo dotnet/xharness#36

@@ -34,7 +34,7 @@ public class AppleAppBuilderTask : Task
/// Path to Mono public headers (*.h)
/// </summary>
[Required]
public string MonoInclude { get; set; } = ""!;
public string MonoRuntimeHeaders { get; set; } = ""!;
Copy link
Member

Choose a reason for hiding this comment

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

What does ""! achieve here? Is this the "null-forgiving" operator?

Copy link
Member Author

Choose a reason for hiding this comment

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

These properties are guaranteed to be non-null always (due to [Required] attribute) the compiler forces me to do inline init to leave them non-nullable. I wonder how @stephentoub solves such cases.

CGRect caretRect = [logLabel caretRectForPosition:logLabel.endOfDocument];
[logLabel scrollRectToVisible:caretRect animated:NO];
[logLabel setScrollEnabled:NO];
[logLabel setScrollEnabled:YES];
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Some hack to automatically scroll to the bottom in UITextView

Copy link
Member

Choose a reason for hiding this comment

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

why do you need to toggle setScrollEnabled? is the scrollRectToVisible not enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

@akoeplinger I don't know but without it doesn't work properly, I tried different hacks from SO this one works as expected (https://stackoverflow.com/questions/19124037/scroll-to-bottom-of-uitextview-erratic-in-ios-7/20989956#20989956)

@@ -62,7 +62,7 @@ public static async Task<int> Main(string[] args)

protected override IEnumerable<TestAssemblyInfo> GetTestAssemblies()
{
foreach (string file in testLibs)
foreach (string file in testLibs!)
Copy link
Member

Choose a reason for hiding this comment

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

Why is the null forgiving operator needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@safern I forgot to remove it

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix it in the next PR

@EgorBo EgorBo changed the title [WIP] iOS Test runner [mono] iOS Test runner Apr 17, 2020
@akoeplinger
Copy link
Member

runtime (Installer Build and Test Linux_x64 Debug) passed on AzDO, the status didn't make it to GitHub: https://dev.azure.com/dnceng/public/_build/results?buildId=603747&view=logs&j=0d59b9e3-002e-58b9-0bdb-d3cd1e08882b&t=90f7f7ef-163c-557b-3338-db1b69e0bef4&l=21

@EgorBo EgorBo merged commit 3468524 into dotnet:master Apr 17, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants