summaryrefslogtreecommitdiff
path: root/extension/src/activation/test/environmentSetup.test.ts
diff options
context:
space:
mode:
authorKirill Dubovitskiy <kirill2003de@gmail.com>2023-08-07 14:54:37 -0700
committerKirill Dubovitskiy <kirill2003de@gmail.com>2023-08-07 15:25:11 -0700
commitc12be8daf60cd3d5554e9f5465aa5e8a5187d288 (patch)
tree9e92dc4a10004ec13cb2bfb45be8828bd2fb4dc6 /extension/src/activation/test/environmentSetup.test.ts
parent0fc56305d762181519569098a99faa255f9cd24f (diff)
downloadsncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.tar.gz
sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.tar.bz2
sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.zip
Refactor test scripts and update build configurations
- Added a new esbuild for: - bundling test runners (run tests on vscode + mocha runner) - bundling all tests in the project - Some opinionated renamings / moving test related things around - Changed output directory in tsconfig to avoid overriding the entire out directory - bundles tests also go there Some poking around trying to deprecate jest as it is not used and mocha is more often used for vscode extension testing. Though I assume jest was added to test GUI within extension. This work was started because there are compilation issues with the current setup and neither of the tests are actually working so figured getting one to a working spot is a good start
Diffstat (limited to 'extension/src/activation/test/environmentSetup.test.ts')
-rw-r--r--extension/src/activation/test/environmentSetup.test.ts70
1 files changed, 0 insertions, 70 deletions
diff --git a/extension/src/activation/test/environmentSetup.test.ts b/extension/src/activation/test/environmentSetup.test.ts
deleted file mode 100644
index ca487416..00000000
--- a/extension/src/activation/test/environmentSetup.test.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-const child_process = require("child_process");
-import { platform } from "os";
-import { getPythonPipCommands } from "../environmentSetup";
-
-jest.mock("os");
-jest.mock("child_process");
-
-function mockPythonVersionMappings(mappings: { [pythonCmd: string]: string }) {
- (child_process.exec as jest.Mock).mockImplementation(
- (command: string, options: any) => {
- const pythonCmd = command.split(" ")[0];
- if (pythonCmd in mappings) {
- return Promise.resolve([mappings[pythonCmd], ""]);
- } else {
- return Promise.resolve(["", stubStderr]);
- }
- }
- );
-}
-
-const stubStderr =
- "This is a stub stderr, but will be checked only for existence.";
-describe("getPythonPipCommands", () => {
- describe("on Windows", () => {
- it("should return the correct Python and Pip commands", async () => {
- (platform as jest.Mock).mockReturnValue("win32");
- mockPythonVersionMappings({
- python: "Python 3.8.0",
- });
-
- const [pythonCmd, pipCmd] = await getPythonPipCommands();
-
- expect(pythonCmd).toBe("python");
- expect(pipCmd).toBe("pip");
-
- jest.restoreAllMocks();
- });
- describe("on MacOS", () => {
- (platform as jest.Mock).mockReturnValue("darwin");
- it("should check through all python versions after finding 3.7", async () => {
- mockPythonVersionMappings({
- python: "",
- python3: "Python 3.7.0",
- "python3.11": "Python 3.11.0",
- });
-
- const [pythonCmd, pipCmd] = await getPythonPipCommands();
-
- expect(pythonCmd).toBe("python3.11");
- expect(pipCmd).toBe("pip3.11");
-
- jest.restoreAllMocks();
- });
-
- it("should use python3 if that maps to valid version", async () => {
- mockPythonVersionMappings({
- python: "",
- python3: "Python 3.8.0",
- });
-
- const [pythonCmd, pipCmd] = await getPythonPipCommands();
-
- expect(pythonCmd).toBe("python3");
- expect(pipCmd).toBe("pip3");
-
- jest.restoreAllMocks();
- });
- });
- });
-});