Merge branch 'main' into github-action/bump-cli

This commit is contained in:
Chris Smowton
2024-06-13 14:33:51 +01:00
committed by GitHub
2 changed files with 3 additions and 98 deletions

View File

@@ -717,12 +717,13 @@ async function installOrUpdateThenTryActivate(
return undefined; return undefined;
} }
const PACK_GLOBS = [ const CLEAR_PACK_CACHE_ON_EDIT_GLOBS = [
"**/codeql-pack.yml", "**/codeql-pack.yml",
"**/qlpack.yml", "**/qlpack.yml",
"**/queries.xml", "**/queries.xml",
"**/codeql-pack.lock.yml", "**/codeql-pack.lock.yml",
"**/qlpack.lock.yml", "**/qlpack.lock.yml",
"**/*.dbscheme",
".codeqlmanifest.json", ".codeqlmanifest.json",
"codeql-workspace.yml", "codeql-workspace.yml",
]; ];
@@ -769,7 +770,7 @@ async function activateWithInstalledDistribution(
ctx, ctx,
); );
for (const glob of PACK_GLOBS) { for (const glob of CLEAR_PACK_CACHE_ON_EDIT_GLOBS) {
const fsWatcher = workspace.createFileSystemWatcher(glob); const fsWatcher = workspace.createFileSystemWatcher(glob);
ctx.subscriptions.push(fsWatcher); ctx.subscriptions.push(fsWatcher);

View File

@@ -1,96 +0,0 @@
import { platform } from "os";
import type { BaseLogger } from "../../../src/common/logging";
import { expandShortPaths } from "../../../src/common/short-paths";
import { join } from "path";
describe("expandShortPaths", () => {
let logger: BaseLogger;
beforeEach(() => {
logger = {
log: jest.fn(),
};
});
describe("on POSIX", () => {
if (platform() === "win32") {
console.log(`Skipping test on Windows`);
return;
}
it("should return the same path for non-Windows platforms", async () => {
const path = "/home/user/some~path";
const result = await expandShortPaths(path, logger);
expect(logger.log).not.toHaveBeenCalled();
expect(result).toBe(path);
});
});
describe("on Windows", () => {
if (platform() !== "win32") {
console.log(`Skipping test on non-Windows`);
return;
}
it("should return the same path if no short components", async () => {
const path = "C:\\Program Files\\Some Folder";
const result = await expandShortPaths(path, logger);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short paths in: ${path}`,
);
expect(logger.log).toHaveBeenCalledWith(
"Skipping due to no short components",
);
expect(result).toBe(path);
});
it("should not attempt to expand long paths with '~' in the name", async () => {
const testDir = join(__dirname, "../data/short-paths");
const path = join(testDir, "textfile-with~tilde.txt");
const result = await expandShortPaths(path, logger);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short paths in: ${path}`,
);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short path component: textfile-with~tilde.txt`,
);
expect(logger.log).toHaveBeenCalledWith(`Component is not a short name`);
expect(result).toBe(join(testDir, "textfile-with~tilde.txt"));
});
it("should expand a short path", async () => {
const path = "C:\\PROGRA~1\\Some Folder";
const result = await expandShortPaths(path, logger);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short paths in: ${path}`,
);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short path component: PROGRA~1`,
);
expect(result).toBe("C:\\Program Files\\Some Folder");
});
it("should expand multiple short paths", async () => {
const testDir = join(__dirname, "../data/short-paths");
const path = join(testDir, "FOLDER~1", "TEXTFI~1.TXT");
const result = await expandShortPaths(path, logger);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short paths in: ${path}`,
);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short path component: FOLDER~1`,
);
expect(logger.log).toHaveBeenCalledWith(
`Expanding short path component: TEXTFI~1.TXT`,
);
expect(result).toBe(
join(testDir, "folder with space", ".textfile+extra.characters.txt"),
);
});
});
});