Skip to content

Commit f694061

Browse files
committed
fix cancelation tests
1 parent 17e23ac commit f694061

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

python_files/tests/pytestadapter/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ def parse_rpc_message(data: str) -> Tuple[Dict[str, str], str]:
130130

131131
def _listen_on_fifo(pipe_name: str, result: List[str], completed: threading.Event):
132132
# Open the FIFO for reading
133-
with open(pipe_name) as fifo:
133+
fifo_path = pathlib.Path(pipe_name)
134+
with fifo_path.open() as fifo:
134135
print("Waiting for data...")
135136
while True:
136137
if completed.is_set():

src/client/testing/testController/pytest/pytestExecutionAdapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
188188
resultProc?.kill();
189189
} else {
190190
deferredTillExecClose.resolve();
191+
serverCancel.cancel();
191192
}
192193
});
193194

src/client/testing/testController/unittest/testExecutionAdapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export class UnittestTestExecutionAdapter implements ITestExecutionAdapter {
190190
resultProc?.kill();
191191
} else {
192192
deferredTillExecClose?.resolve();
193+
serverCancel.cancel();
193194
}
194195
});
195196

src/test/testing/testController/testCancellationRunAdapters.unit.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ suite('Execution Flow Run Adapters', () => {
7474
.setup((x) => x.execObservable(typeMoq.It.isAny(), typeMoq.It.isAny()))
7575
.returns(() => {
7676
cancellationToken.cancel();
77-
deferredTillServerCloseTester?.resolve();
7877
return {
7978
proc: mockProc as any,
8079
out: typeMoq.Mock.ofType<Observable<Output<string>>>().object,
@@ -96,8 +95,12 @@ suite('Execution Flow Run Adapters', () => {
9695
return Promise.resolve('named-pipe');
9796
});
9897

99-
utilsStartRunResultNamedPipe.callsFake((_callback, deferredTillServerClose, _token) => {
98+
utilsStartRunResultNamedPipe.callsFake((_callback, deferredTillServerClose, token) => {
10099
deferredTillServerCloseTester = deferredTillServerClose;
100+
token?.onCancellationRequested(() => {
101+
deferredTillServerCloseTester?.resolve();
102+
});
103+
101104
return Promise.resolve('named-pipes-socket-name');
102105
});
103106
serverDisposeStub.callsFake(() => {
@@ -140,7 +143,6 @@ suite('Execution Flow Run Adapters', () => {
140143
.setup((x) => x.execObservable(typeMoq.It.isAny(), typeMoq.It.isAny()))
141144
.returns(() => {
142145
cancellationToken.cancel();
143-
deferredTillServerCloseTester?.resolve();
144146
return {
145147
proc: mockProc as any,
146148
out: typeMoq.Mock.ofType<Observable<Output<string>>>().object,
@@ -164,6 +166,9 @@ suite('Execution Flow Run Adapters', () => {
164166

165167
utilsStartRunResultNamedPipe.callsFake((_callback, deferredTillServerClose, _token) => {
166168
deferredTillServerCloseTester = deferredTillServerClose;
169+
token?.onCancellationRequested(() => {
170+
deferredTillServerCloseTester?.resolve();
171+
});
167172
return Promise.resolve('named-pipes-socket-name');
168173
});
169174
serverDisposeStub.callsFake(() => {
@@ -188,7 +193,6 @@ suite('Execution Flow Run Adapters', () => {
188193
})
189194
.returns(async () => {
190195
cancellationToken.cancel();
191-
deferredTillServerCloseTester?.resolve();
192196
return Promise.resolve();
193197
});
194198

0 commit comments

Comments
 (0)