MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / killFlutterTester

Function killFlutterTester

src/test/debug_helpers.ts:320–354  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

318}
319
320export async function killFlutterTester(): Promise<void> {
321 // privateApi may be unavailable if the test was skipped (eg. Flutter Bazel on
322 // Windows), so we can't call privateApi.safeToolSpawn here (though also should
323 // not need to).
324 if (!privateApi)
325 return;
326
327 await new Promise<void>((resolve) => {
328 const proc = isWin
329 ? privateApi.safeToolSpawn(undefined, "taskkill", ["/IM", "flutter_tester.exe", "/F"])
330 : privateApi.safeToolSpawn(undefined, "pkill", ["flutter_tester"]);
331 proc.on("exit", (code: number) => {
332 if (isWin ? code !== 128 : code === 0) {
333 logger.warn(`flutter_tester process(s) remained after test (${currentTestName}). These have been terminated to avoid affecting future tests, ` +
334 `but may indicate something is not cleaning up correctly`, LogCategory.CI);
335 }
336 resolve();
337 });
338 });
339
340 if (!isWin) {
341 await new Promise<void>((resolve) => {
342 const proc2 = privateApi.safeToolSpawn(undefined, "ps", ["-x"]);
343
344 proc2.stdout.setEncoding("utf8");
345 proc2.stdout.on("data", (data: Buffer | string) => logger.info(data.toString()));
346 proc2.stderr.setEncoding("utf8");
347 proc2.stderr.on("data", (data: Buffer | string) => logger.info(data.toString()));
348 proc2.on("error", (error) => logger.info(error?.message));
349 proc2.on("data", (data: Buffer | string) => logger.info(data.toString()));
350
351 proc2.on("exit", () => resolve());
352 });
353 }
354}
355
356export function isSdkFrame(frame: DebugProtocol.StackFrame) {
357 return frame.source?.name?.startsWith("dart:");

Calls 4

onMethod · 0.80
warnMethod · 0.65
infoMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected