Skip to content

Commit 5367ef7

Browse files
committed
fix(scripts): accept forwarded otel smoke args
1 parent 598e177 commit 5367ef7

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

scripts/qa-otel-smoke.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { tmpdir } from "node:os";
1010
import path from "node:path";
1111
import { pathToFileURL } from "node:url";
1212
import { gunzipSync } from "node:zlib";
13+
import { stripLeadingPackageManagerSeparator } from "./lib/arg-utils.mjs";
1314

1415
type CollectorMode = "local" | "docker";
1516

@@ -169,6 +170,7 @@ Collector container in front of the receiver.
169170
}
170171

171172
function parseArgs(argv: string[]): CliOptions {
173+
const args = stripLeadingPackageManagerSeparator(argv);
172174
const options: CliOptions = {
173175
collectorMode: "local",
174176
outputDir: path.join(".artifacts", "qa-e2e", `otel-smoke-${Date.now().toString(36)}`),
@@ -177,14 +179,14 @@ function parseArgs(argv: string[]): CliOptions {
177179
help: false,
178180
};
179181

180-
for (let index = 0; index < argv.length; index += 1) {
181-
const arg = argv[index];
182+
for (let index = 0; index < args.length; index += 1) {
183+
const arg = args[index];
182184
if (arg === "--help" || arg === "-h") {
183185
options.help = true;
184186
continue;
185187
}
186188
const readValue = () => {
187-
const value = argv[index + 1]?.trim();
189+
const value = args[index + 1]?.trim();
188190
if (!value) {
189191
throw new Error(`${arg} requires a value`);
190192
}
@@ -1334,6 +1336,7 @@ async function main() {
13341336
export const testing = {
13351337
appendCapturedBodyText,
13361338
decodeRequestBody,
1339+
parseArgs,
13371340
readPositiveIntegerEnv,
13381341
readRequestBody,
13391342
};

test/scripts/qa-otel-smoke.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ import { describe, expect, it } from "vitest";
44
import { testing } from "../../scripts/qa-otel-smoke.ts";
55

66
describe("qa-otel-smoke receiver bounds", () => {
7+
it("accepts package-manager forwarded arguments", () => {
8+
expect(
9+
testing.parseArgs([
10+
"--",
11+
"--collector",
12+
"docker",
13+
"--provider-mode",
14+
"mock-openai",
15+
"--scenario",
16+
"otel-trace-smoke",
17+
]),
18+
).toMatchObject({
19+
collectorMode: "docker",
20+
providerMode: "mock-openai",
21+
scenarioId: "otel-trace-smoke",
22+
});
23+
});
24+
725
it("parses body-size limit env values as strict positive integers", () => {
826
expect(testing.readPositiveIntegerEnv("OTEL_TEST_LIMIT", 64, {})).toBe(64);
927
expect(

0 commit comments

Comments
 (0)