Skip to content

Commit 5cd6b9e

Browse files
[tsp-client] Misc fixes (Azure#13078)
* add output-dir warning * reduce test failures * fix test clean up * fix test clean up --------- Co-authored-by: catalinaperalta <caperal@microsoft.com>
1 parent d6312e9 commit 5cd6b9e

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

tools/tsp-client/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ const parser = yargs(hideBin(process.argv))
134134
});
135135
},
136136
async (argv: any) => {
137+
if (argv["output-dir"] !== undefined) {
138+
Logger.warn(
139+
"'output-dir' option is ignored when 'emitter-output-dir' is specified in emitter options.",
140+
);
141+
}
137142
argv["output-dir"] = resolveOutputDir(argv);
138143
await initCommand(argv);
139144
},
@@ -218,6 +223,11 @@ const parser = yargs(hideBin(process.argv))
218223
});
219224
},
220225
async (argv: any) => {
226+
if (argv["output-dir"] !== undefined) {
227+
Logger.warn(
228+
"'output-dir' is only used to find directory containing tsp-location.yaml, the value isn't interpolated when 'emitter-output-dir' is specified in emitter options.",
229+
);
230+
}
221231
argv["output-dir"] = resolveOutputDir(argv);
222232
await updateCommand(argv);
223233
},

tools/tsp-client/test/commands.spec.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,17 @@ describe.sequential("Verify commands", () => {
3838
});
3939

4040
afterAll(async () => {
41-
await rm(joinPaths(repoRoot, "eng", "emitter-package.json"));
42-
43-
// This is generated in the first test using the command
44-
const emitterPackageLock = joinPaths(repoRoot, "eng", "emitter-package-lock.json");
45-
if (await doesFileExist(emitterPackageLock)) {
46-
await rm(emitterPackageLock);
47-
}
48-
49-
await rm("./test/examples/sdk/local-spec-sdk/TempTypeSpecFiles/", { recursive: true });
50-
await rm("./test/examples/initGlobalConfig/", { recursive: true });
51-
await rm("./test/examples/initGlobalConfigNoMatch/", { recursive: true });
41+
await rm(joinPaths(repoRoot, "eng", "emitter-package.json"), { force: true });
42+
await rm(joinPaths(repoRoot, "eng", "emitter-package-lock.json"), { force: true });
43+
await rm("./test/examples/sdk/local-spec-sdk/TempTypeSpecFiles/", {
44+
recursive: true,
45+
force: true,
46+
});
47+
await rm("./test/examples/initGlobalConfig/", { recursive: true, force: true });
48+
await rm("./test/examples/initGlobalConfigNoMatch/", { recursive: true, force: true });
5249
await rm(
5350
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest/TempTypeSpecFiles/",
54-
{ recursive: true },
51+
{ recursive: true, force: true },
5552
);
5653
await rm(joinPaths(repoRoot, "sdk/keyvault"), { recursive: true, force: true });
5754
});

tools/tsp-client/test/metadata.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe.sequential("tsp-client metadata generation", function () {
4141

4242
afterEach(async function () {
4343
// Clean up test files
44-
await removeDirectory(testOutputDir).catch(() => {});
44+
await rm(testOutputDir, { recursive: true, force: true });
4545
});
4646

4747
it("should create tsp-client-metadata.yaml with correct structure", async function () {

tools/tsp-client/test/utils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe("Verify fs functions", function () {
134134
});
135135

136136
afterAll(async () => {
137-
await rm(joinPaths(await getRepoRoot("."), "eng", "tsp-client-config.yaml"));
137+
await rm(joinPaths(await getRepoRoot("."), "eng", "tsp-client-config.yaml"), { force: true });
138138
});
139139

140140
it("Check parseTspClientRepoConfig", async function () {

0 commit comments

Comments
 (0)