From c12be8daf60cd3d5554e9f5465aa5e8a5187d288 Mon Sep 17 00:00:00 2001 From: Kirill Dubovitskiy Date: Mon, 7 Aug 2023 14:54:37 -0700 Subject: 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 --- .../src/activation/test/environmentSetup.test.ts | 70 ---------------------- 1 file changed, 70 deletions(-) delete mode 100644 extension/src/activation/test/environmentSetup.test.ts (limited to 'extension/src/activation/test') 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(); - }); - }); - }); -}); -- cgit v1.2.3-70-g09d2