feat(signals): discover installed decoders and option help (#2487)
* feat(signals): discover installed decoders and selected option help * fix(signals): bound retained discovery data and preserve resource failures * fix(signals): complete CLI help and portable decoder patterns * test(signals): verify case-insensitive decoder help queries * fix(signals): retain discovery operation across cleanup retries
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { inspectSignalDecodersInputSchema } from "../../../src/domain/signals/signalDecoders.js";
|
||||
import { parseDecoderDiscovery } from "../../../src/signals/parseDecoderDiscovery.js";
|
||||
|
||||
it("rejects malformed catalogs and the wrong decoder identity", () => {
|
||||
for (const text of [
|
||||
"",
|
||||
"Supported protocol decoders:\n",
|
||||
"Supported protocol decoders:\n uart UART\n uart Duplicate",
|
||||
"Supported protocol decoders:\n malformed",
|
||||
]) {
|
||||
expect(() =>
|
||||
parseDecoderDiscovery(text, inspectSignalDecodersInputSchema.parse({})),
|
||||
).toThrow();
|
||||
}
|
||||
expect(() =>
|
||||
parseDecoderDiscovery(
|
||||
"ID: spi\nOptions:",
|
||||
inspectSignalDecodersInputSchema.parse({ decoder: "uart" }),
|
||||
),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("keeps help line ordinals, blank lines and literal special characters through selection", () => {
|
||||
const text = "ID: uart\r\nOptions:\r\n\r\n- mode: A[0] (default 'x')\r\n";
|
||||
const result = parseDecoderDiscovery(
|
||||
text,
|
||||
inspectSignalDecodersInputSchema.parse({
|
||||
decoder: "uart",
|
||||
query: "[0]",
|
||||
offset: 0,
|
||||
limit: 1,
|
||||
}),
|
||||
);
|
||||
expect(result.help_lines).toEqual([
|
||||
{ line_number: 4, text: "- mode: A[0] (default 'x')" },
|
||||
]);
|
||||
expect(result.output_window.examined).toBe(4);
|
||||
});
|
||||
|
||||
it("bounds line expansion before constructing help records", () => {
|
||||
expect(() =>
|
||||
parseDecoderDiscovery(
|
||||
"ID: uart\n" + "\n".repeat(65536),
|
||||
inspectSignalDecodersInputSchema.parse({ decoder: "uart" }),
|
||||
),
|
||||
).toThrow("representation budget");
|
||||
});
|
||||
Reference in New Issue
Block a user