forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprojectAdapter.ts
More file actions
142 lines (120 loc) · 3.63 KB
/
projectAdapter.ts
File metadata and controls
142 lines (120 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { TestItem, Uri } from 'vscode';
import { TestProvider } from '../../types';
import {
ITestDiscoveryAdapter,
ITestExecutionAdapter,
ITestResultResolver,
DiscoveredTestPayload,
DiscoveredTestNode,
} from './types';
import { PythonEnvironment, PythonProject } from '../../../envExt/types';
/**
* Represents a single Python project with its own test infrastructure.
* A project is defined as a combination of a Python executable + URI (folder/file).
* Projects are keyed by projectUri.toString()
*/
export interface ProjectAdapter {
// === IDENTITY ===
/**
* Project identifier, which is the string representation of the project URI.
*/
projectId: string;
/**
* Display name for the project (e.g., "alice (Python 3.11)").
*/
projectName: string;
/**
* URI of the project root folder or file.
*/
projectUri: Uri;
/**
* Parent workspace URI containing this project.
*/
workspaceUri: Uri;
// === API OBJECTS (from vscode-python-environments extension) ===
/**
* The PythonProject object from the environment API.
*/
pythonProject: PythonProject;
/**
* The resolved PythonEnvironment with execution details.
* Contains execInfo.run.executable for running tests.
*/
pythonEnvironment: PythonEnvironment;
// === TEST INFRASTRUCTURE ===
/**
* Test framework provider ('pytest' | 'unittest').
*/
testProvider: TestProvider;
/**
* Adapter for test discovery.
*/
discoveryAdapter: ITestDiscoveryAdapter;
/**
* Adapter for test execution.
*/
executionAdapter: ITestExecutionAdapter;
/**
* Result resolver for this project (maps test IDs and handles results).
*/
resultResolver: ITestResultResolver;
// === DISCOVERY STATE ===
/**
* Raw discovery data before filtering (all discovered tests).
* Cleared after ownership resolution to save memory.
*/
rawDiscoveryData?: DiscoveredTestPayload;
/**
* Filtered tests that this project owns (after API verification).
* This is the tree structure passed to populateTestTree().
*/
ownedTests?: DiscoveredTestNode;
// === LIFECYCLE ===
/**
* Whether discovery is currently running for this project.
*/
isDiscovering: boolean;
/**
* Whether tests are currently executing for this project.
*/
isExecuting: boolean;
/**
* Root TestItem for this project in the VS Code test tree.
* All project tests are children of this item.
*/
projectRootTestItem?: TestItem;
}
/**
* Temporary state used during workspace-wide test discovery.
* Created at the start of discovery and cleared after ownership resolution.
*/
export interface WorkspaceDiscoveryState {
/**
* The workspace being discovered.
*/
workspaceUri: Uri;
/**
* Maps test file paths to the set of projects that discovered them.
* Used to detect overlapping discovery.
*/
fileToProjects: Map<string, Set<ProjectAdapter>>;
/**
* Maps test file paths to their owning project (after API resolution).
* Value is the ProjectAdapter whose pythonProject.uri matches API response.
*/
fileOwnership: Map<string, ProjectAdapter>;
/**
* Progress tracking for parallel discovery.
*/
projectsCompleted: Set<string>;
/**
* Total number of projects in this workspace.
*/
totalProjects: number;
/**
* Whether all projects have completed discovery.
*/
isComplete: boolean;
}