Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions eng/tools/spec-gen-sdk-runner/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { existsSync, mkdirSync } from "node:fs";
import path from "node:path";
import { exit } from "node:process";
Expand All @@ -22,12 +22,18 @@
mkdirSync(logFolder, { recursive: true });
}
let statusCode: number;
if (batchType) {
statusCode = await generateSdkForBatchSpecs(batchType);
} else if (pullRequestNumber) {
statusCode = await generateSdkForSpecPr();
} else {
statusCode = await generateSdkForSingleSpec();
try {
if (batchType) {
statusCode = await generateSdkForBatchSpecs(batchType);
} else if (pullRequestNumber) {
statusCode = await generateSdkForSpecPr();
} else {
statusCode = await generateSdkForSingleSpec();
}
} catch (error) {
console.error("Unhandled exception in spec-gen-sdk-runner:", error);
console.log("##vso[task.complete result=Failed;]");
exit(1);
}
if (statusCode !== 0) {
console.log("##vso[task.complete result=Failed;]");
Expand Down
9 changes: 2 additions & 7 deletions eng/tools/spec-gen-sdk-runner/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { getChangedFiles as getChangedFilesShared } from "@azure-tools/specs-shared/changed-files";
import { exec, spawn, spawnSync } from "node:child_process";
import fs from "node:fs";
Expand Down Expand Up @@ -249,13 +249,8 @@
results.push(currentPath);
}
} catch (error) {
logMessage(
`Error reading directory: ${currentPath}. ` +
`If this is a transient IO error, please re-run the pipeline. ` +
`Error details: ${inspect(error)}`,
LogLevel.Error,
);
throw error;
logMessage(`Error reading directory: ${currentPath} with ${inspect(error)}`, LogLevel.Warn);
return results;
}
currentPath = path.dirname(currentPath);
// Check if we've reached the root of the path (stopAtFolder) or
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, test } from "vitest";
Expand Down Expand Up @@ -66,10 +66,13 @@
);
});

test("throws error when directory does not exist", () => {
expect(() =>
findAllParentsWithFile("specification/nonexistent/path", typespecProjectRegex, repoRoot),
).toThrow(/ENOENT/);
test("returns empty array when directory does not exist", () => {
const result = findAllParentsWithFile(
"specification/nonexistent/path",
typespecProjectRegex,
repoRoot,
);
expect(result).toHaveLength(0);
});

test("stops at specified boundary and finds files before it", () => {
Expand Down
Loading