Skip to content

1.x: Run tests on Android! #3519

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

Conversation

artem-zinnatullin
Copy link
Contributor

Closes #3503.

In short:

  • Created rxjava gradle module and moved src to rxjava/src.
  • Created android-tests module and configured it to run tests from rxjava/src/test on Android.
  • Tuned build scripts so we can run builds on Android/JDK concurrently.
  • Changed MemoryMXBean to Runtime in ExecutorSchedulerTest because MemoryMXBean is not presented on Android.

TODO:

@JakeWharton PTAL

classpath 'com.android.tools.build:gradle:1.3.1'

// Resolves android-sdk dependencies
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed. .travis.yml takes care of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's for developers, I guess @akarnokd used it without noticing :)

On Fri, Nov 13, 2015, 07:47 Jake Wharton [email protected] wrote:

In android-tests/build.gradle
#3519 (comment):

@@ -0,0 +1,61 @@
+buildscript {

  • repositories {
  •    jcenter()
    
  • }
  • dependencies {
  •    // Android Gradle plugin
    
  •    classpath 'com.android.tools.build:gradle:1.3.1'
    
  •    // Resolves android-sdk dependencies
    
  •    classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
    

Not needed. .travis.yml takes care of this.


Reply to this email directly or view it on GitHub
https://github.com/ReactiveX/RxJava/pull/3519/files#r44749555.

@artem_zin

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm amazed it even still works.

On Thu, Nov 12, 2015 at 11:51 PM Artem Zinnatullin [email protected]
wrote:

In android-tests/build.gradle
#3519 (comment):

@@ -0,0 +1,61 @@
+buildscript {

  • repositories {
  •    jcenter()
    
  • }
  • dependencies {
  •    // Android Gradle plugin
    
  •    classpath 'com.android.tools.build:gradle:1.3.1'
    
  •    // Resolves android-sdk dependencies
    
  •    classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
    

It's for developers, I guess @akarnokd https://github.com/akarnokd used
it without noticing :)
On Fri, Nov 13, 2015, 07:47 Jake Wharton [email protected]
wrote: In android-tests/build.gradle <#3519 (comment)
https://github.com/ReactiveX/RxJava/pull/3519#discussion_r44749555>: >
@@ -0,0 +1,61 @@ > +buildscript { > + repositories { > + jcenter() > + } >


Reply to this email directly or view it on GitHub
https://github.com/ReactiveX/RxJava/pull/3519/files#r44749702.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, would be nice to see new releases! Sometimes it can not handle
support libraries updates. But anyway, great tool.

On Fri, Nov 13, 2015, 07:52 Jake Wharton [email protected] wrote:

In android-tests/build.gradle
#3519 (comment):

@@ -0,0 +1,61 @@
+buildscript {

  • repositories {
  •    jcenter()
    
  • }
  • dependencies {
  •    // Android Gradle plugin
    
  •    classpath 'com.android.tools.build:gradle:1.3.1'
    
  •    // Resolves android-sdk dependencies
    
  •    classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
    

I'm amazed it even still works.
… <#msg-f:1517698800156585010_>
On Thu, Nov 12, 2015 at 11:51 PM Artem Zinnatullin <
[email protected]> wrote: In android-tests/build.gradle <#3519
(comment)
https://github.com/ReactiveX/RxJava/pull/3519#discussion_r44749702>: >
@@ -0,0 +1,61 @@ > +buildscript { > + repositories { > + jcenter() > + } >


Reply to this email directly or view it on GitHub
https://github.com/ReactiveX/RxJava/pull/3519/files#r44749727.

@artem_zin

@akarnokd
Copy link
Member

Can we do this without moving any files?

@artem-zinnatullin
Copy link
Contributor Author

Can we do this without moving any files?

Not sure, unfortunately. src is default source root it will probably be bound to the root Gradle project and I'm not sure that I'll be able to detach it from root project.

Though I'll try it today, if somebody already done this — please comment.

@artem-zinnatullin artem-zinnatullin force-pushed the run-tests-on-android branch 2 times, most recently from 93e9322 to f7a1c58 Compare November 15, 2015 01:54
@artem-zinnatullin
Copy link
Contributor Author

@akarnokd done!

subject.subscribe();
subject.materialize().toBlocking().first();

Thread.sleep(1000); // the uncaught exception comes after the terminal event reaches toBlocking
Copy link
Member

Choose a reason for hiding this comment

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

This fails for some reason. Maybe the underlying thread dies off?
Could you change the code above to use a ThreadFactory with newSingleThreadExecutor and set the uncaught exception handler within the factory?

@akarnokd
Copy link
Member

Generally, I'm not against testing on Android but I'm afraid it will hinder progress on RxJava due to platform nuances. I remember when RxJava had every other Rx language and tool under the same main project and a change for Java caused build failures because something didn't compile in RxScala or some test failed in RxClojure. Would it be possible to have this as a separate project where Gradle/travis checks out the RxJava code from github and runs the tests on the emulator?

@artem-zinnatullin
Copy link
Contributor Author

Android is just another Runtime, see it as different JVM (though it's not J-VM, but it does not matter in this case). Scala, Clojure, etc run on the JVM too, so your example is not directly applicable to the intention of running tests on Android. Your example is more about RxAndroid and I agree that it should be separate project and it is in .

Thousands of Android apps use RxJava, millions of Android devices run RxJava code every minute. And RxJava has some Platform-dependent code. Would be great to check that it works as expected 😄

Would it be possible to have this as a separate project where Gradle/travis checks out the RxJava code from github and runs the tests on the emulator?

It's possible, but it will be very hard since it requires changes of the tests (timeouts, etc). Also, it won't give immediate feedback to PRs in the RxJava.

I'm sorry for the delay with this PR, I'm very busy this week, will try to finish it soon.

@avram
Copy link
Contributor

avram commented Feb 3, 2016

It's possible, but it will be very hard since it requires changes of the tests (timeouts, etc). Also, it won't give immediate feedback to PRs in the RxJava.

With appropriate privileging, a secondary RxJava test runner outside of this repo could still post status checks to PRs -- it probably couldn't easily use Travis, but a custom runner on Jenkins would have enough flexibility to do that. Concerns about changes to tests would still remain.

@artem-zinnatullin
Copy link
Contributor Author

I'd still prefer to run tests on Android as part of current RxJava CI, actually there're just few tests fail with timeouts because Android emulator is slow as hell, we can write custom test runner or JUnit rule and add AndroidTimeout annotation to fix that and not touch regular tests runs.

Please feel free (anyone) to work on this, hopefully I'll do it at some point, but I don't have much time right now.

@akarnokd akarnokd changed the title Run tests on Android! 1.x: Run tests on Android! Feb 9, 2016
@akarnokd
Copy link
Member

I'm still not in favor of running the tests for Android in the same CI process.

The alternative I see is to somehow package up the unit tests as well and have a separate project run it it, or if a gradle script could be written to checkout the RxJava sources and run the tests in that way.

@artem-zinnatullin
Copy link
Contributor Author

Let's close it for now, I have a task to run RxJava tests on Android as part of CI of RxJavaProGuardRules project.

Hope I'll find some time to work on it in the summer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants