1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT License.
3
3
4
- import * as path from 'path' ;
5
4
import { Uri } from 'vscode' ;
6
5
import { IConfigurationService } from '../../../common/types' ;
7
6
import { createDeferred , Deferred } from '../../../common/utils/async' ;
8
- import { EXTENSION_ROOT_DIR } from '../../../constants' ;
9
- import {
10
- DataReceivedEvent ,
11
- ExecutionTestPayload ,
12
- ITestExecutionAdapter ,
13
- ITestServer ,
14
- TestCommandOptions ,
15
- TestExecutionCommand ,
16
- } from '../common/types' ;
7
+ import { traceVerbose } from '../../../logging' ;
8
+ import { DataReceivedEvent , ExecutionTestPayload , ITestExecutionAdapter , ITestServer } from '../common/types' ;
17
9
18
10
/**
19
- * Wrapper Class for unittest test execution. This is where we call `runTestCommand`?
11
+ * Wrapper Class for pytest test execution. This is where we call `runTestCommand`?
20
12
*/
21
13
22
14
export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
@@ -37,37 +29,69 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
37
29
}
38
30
}
39
31
40
- public async runTests ( uri : Uri , testIds : string [ ] , debugBool ?: boolean ) : Promise < ExecutionTestPayload > {
41
- if ( ! this . deferred ) {
42
- const settings = this . configSettings . getSettings ( uri ) ;
43
- const { unittestArgs } = settings . testing ;
32
+ // ** Old version of discover tests.
33
+ async runTests ( uri : Uri , testIds : string [ ] , debugBool ?: boolean ) : Promise < ExecutionTestPayload > {
34
+ traceVerbose ( uri , testIds , debugBool ) ;
35
+ this . deferred = createDeferred < ExecutionTestPayload > ( ) ;
36
+ return this . deferred . promise ;
37
+ }
44
38
45
- const command = buildExecutionCommand ( unittestArgs ) ;
46
- this . cwd = uri . fsPath ;
39
+ // public async runTests(
40
+ // uri: Uri,
41
+ // testIds: string[],
42
+ // debugBool?: boolean,
43
+ // executionFactory?: IPythonExecutionFactory,
44
+ // ): Promise<ExecutionTestPayload> {
45
+ // if (!this.deferred) {
46
+ // this.deferred = createDeferred<ExecutionTestPayload>();
47
+ // const relativePathToPytest = 'pythonFiles';
48
+ // const fullPluginPath = path.join(EXTENSION_ROOT_DIR, relativePathToPytest);
49
+ // this.configSettings.isTestExecution();
50
+ // const uuid = this.testServer.createUUID(uri.fsPath);
51
+ // const settings = this.configSettings.getSettings(uri);
52
+ // const { pytestArgs } = settings.testing;
47
53
48
- const options : TestCommandOptions = {
49
- workspaceFolder : uri ,
50
- command,
51
- cwd : this . cwd ,
52
- debugBool,
53
- testIds,
54
- } ;
54
+ // const pythonPathParts: string[] = process.env.PYTHONPATH?.split(path.delimiter) ?? [];
55
+ // const pythonPathCommand = [fullPluginPath, ...pythonPathParts].join(path.delimiter);
55
56
56
- this . deferred = createDeferred < ExecutionTestPayload > ( ) ;
57
+ // const spawnOptions: SpawnOptions = {
58
+ // cwd: uri.fsPath,
59
+ // throwOnStdErr: true,
60
+ // extraVariables: {
61
+ // PYTHONPATH: pythonPathCommand,
62
+ // TEST_UUID: uuid.toString(),
63
+ // TEST_PORT: this.testServer.getPort().toString(),
64
+ // },
65
+ // };
57
66
58
- // send test command to server
59
- // server fire onDataReceived event once it gets response
60
- this . testServer . sendCommand ( options ) ;
61
- }
62
- return this . deferred . promise ;
63
- }
64
- }
67
+ // // Create the Python environment in which to execute the command.
68
+ // const creationOptions: ExecutionFactoryCreateWithEnvironmentOptions = {
69
+ // allowEnvironmentFetchExceptions: false,
70
+ // resource: uri,
71
+ // };
72
+ // // need to check what will happen in the exec service is NOT defined and is null
73
+ // const execService = await executionFactory?.createActivatedEnvironment(creationOptions);
74
+
75
+ // const testIdsString = testIds.join(' ');
76
+ // console.debug('what to do with debug bool?', debugBool);
77
+ // try {
78
+ // execService?.exec(
79
+ // ['-m', 'pytest', '-p', 'vscode_pytest', testIdsString].concat(pytestArgs),
80
+ // spawnOptions,
81
+ // );
82
+ // } catch (ex) {
83
+ // console.error(ex);
84
+ // }
85
+ // }
86
+ // return this.deferred.promise;
87
+ // }
88
+ // }
65
89
66
- function buildExecutionCommand ( args : string [ ] ) : TestExecutionCommand {
67
- const executionScript = path . join ( EXTENSION_ROOT_DIR , 'pythonFiles' , 'unittestadapter' , 'execution.py' ) ;
90
+ // function buildExecutionCommand(args: string[]): TestExecutionCommand {
91
+ // const executionScript = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'unittestadapter', 'execution.py');
68
92
69
- return {
70
- script : executionScript ,
71
- args : [ '--udiscovery' , ...args ] ,
72
- } ;
93
+ // return {
94
+ // script: executionScript,
95
+ // args: ['--udiscovery', ...args],
96
+ // };
73
97
}
0 commit comments