Skip to content

Commit 22864fd

Browse files
updated execution block
1 parent 73ad7de commit 22864fd

File tree

2 files changed

+28
-67
lines changed

2 files changed

+28
-67
lines changed

code/extensions/che-commands/src/compositeTaskBuilder.ts

Lines changed: 7 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ export class CompositeTaskBuilder {
5757
}
5858

5959
if (parallel) {
60-
return this.buildParallelCrossComponent(command, execs);
60+
execs.forEach((e, index) => {
61+
const childTask = this.buildExecTask(e, index === 0);
62+
63+
vscode.tasks.executeTask(childTask);
64+
});
65+
66+
return undefined;
6167
}
6268

6369
return this.buildSeqCrossComponent(command, execs);
@@ -231,64 +237,6 @@ export class CompositeTaskBuilder {
231237
);
232238
}
233239

234-
private buildParallelCrossComponent(
235-
command: any,
236-
execs: ResolvedExec[],
237-
): vscode.Task {
238-
const execution = new vscode.CustomExecution(async () => {
239-
const writeEmitter = new vscode.EventEmitter<string>();
240-
const closeEmitter = new vscode.EventEmitter<number>();
241-
242-
const pty: vscode.Pseudoterminal = {
243-
onDidWrite: writeEmitter.event,
244-
245-
onDidClose: closeEmitter.event,
246-
247-
open: () => {
248-
execs.forEach((e, index) => {
249-
const childTask = this.buildExecTask(e, index === 0);
250-
251-
vscode.tasks.executeTask(childTask);
252-
});
253-
closeEmitter.fire(0);
254-
},
255-
256-
close: () => {
257-
closeEmitter.fire(0);
258-
},
259-
260-
handleInput: () => {},
261-
};
262-
263-
return pty;
264-
});
265-
266-
const first = execs[0];
267-
268-
const task = new vscode.Task(
269-
{
270-
type: "devfile",
271-
command: command.id,
272-
workdir: first.workdir,
273-
component: first.component,
274-
},
275-
vscode.TaskScope.Workspace,
276-
command.composite.label || command.id,
277-
"devfile",
278-
execution,
279-
[],
280-
);
281-
282-
task.presentationOptions = {
283-
reveal: vscode.TaskRevealKind?.Never ?? 0,
284-
panel: vscode.TaskPanelKind?.Dedicated ?? 1,
285-
clear: false,
286-
showReuseMessage: false,
287-
};
288-
289-
return task;
290-
}
291-
292240
private buildExecTask(e: ResolvedExec, focus: boolean): vscode.Task {
293241
const task = new vscode.Task(
294242
{

code/extensions/che-commands/tests/compositeTaskBuilder.test.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe("Composite — same component flattening", () => {
8383
});
8484
});
8585

86-
describe("Composite — cross component execution", () => {
86+
describe("Composite Sequential — cross component execution", () => {
8787
const devfile = {
8888
commands: [
8989
{
@@ -98,10 +98,6 @@ describe("Composite — cross component execution", () => {
9898
id: "seq",
9999
composite: { commands: ["backend", "frontend"], parallel: false },
100100
},
101-
{
102-
id: "par",
103-
composite: { commands: ["backend", "frontend"], parallel: true },
104-
},
105101
],
106102
};
107103

@@ -113,6 +109,25 @@ describe("Composite — cross component execution", () => {
113109

114110
expect(term.calls.map((c) => c.component)).toEqual(["backend", "frontend"]);
115111
});
112+
});
113+
114+
describe("Composite Parallel — cross component execution", () => {
115+
const devfile = {
116+
commands: [
117+
{
118+
id: "backend",
119+
exec: { component: "backend", commandLine: "echo backend" },
120+
},
121+
{
122+
id: "frontend",
123+
exec: { component: "frontend", commandLine: "echo frontend" },
124+
},
125+
{
126+
id: "par",
127+
composite: { commands: ["backend", "frontend"], parallel: true },
128+
},
129+
],
130+
};
116131

117132
test("parallel composite executes all components and opens only child terminals", async () => {
118133
let executedTasks: vscode.Task[] = [];
@@ -135,9 +150,7 @@ describe("Composite — cross component execution", () => {
135150

136151
const term = new MockTerminalAPI();
137152

138-
const tasks = await provide(devfile, term);
139-
140-
await runByName(tasks!, "par");
153+
await provide(devfile, term);
141154

142155
expect(executedTasks).toHaveLength(2);
143156

0 commit comments

Comments
 (0)