Skip to content

Conversation

@xta0
Copy link
Contributor

@xta0 xta0 commented Nov 16, 2019

Stack from ghstack:

Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors. Starting from this PR, we'll add some unit tests to the iOS Simulator build. As follows:

  1. Add an unit test target to XCode (this PR)
  2. Use Fastlane to run the tests on CI
  3. Modify the CI scripts to trigger tests

Test Plan

  • Don't break the existing CI jobs unless they are flaky.

Differential Revision: D18582908

xta0 added a commit that referenced this pull request Nov 16, 2019
ghstack-source-id: b7f04c4
Pull Request resolved: #29962
@xta0 xta0 requested review from ljk53 and shoumikhin November 16, 2019 06:36
@xta0 xta0 changed the title [iOS] add unit test for Simulator build [iOS] add an unit test target to XCode Nov 16, 2019
@xta0 xta0 changed the title [iOS] add an unit test target to XCode [iOS] add an unit test target to TestApp Nov 18, 2019
@xta0 xta0 added the module: ios Related to iOS support - build, API, Continuous Integration, document label Nov 18, 2019
Copy link
Contributor

@shoumikhin shoumikhin left a comment

Choose a reason for hiding this comment

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

Did we run clang-format on it?

}
torch::autograd::AutoGradMode guard(false);
_module = torch::jit::load(std::string(modelPath.UTF8String));
_module.eval();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe better to have it in each test, since some tests may actually want to change module's parameters in future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what parameters could be changed?

@@ -0,0 +1,38 @@
#import <XCTest/XCTest.h>
#import <torch/script.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: #include C++ headers?
Also, may like an LF between the two, since they belong to different types of headers

[super setUp];
NSString* modelPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"model"
ofType:@"pt"];
XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:modelPath],
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: dot-syntax for the class property?

at::globalContext().setQEngine(at::QEngine::QNNPACK);
}
torch::autograd::AutoGradMode guard(false);
_module = torch::jit::load(std::string(modelPath.UTF8String));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: probably no need to convert char* to std::string explicitly?

### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors. Starting from this PR, we'll add some unit tests to the iOS Simulator build. As follows:

1. Add an unit test target to XCode (this PR)
2. Use Fastlane to run the tests on CI
3. Modify the CI scripts to trigger tests

### Test Plan

- Don't break the existing CI jobs unless they are flaky.
@xta0
Copy link
Contributor Author

xta0 commented Nov 18, 2019

Did we run clang-format on it?

I did.

Copy link
Contributor

@shoumikhin shoumikhin left a comment

Choose a reason for hiding this comment

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

Awesome!

@facebook-github-bot
Copy link
Contributor

@xta0 merged this pull request in 57acc2f.

xta0 added a commit that referenced this pull request Nov 22, 2019
### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors. 

### Previous work

- Add an unit test target to the iOS TestApp ( #29962 )
- Update Fastlane to run tests ( #29963 )

### What's been changed in CI

1. XCode version has been updated to 11.2.1 
2. For iOS simulator build, we'll run some unit tests( currently only one) after the build test.

Differential Revision: [D18641413](https://our.internmc.facebook.com/intern/diff/D18641413)
xta0 added a commit that referenced this pull request Nov 22, 2019
### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors. 

### Previous work

- Add an unit test target to the iOS TestApp ( #29962 )
- Update Fastlane to run tests ( #29963 )

### What's been changed in CI

1. XCode version has been updated to 11.2.1 
2. For iOS simulator build, we'll run some unit tests( currently only one) after the build test.

Differential Revision: [D18641413](https://our.internmc.facebook.com/intern/diff/D18641413)
xta0 added a commit that referenced this pull request Nov 22, 2019
### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors. 

### Previous work

- Add an unit test target to the iOS TestApp ( #29962 )
- Update Fastlane to run tests ( #29963 )

### What's been changed in CI

1. XCode version has been updated to 11.2.1 
2. For iOS simulator build, we'll run some unit tests( currently only one) after the build test.

Differential Revision: [D18641413](https://our.internmc.facebook.com/intern/diff/D18641413)
xta0 added a commit that referenced this pull request Nov 22, 2019
### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors. 

### Previous work

- Add an unit test target to the iOS TestApp ( #29962 )
- Update Fastlane to run tests ( #29963 )

### What's been changed in CI

1. XCode version has been updated to 11.2.1 
2. For iOS simulator build, we'll run some unit tests( currently only one) after the build test.

Differential Revision: [D18641413](https://our.internmc.facebook.com/intern/diff/D18641413)
facebook-github-bot pushed a commit that referenced this pull request Nov 22, 2019
Summary:
Pull Request resolved: #30133

### Summary

Recently we've found that the master branch was constantly broken due to some unwanted change being landed on mobile. The problem is that our CI was not able to detect the runtime errors.

### Previous work

- Add an unit test target to the iOS TestApp ( #29962 )
- Update Fastlane to run tests ( #29963 )

### What's been changed in CI

1. XCode version has been updated to 11.2.1
2. For iOS simulator build, we'll run some unit tests( currently only one) after the build test.

Test Plan: Imported from OSS

Differential Revision: D18641413

Pulled By: xta0

fbshipit-source-id: 12942206f1dee045b2addba3ae618760e992752c
@facebook-github-bot facebook-github-bot deleted the gh/xta0/41/head branch November 23, 2019 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: ios Related to iOS support - build, API, Continuous Integration, document

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants