testing: clean up actions, add run/debug all, rm duplication

The WorkspaceTestCollectionService duplicated collection logic
unnecessarily. Centralize to the TestService's collection.

This also moves the state updates for discovering tests, and a new
update for adding roots, into the diff, which lets us synchronize those
changes with the changes to test collections.

There's a super crazy bug with the "run all" action that I have
not dove into yet.
This commit is contained in:
Connor Peet
2021-01-19 17:41:01 -08:00
parent bb1c05e62e
commit 686cd7df53
17 changed files with 442 additions and 280 deletions

View File

@@ -3,13 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CancellationToken } from 'vs/base/common/cancellation';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { URI, UriComponents } from 'vs/base/common/uri';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { getTestSubscriptionKey, RunTestsRequest, RunTestsResult, TestDiffOpType, TestsDiff } from 'vs/workbench/contrib/testing/common/testCollection';
import { ITestService } from 'vs/workbench/contrib/testing/common/testService';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { ExtHostContext, ExtHostTestingResource, ExtHostTestingShape, IExtHostContext, MainContext, MainThreadTestingShape } from '../common/extHost.protocol';
import { URI, UriComponents } from 'vs/base/common/uri';
import { CancellationToken } from 'vs/base/common/cancellation';
const reviveDiff = (diff: TestsDiff) => {
for (const entry of diff) {
@@ -41,6 +41,7 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
this.proxy = extHostContext.getProxy(ExtHostContext.ExtHostTesting);
this._register(this.testService.onShouldSubscribe(args => this.proxy.$subscribeToTests(args.resource, args.uri)));
this._register(this.testService.onShouldUnsubscribe(args => this.proxy.$unsubscribeFromTests(args.resource, args.uri)));
testService.updateRootProviderCount(1);
for (const { resource, uri } of this.testService.subscriptions) {
this.proxy.$subscribeToTests(resource, uri);
@@ -64,13 +65,6 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
this.testService.unregisterTestController(id);
}
/**
* @inheritdoc
*/
$updateDiscoveringCount(resource: ExtHostTestingResource, uriComponents: UriComponents, delta: number): void {
this.testService.updateDiscoveringCount(resource, URI.revive(uriComponents), delta);
}
/**
* @inheritdoc
*/
@@ -103,6 +97,10 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
}
public dispose() {
// no-op
this.testService.updateRootProviderCount(-1);
for (const subscription of this.testSubscriptions.values()) {
subscription.dispose();
}
this.testSubscriptions.clear();
}
}