Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(profiler): no such file /proc/{pid}/task #117

Merged
merged 13 commits into from
Jul 12, 2023
Merged
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os from "os";
import fs from "fs";
import { measurePerformance } from "..";
import { PerformancePollingMock } from "../utils/PerformancePollingMock";
import { PerformancePollingMock } from "../utils/test/PerformancePollingMock";
import { Logger, LogLevel } from "@perf-profiler/logger";

const mockPerformancePolling = new PerformancePollingMock();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
Copy link
Contributor

@legkikh legkikh Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes (but at least it's in a test file)

import EventEmitter from "events";
import { ChildProcess } from "child_process";

const mockSpawn = (): { stdout: EventEmitter; kill: () => void } => {
const mockProcess = new EventEmitter();
Expand All @@ -10,7 +12,7 @@ const mockSpawn = (): { stdout: EventEmitter; kill: () => void } => {
.spyOn(require("child_process"), "spawn")
.mockImplementationOnce((...args) => {
expect(args).toEqual(["adb", ["shell", "atrace", "-c", "view", "-t", "999"]]);
return mockProcess;
return mockProcess as ChildProcess;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we okay with these casts I suppose ?

})
.mockImplementationOnce((...args) => {
expect(args).toEqual([
Expand All @@ -23,7 +25,7 @@ const mockSpawn = (): { stdout: EventEmitter; kill: () => void } => {
"500",
],
]);
return mockProcess;
return mockProcess as ChildProcess;
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// We'll remove the flipper plugin at some point so it's ok to just import those
// from another package in the test
// eslint-disable-next-line import/no-extraneous-dependencies
import "@perf-profiler/measure/src/__tests__/utils/mockChildProcess";
import "@perf-profiler/e2e/src/utils/test/mockChildProcess";
// eslint-disable-next-line import/no-extraneous-dependencies
import { emitMeasures, spawn } from "@perf-profiler/measure/src/__tests__/utils/mockEmitMeasures";
import { emitMeasures, spawn } from "@perf-profiler/e2e/src/utils/test/mockEmitMeasures";
import { act, fireEvent, screen } from "@testing-library/react";
import { TestUtils } from "flipper-plugin";
import * as Plugin from "..";
Expand Down
4 changes: 2 additions & 2 deletions packages/measure/src/__tests__/measure.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "./utils/mockChildProcess";
import { spawn, emitMeasures } from "./utils/mockEmitMeasures";
import "@perf-profiler/e2e/src/utils/test/mockChildProcess";
import { spawn, emitMeasures } from "@perf-profiler/e2e/src/utils/test/mockEmitMeasures";
import { fireEvent, render as webRender, screen, waitFor, act } from "@testing-library/react";
import { render as cliRender } from "ink-testing-library";
import { MeasureWebApp } from "../webapp/MeasureWebApp";
Expand Down