Skip to content

Commit 2b75bc7

Browse files
committed
"testRunSettings" option is now available through solution
1 parent 19b027b commit 2b75bc7

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@
826826
"default": false,
827827
"description": "(EXPERIMENTAL) Enables support for resolving completion edits asynchronously. This can speed up time to show the completion list, particularly override and partial method completion lists, at the cost of slight delays after inserting a completion item. Most completion items will have no noticeable impact with this feature, but typing immediately after inserting an override or partial method completion, before the insert is completed, can have unpredictable results."
828828
},
829+
"omnisharp.testRunSettings": {
830+
"type": "string",
831+
"default": null,
832+
"description": "Specifies the path to the .runSettings file used to run the unit tests"
833+
},
829834
"razor.plugin.path": {
830835
"type": [
831836
"string",

src/features/dotnetTest.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import LaunchConfiguration from './launchConfiguration';
1919
import Disposable from '../Disposable';
2020
import CompositeDisposable from '../CompositeDisposable';
2121
import { LanguageMiddlewareFeature } from '../omnisharp/LanguageMiddlewareFeature';
22+
import OptionProvider from '../observers/OptionProvider';
2223

2324
const TelemetryReportingDelay = 2 * 60 * 1000; // two minutes
2425

@@ -29,7 +30,7 @@ export default class TestManager extends AbstractProvider {
2930
private _telemetryIntervalId: NodeJS.Timer = undefined;
3031
private _eventStream: EventStream;
3132

32-
constructor(server: OmniSharpServer, eventStream: EventStream, languageMiddlewareFeature: LanguageMiddlewareFeature) {
33+
constructor(private optionProvider: OptionProvider, server: OmniSharpServer, eventStream: EventStream, languageMiddlewareFeature: LanguageMiddlewareFeature) {
3334
super(server, languageMiddlewareFeature);
3435
this._eventStream = eventStream;
3536

@@ -172,8 +173,8 @@ export default class TestManager extends AbstractProvider {
172173
public async discoverTests(fileName: string, testFrameworkName: string, noBuild: boolean): Promise<protocol.V2.TestInfo[]> {
173174

174175
let targetFrameworkVersion = await this._recordRunAndGetFrameworkVersion(fileName, testFrameworkName);
175-
let runSettings = vscode.workspace.getConfiguration('omnisharp').get<string>('testRunSettings');
176-
176+
let runSettings = this._getRunSettings();
177+
177178
const request: protocol.V2.DiscoverTestsRequest = {
178179
FileName: fileName,
179180
RunSettings: runSettings,
@@ -192,7 +193,7 @@ export default class TestManager extends AbstractProvider {
192193
}
193194

194195
private _getRunSettings(): string | undefined {
195-
return vscode.workspace.getConfiguration('omnisharp').get<string>('testRunSettings');
196+
return this.optionProvider.GetLatestOptions().testRunSettings;
196197
}
197198

198199
public async runDotnetTest(testMethod: string, fileName: string, testFrameworkName: string, noBuild: boolean = false) {

src/omnisharp/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an
6363
languageMiddlewareFeature.register();
6464
disposables.add(languageMiddlewareFeature);
6565
let localDisposables: CompositeDisposable;
66-
const testManager = new TestManager(server, eventStream, languageMiddlewareFeature);
66+
const testManager = new TestManager(optionProvider, server, eventStream, languageMiddlewareFeature);
6767
const completionProvider = new CompletionProvider(server, languageMiddlewareFeature);
6868

6969
disposables.add(server.onServerStart(() => {

src/omnisharp/options.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export class Options {
3838
public defaultLaunchSolution?: string,
3939
public monoPath?: string,
4040
public excludePaths?: string[],
41-
public maxProjectFileCountForDiagnosticAnalysis?: number | null) {
41+
public maxProjectFileCountForDiagnosticAnalysis?: number | null,
42+
public testRunSettings?: string) {
4243
}
4344

4445
public static Read(vscode: vscode): Options {
@@ -104,6 +105,8 @@ export class Options {
104105

105106
const maxProjectFileCountForDiagnosticAnalysis = csharpConfig.get<number | null>('maxProjectFileCountForDiagnosticAnalysis', 1000);
106107

108+
const testRunSettings = omnisharpConfig.get<string>('testRunSettings', undefined);
109+
107110
const excludePaths = this.getExcludedPaths(vscode);
108111

109112
return new Options(
@@ -138,7 +141,8 @@ export class Options {
138141
defaultLaunchSolution,
139142
monoPath,
140143
excludePaths,
141-
maxProjectFileCountForDiagnosticAnalysis
144+
maxProjectFileCountForDiagnosticAnalysis,
145+
testRunSettings
142146
);
143147
}
144148

test/unitTests/options.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ suite("Options tests", () => {
3434
options.enableEditorConfigSupport.should.equal(false);
3535
options.enableDecompilationSupport.should.equal(false);
3636
options.enableImportCompletion.should.equal(false);
37+
expect(options.testRunSettings).to.be.undefined;
3738
expect(options.defaultLaunchSolution).to.be.undefined;
3839
});
3940

@@ -143,4 +144,13 @@ suite("Options tests", () => {
143144

144145
options.defaultLaunchSolution.should.equal("some_valid_solution.sln");
145146
});
147+
148+
test('"omnisharp.testRunSettings" is used if set', () => {
149+
const vscode = getVSCodeWithConfig();
150+
updateConfig(vscode, 'omnisharp', 'testRunSettings', 'some_valid_path\\some_valid_runsettings_files.runsettings');
151+
152+
const options = Options.Read(vscode);
153+
154+
options.testRunSettings.should.equal("some_valid_path\\some_valid_runsettings_files.runsettings");
155+
});
146156
});

0 commit comments

Comments
 (0)