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

Quelle  diagnostic-flags.test.ts

  Sprache: JAVA
 

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

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import {
  isDiagnosticFlagEnabled,
  matchesDiagnosticFlag,
  resolveDiagnosticFlags,
} from "./diagnostic-flags.js";

describe("resolveDiagnosticFlags", () => {
  it("normalizes and dedupes config and env flags", () => {
    const cfg = {
      diagnostics: { flags: [" Telegram.Http ", "cache.*", "CACHE.*"] },
    } as OpenClawConfig;
    const env = {
      OPENCLAW_DIAGNOSTICS: " foo, Cache.*  telegram.http  ",
    } as NodeJS.ProcessEnv;

    expect(resolveDiagnosticFlags(cfg, env)).toEqual(["telegram.http", "cache.*", "foo"]);
  });

  it("treats false-like env values as no extra flags", () => {
    const cfg = {
      diagnostics: { flags: ["telegram.http"] },
    } as OpenClawConfig;

    for (const raw of ["0", "false", "off", "none", "   "]) {
      expect(
        resolveDiagnosticFlags(cfg, {
          OPENCLAW_DIAGNOSTICS: raw,
        } as NodeJS.ProcessEnv),
      ).toEqual(["telegram.http"]);
    }
  });
});

describe("matchesDiagnosticFlag", () => {
  it("matches exact, namespace, prefix, and wildcard rules", () => {
    expect(matchesDiagnosticFlag("telegram.http", ["telegram.http"])).toBe(true);
    expect(matchesDiagnosticFlag("cache", ["cache.*"])).toBe(true);
    expect(matchesDiagnosticFlag("cache.hit", ["cache.*"])).toBe(true);
    expect(matchesDiagnosticFlag("tool.exec.fast", ["tool.exec*"])).toBe(true);
    expect(matchesDiagnosticFlag("anything", ["all"])).toBe(true);
    expect(matchesDiagnosticFlag("anything", ["*"])).toBe(true);
  });

  it("rejects blank and non-matching flags", () => {
    expect(matchesDiagnosticFlag("   ", ["*"])).toBe(false);
    expect(matchesDiagnosticFlag("cache.hit", ["cache.miss", "tool.*"])).toBe(false);
  });
});

describe("isDiagnosticFlagEnabled", () => {
  it("resolves config and env together before matching", () => {
    const cfg = {
      diagnostics: { flags: ["gateway.*"] },
    } as OpenClawConfig;
    const env = {
      OPENCLAW_DIAGNOSTICS: "telegram.http",
    } as NodeJS.ProcessEnv;

    expect(isDiagnosticFlagEnabled("gateway.ws", cfg, env)).toBe(true);
    expect(isDiagnosticFlagEnabled("telegram.http", cfg, env)).toBe(true);
    expect(isDiagnosticFlagEnabled("slack.http", cfg, env)).toBe(false);
  });
});

¤ Dauer der Verarbeitung: 0.15 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.