Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/src/cli/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 2 kB image not shown  

Quelle  command-source.test-helpers.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { readCommandSource } from "./command-source.test-helpers.js";

const tempDirs: string[] = [];

afterEach(() => {
  for (const dir of tempDirs.splice(0)) {
    fs.rmSync(dir, { recursive: true, force: true });
  }
});

function makeTempDir(): string {
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-command-source-"));
  tempDirs.push(dir);
  return dir;
}

describe("readCommandSource", () => {
  it("follows re-export shims and runtime boundaries", async () => {
    const rootDir = makeTempDir();
    const cliDir = path.join(rootDir, "src", "cli");
    fs.mkdirSync(cliDir, { recursive: true });
    fs.writeFileSync(path.join(cliDir, "index.ts"), 'export * from "./command.js";\n');
    fs.writeFileSync(
      path.join(cliDir, "command.ts"),
      [
        "async function loadRuntime() {",
        '  return await import("./command.runtime.js");',
        "}",
        "export { loadRuntime };",
      ].join("\n"),
    );
    fs.writeFileSync(
      path.join(cliDir, "command.runtime.ts"),
      'export const marker = "resolveCommandSecretRefsViaGateway";\n',
    );

    const source = await readCommandSource("src/cli/index.ts", rootDir);

    expect(source).toContain('export * from "./command.js";');
    expect(source).toContain('import("./command.runtime.js")');
    expect(source).toContain("resolveCommandSecretRefsViaGateway");
  });

  it("dedupes repeated runtime imports", async () => {
    const rootDir = makeTempDir();
    const cliDir = path.join(rootDir, "src", "cli");
    fs.mkdirSync(cliDir, { recursive: true });
    fs.writeFileSync(
      path.join(cliDir, "command.ts"),
      ['await import("./shared.runtime.js");', 'await import("./shared.runtime.js");'].join("\n"),
    );
    fs.writeFileSync(path.join(cliDir, "shared.runtime.ts"), "export const shared = true;\n");

    const source = await readCommandSource("src/cli/command.ts", rootDir);
    const occurrences = source.match(/export const shared = true;/gu) ?? [];

    expect(occurrences).toHaveLength(1);
  });
});

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.