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

2.x: Test cleanup #6119

Merged
merged 5 commits into from
Aug 1, 2018
Merged

2.x: Test cleanup #6119

merged 5 commits into from
Aug 1, 2018

Conversation

akarnokd
Copy link
Member

This PR cleans up the tests:

  • Reduce stacktrace printouts due to undeliverable errors and turn them into assertions instead.
  • Rename local variables & arguments of Subscribers from o and observer to the proper subscriber
  • Rename local variables & arguments of Flowables from o and observable to the more appropriate f and flowable
  • Add more naming tests to CheckLocalVariablesInTests to support the previous two points.

@akarnokd akarnokd added this to the 2.2 backlog milestone Jul 31, 2018
@codecov
Copy link

codecov bot commented Jul 31, 2018

Codecov Report

Merging #6119 into 2.x will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6119      +/-   ##
============================================
- Coverage     98.25%   98.25%   -0.01%     
- Complexity     6191     6194       +3     
============================================
  Files           667      667              
  Lines         44861    44861              
  Branches       6213     6213              
============================================
- Hits          44080    44078       -2     
- Misses          237      239       +2     
  Partials        544      544
Impacted Files Coverage Δ Complexity Δ
...rators/single/SingleFlatMapIterableObservable.java 100% <100%> (ø) 2 <1> (ø) ⬇️
...reactivex/internal/operators/single/SingleAmb.java 100% <100%> (+3.63%) 10 <0> (+1) ⬆️
...l/operators/observable/ObservableFromCallable.java 100% <100%> (ø) 5 <3> (ø) ⬇️
...x/internal/operators/observable/ObservableAmb.java 98.94% <100%> (ø) 8 <0> (ø) ⬇️
...operators/observable/ObservableThrottleLatest.java 100% <100%> (ø) 2 <1> (ø) ⬇️
...ternal/operators/completable/CompletableEmpty.java 100% <100%> (ø) 2 <1> (ø) ⬇️
...activex/internal/observers/QueueDrainObserver.java 100% <100%> (+2.56%) 22 <11> (+1) ⬆️
...al/operators/completable/CompletableDoOnEvent.java 100% <100%> (ø) 2 <1> (ø) ⬇️
...x/internal/operators/observable/ObservableZip.java 100% <100%> (ø) 6 <0> (ø) ⬇️
...internal/operators/completable/CompletableAmb.java 100% <100%> (ø) 11 <0> (ø) ⬇️
... and 179 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a20f993...04e1f4b. Read the comment docs.

@@ -188,4 +188,77 @@ public void completableSourceAsMs() throws Exception {
public void observableAsC() throws Exception {
findPattern("Observable<.*>\\s+c\\b");
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

findPattern("Single<.*>\\s+flowable\\b");
}

public void observerAsSubscriber() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing @Test

findPattern("Observer<.*>\\s+subscriber[0-9]?\\b");
}

public void observerAsS() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing @Test

findPattern("Observer\\s+s[0-9]?\\b");
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: indent

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'll indent it shortly.

@@ -466,35 +467,40 @@ public boolean test(Integer n, Throwable e) throws Exception {

@Test
public void retryBiPredicateDisposeRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final PublishProcessor<Integer> pp = PublishProcessor.create();
RxJavaPlugins.setErrorHandler(Functions.emptyConsumer());
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, did it flake?

Copy link
Member Author

Choose a reason for hiding this comment

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

One valid outcome was an error that was flooding the console. It is not interesting here so itbis suppressed.

@@ -118,7 +118,9 @@ public void requestMore(long n) {

@Override
public void onStart() {
request(initialRequest);
if (initialRequest > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, why though? Isn't it normally validated by SubscriptionHelper#validate()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's how I found this mistake. The intention wasn't to trigger the validation but simply not request upfront.

Copy link
Contributor

Choose a reason for hiding this comment

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

was it just going to RxJavaPlugins and not failing the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, only that default stacktrace printout of the validation error.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see

If you want I can make a JUnit Rule that'll by default check that there are no RxJavaPlugin errors and an annotation to allow errors on specific tests

@artem-zinnatullin
Copy link
Contributor

Mathematical representation of this code review:

limit (1/x^2) as x->0

screen shot 2018-07-31 at 3 42 59 pm

Each "Load diff" was technically getting me closer…

I've tried my best, hope I didn't miss anything.

@akarnokd akarnokd merged commit 45cc53d into ReactiveX:2.x Aug 1, 2018
@akarnokd akarnokd deleted the LessErrorPrintout branch August 1, 2018 08:23
Copy link
Collaborator

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

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

Good change 👍

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

Successfully merging this pull request may close these issues.

3 participants