Skip to content

Commit

Permalink
fix cancelation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Oct 29, 2024
1 parent 17e23ac commit f694061
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion python_files/tests/pytestadapter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def parse_rpc_message(data: str) -> Tuple[Dict[str, str], str]:

def _listen_on_fifo(pipe_name: str, result: List[str], completed: threading.Event):
# Open the FIFO for reading
with open(pipe_name) as fifo:
fifo_path = pathlib.Path(pipe_name)
with fifo_path.open() as fifo:
print("Waiting for data...")
while True:
if completed.is_set():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
resultProc?.kill();
} else {
deferredTillExecClose.resolve();
serverCancel.cancel();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class UnittestTestExecutionAdapter implements ITestExecutionAdapter {
resultProc?.kill();
} else {
deferredTillExecClose?.resolve();
serverCancel.cancel();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ suite('Execution Flow Run Adapters', () => {
.setup((x) => x.execObservable(typeMoq.It.isAny(), typeMoq.It.isAny()))
.returns(() => {
cancellationToken.cancel();
deferredTillServerCloseTester?.resolve();
return {
proc: mockProc as any,
out: typeMoq.Mock.ofType<Observable<Output<string>>>().object,
Expand All @@ -96,8 +95,12 @@ suite('Execution Flow Run Adapters', () => {
return Promise.resolve('named-pipe');
});

utilsStartRunResultNamedPipe.callsFake((_callback, deferredTillServerClose, _token) => {
utilsStartRunResultNamedPipe.callsFake((_callback, deferredTillServerClose, token) => {
deferredTillServerCloseTester = deferredTillServerClose;
token?.onCancellationRequested(() => {
deferredTillServerCloseTester?.resolve();
});

return Promise.resolve('named-pipes-socket-name');
});
serverDisposeStub.callsFake(() => {
Expand Down Expand Up @@ -140,7 +143,6 @@ suite('Execution Flow Run Adapters', () => {
.setup((x) => x.execObservable(typeMoq.It.isAny(), typeMoq.It.isAny()))
.returns(() => {
cancellationToken.cancel();
deferredTillServerCloseTester?.resolve();
return {
proc: mockProc as any,
out: typeMoq.Mock.ofType<Observable<Output<string>>>().object,
Expand All @@ -164,6 +166,9 @@ suite('Execution Flow Run Adapters', () => {

utilsStartRunResultNamedPipe.callsFake((_callback, deferredTillServerClose, _token) => {
deferredTillServerCloseTester = deferredTillServerClose;
token?.onCancellationRequested(() => {
deferredTillServerCloseTester?.resolve();
});
return Promise.resolve('named-pipes-socket-name');
});
serverDisposeStub.callsFake(() => {
Expand All @@ -188,7 +193,6 @@ suite('Execution Flow Run Adapters', () => {
})
.returns(async () => {
cancellationToken.cancel();
deferredTillServerCloseTester?.resolve();
return Promise.resolve();
});

Expand Down

0 comments on commit f694061

Please sign in to comment.