frida-test 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAwEA,wBAAsB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CA2DlG"}
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAwFA,wBAAsB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CA4DlG"}
package/dist/bundler.js CHANGED
@@ -63,6 +63,20 @@ async function deleteWorkDir(workDir) {
63
63
  logger.warn(`Failed to remove temporary work dir "${workDir}": ${err.message}`);
64
64
  }
65
65
  }
66
+ async function prepareTypeCheckConfig(projectRoot, workDir) {
67
+ const realTsconfigPath = path.join(projectRoot, "tsconfig.json");
68
+ if (!existsSync(realTsconfigPath))
69
+ return;
70
+ const scratchConfig = {
71
+ extends: realTsconfigPath.replace(/\\/g, "/"),
72
+ compilerOptions: {
73
+ rootDir: projectRoot.replace(/\\/g, "/"),
74
+ },
75
+ include: [],
76
+ exclude: [],
77
+ };
78
+ await writeFile(path.join(workDir, "tsconfig.json"), JSON.stringify(scratchConfig, null, 2), "utf8");
79
+ }
66
80
  export async function bundleAgent(testSuitePaths, keep = false) {
67
81
  if (testSuitePaths.length === 0) {
68
82
  throw new Error("bundleAgent requires at least one test suite path.");
@@ -87,19 +101,19 @@ export async function bundleAgent(testSuitePaths, keep = false) {
87
101
  .join("\n");
88
102
  await rm(entrypointPath, { force: true });
89
103
  await writeFile(entrypointPath, agentSource.replace(IMPORT_MARKER, importStatements), "utf8");
104
+ await prepareTypeCheckConfig(projectRoot, workDir);
90
105
  const outfilePath = path.join(workDir, AGENT_BUNDLE_FILENAME);
91
106
  const fridaCompile = getFridaCompileBin(projectRoot);
92
107
  const args = fridaCompile.useLocal ? [entrypointPath, "-o", outfilePath] : ["frida-compile", entrypointPath, "-o", outfilePath];
93
108
  try {
94
109
  execFileSync(fridaCompile.path, args, {
95
- cwd: projectRoot,
110
+ cwd: workDir,
96
111
  shell: process.platform === "win32",
97
- encoding: "utf8",
112
+ stdio: "inherit",
98
113
  });
99
114
  }
100
115
  catch (err) {
101
- const stderr = err.stderr?.toString().trim();
102
- throw new Error(`frida-compile failed for entrypoint "${entrypointPath}" with suites [${testSuitePaths.join(", ")}]: ${stderr || err.message}`, { cause: err });
116
+ throw new Error(`frida-compile failed for entrypoint "${entrypointPath}" with suites [${testSuitePaths.join(", ")}] (see compiler output above for details)`, { cause: err });
103
117
  }
104
118
  logger.info(`Agent bundle sucessfully created and saved at ${outfilePath}.`);
105
119
  return await readFile(outfilePath, "utf8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-test",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "license": "GPL-3.0-only",
6
6
  "homepage": "https://github.com/bernhste/frida-test/blob/main/README.md",
@@ -63,6 +63,6 @@
63
63
  "typescript": "^7.0.2"
64
64
  },
65
65
  "allowScripts": {
66
- "frida@17.17.0": true
66
+ "frida@17.18.0": true
67
67
  }
68
68
  }
@@ -252,35 +252,29 @@ export async function runTests(nodes: TestSuiteNode[], emit: (message: AgentMess
252
252
 
253
253
  const parentHooks: EachHooks = { beforeEach: rootHooks.beforeEach, afterEach: rootHooks.afterEach };
254
254
 
255
- const settled = await Promise.allSettled(
256
- nodes.map(async (node) => {
257
- emit({ type: "test-suite-started", name: node.name });
258
- const { result: testResult, counts } = await runTestSuiteNode(node, verbose, parentHooks);
259
- const suiteResult: TestSuiteResult = { name: node.name, testResult, status: testResult.status };
260
- emit({ type: "test-suite-finished", name: node.name, result: suiteResult });
261
- return { suiteResult, counts };
262
- }),
263
- );
264
-
265
255
  const testSuitesResults: TestSuiteResult[] = [];
266
256
  let counts = ZERO_COUNTS;
267
257
 
268
- settled.forEach((outcome, i) => {
269
- if (outcome.status === "fulfilled") {
270
- testSuitesResults.push(outcome.value.suiteResult);
271
- counts = addCounts(counts, outcome.value.counts);
272
- return;
258
+ for (const node of nodes) {
259
+ emit({ type: "test-suite-started", name: node.name });
260
+ try {
261
+ const { result: testResult, counts: nodeCounts } = await runTestSuiteNode(node, verbose, parentHooks);
262
+ const suiteResult: TestSuiteResult = { name: node.name, testResult, status: testResult.status };
263
+ emit({ type: "test-suite-finished", name: node.name, result: suiteResult });
264
+ testSuitesResults.push(suiteResult);
265
+ counts = addCounts(counts, nodeCounts);
266
+ } catch (err) {
267
+ const error = serializeError(err, verbose);
268
+ const suiteResult: TestSuiteResult = {
269
+ name: node.name,
270
+ testResult: { name: node.name, status: "failed", durationMs: 0, error },
271
+ status: "failed",
272
+ };
273
+ emit({ type: "test-suite-finished", name: node.name, result: suiteResult });
274
+ testSuitesResults.push(suiteResult);
275
+ counts = addCounts(counts, { total: 1, passed: 0, failed: 1 });
273
276
  }
274
-
275
- const error = serializeError(outcome.reason, verbose);
276
- const testSuiteResult: TestSuiteResult = {
277
- name: nodes[i].name,
278
- testResult: { name: nodes[i].name, status: "failed", durationMs: 0, error },
279
- status: "failed",
280
- };
281
- testSuitesResults.push(testSuiteResult);
282
- counts = addCounts(counts, { total: 1, passed: 0, failed: 1 });
283
- });
277
+ }
284
278
 
285
279
  const afterAllError = await runTeardownHooks(rootHooks.afterAll, verbose);
286
280
  if (afterAllError) {