Skip to content

Commit dd7cab9

Browse files
committed
Retrofit bazelrc tests for new command lens providers
1 parent 22e7392 commit dd7cab9

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/bazelrc/feature.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@ export class BazelrcFeature implements IExtensionFeature, vscode.Disposable {
1919
) {
2020
}
2121

22-
private registerBazelCommandCodeLensProviders(bazelExecutable: string) {
23-
const provider = new BazelCommandCodeLensProvider(bazelExecutable);
24-
const r = this.commandCodelensProviderRegistry;
25-
BazelCommands.forEach(command => {
26-
r.registerCommandCodeLensProvider(command, provider);
27-
});
28-
}
29-
3022
async activate(
3123
ctx: vscode.ExtensionContext,
3224
config: vscode.WorkspaceConfiguration): Promise<any> {
3325

3426
const cfg = await createBazelrcConfiguration(ctx, config);
35-
this.registerBazelCommandCodeLensProviders(cfg.run.executable);
27+
registerBazelCommandCodeLensProviders(this.commandCodelensProviderRegistry, cfg.run.executable);
3628

3729
const codelens = new BazelrcCodelens(cfg.run.executable, this.commandCodelensProviderRegistry);
3830
this.disposables.push(codelens);
@@ -54,7 +46,7 @@ export class BazelrcFeature implements IExtensionFeature, vscode.Disposable {
5446
}
5547
}
5648

57-
class BazelCommandCodeLensProvider implements CommandCodeLensProvider {
49+
export class BazelCommandCodeLensProvider implements CommandCodeLensProvider {
5850
constructor(
5951
private bazelExecutable: string,
6052
) {}
@@ -97,3 +89,10 @@ function createRunCommand(runCtx: RunContext): vscode.Command {
9789
tooltip: `${runCtx.command} ${runCtx.args.join(' ')}`,
9890
};
9991
}
92+
93+
export function registerBazelCommandCodeLensProviders(registry: ICommandCodeLensProviderRegistry, bazelExecutable: string) {
94+
const provider = new BazelCommandCodeLensProvider(bazelExecutable);
95+
BazelCommands.forEach(command => {
96+
registry.registerCommandCodeLensProvider(command, provider);
97+
});
98+
}

src/test/integration/feature.bazelrc.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { expect } from 'chai';
88
import { after, before, describe, it } from 'mocha';
99
import { API } from '../../api';
1010
import { BazelrcCodelens, RunContext } from '../../bazelrc/codelens';
11-
import { BazelrcFeatureName } from '../../bazelrc/feature';
11+
import { BazelrcFeatureName, registerBazelCommandCodeLensProviders } from '../../bazelrc/feature';
1212
import { BazelFlagSupport } from '../../bazelrc/flags';
1313

1414
tmp.setGracefulCleanup();
@@ -37,7 +37,7 @@ type codelensTest = {
3737
range?: vscode.Range, // the expected range, if we care
3838
};
3939

40-
describe(BazelrcFeatureName, function () {
40+
describe.only(BazelrcFeatureName, function () {
4141
let support: BazelFlagSupport;
4242
let codelens: BazelrcCodelens;
4343
const cancellationTokenSource = new vscode.CancellationTokenSource();
@@ -51,6 +51,7 @@ describe(BazelrcFeatureName, function () {
5151
});
5252
await support.load();
5353
const registry = new API();
54+
registerBazelCommandCodeLensProviders(registry, 'bazel');
5455
codelens = new BazelrcCodelens('bazel', registry);
5556
await codelens.setup(true); // skip install commands
5657
});

0 commit comments

Comments
 (0)