From 13548704cd933d8d80f378e2c15ab6d67eb3fe5c Mon Sep 17 00:00:00 2001 From: Dayoung Lee Date: Thu, 14 Sep 2023 17:32:54 +0900 Subject: [PATCH] [Backend] Remove executors (#1636) --- src/Backend/API.ts | 27 +-------------------------- src/Tests/Backend/Backend.test.ts | 31 +------------------------------ 2 files changed, 2 insertions(+), 56 deletions(-) diff --git a/src/Backend/API.ts b/src/Backend/API.ts index d1fe455ca..5b351290c 100644 --- a/src/Backend/API.ts +++ b/src/Backend/API.ts @@ -19,7 +19,6 @@ const assert = require("assert"); import { Backend } from "./Backend"; import { gToolchainEnvMap, ToolchainEnv } from "../Toolchain/ToolchainEnv"; import { Logger } from "../Utils/Logger"; -import { Executor } from "./Executor"; /** * Interface of backend map @@ -32,8 +31,6 @@ interface BackendMap { // TODO Move outside API.ts // List of backend extensions registered let globalBackendMap: BackendMap = {}; -// List of Executor extensions registered -let globalExecutorArray: Executor[] = []; const logTag = "API"; @@ -57,10 +54,6 @@ const registerBackend = (backend: Backend) => { "enabled" ); } - const executor = backend.executor(); - if (executor) { - globalExecutorArray.push(executor); - } Logger.info( logTag, @@ -76,26 +69,8 @@ const registerBackend = (backend: Backend) => { vscode.commands.executeCommand("one.device.refresh"); }; -const registerExecutor = (executor: Executor) => { - globalExecutorArray.push(executor); - Logger.info( - "API", - "Executor", - executor.name(), - "was registered into ONE-vscode." - ); - - // NOTE: This might not 100% guaratee the activating extension has been done. - // - link: https://github.com/Samsung/ONE-vscode/pull/1101#issuecomment-1195099002 - // TODO: Consider better way to refresh toolchainView after backend's registration. - vscode.commands.executeCommand("one.device.refresh"); -}; - -// TODO Add removeBackend - export const API = { registerBackend, - registerExecutor, }; -export { globalBackendMap, globalExecutorArray }; +export { globalBackendMap }; diff --git a/src/Tests/Backend/Backend.test.ts b/src/Tests/Backend/Backend.test.ts index aec203a70..97c499086 100644 --- a/src/Tests/Backend/Backend.test.ts +++ b/src/Tests/Backend/Backend.test.ts @@ -16,7 +16,7 @@ import { assert } from "chai"; -import { API, globalBackendMap, globalExecutorArray } from "../../Backend/API"; +import { API, globalBackendMap } from "../../Backend/API"; import { Backend } from "../../Backend/Backend"; import { Compiler, CompilerBase } from "../../Backend/Compiler"; import { Executor, ExecutorBase } from "../../Backend/Executor"; @@ -47,19 +47,11 @@ class BackendMockup implements Backend { } } -const executorName = "Mockup"; -class ExecutorMockup extends ExecutorBase { - name(): string { - return executorName; - } -} - suite("Backend", function () { suite("backendAPI", function () { test("registers a OneToolchain", function () { let oneBackend = new OneToolchain(); assert.strictEqual(Object.entries(globalBackendMap).length, 1); - assert.strictEqual(globalExecutorArray.length, 0); const entries = Object.entries(globalBackendMap); assert.strictEqual(entries.length, 1); @@ -71,7 +63,6 @@ suite("Backend", function () { }); test("registers a backend", function () { assert.strictEqual(Object.entries(globalBackendMap).length, 1); - assert.strictEqual(globalExecutorArray.length, 0); let backend = new BackendMockup(); API.registerBackend(backend); @@ -86,23 +77,6 @@ suite("Backend", function () { assert.deepStrictEqual(value, backend); } } - - assert.strictEqual(globalExecutorArray.length, 1); - for (const executor of globalExecutorArray) { - assert.deepStrictEqual(executor, backend.executor()); - } - assert.deepStrictEqual(backend.executors(), globalExecutorArray); - }); - test("registers a executor", function () { - assert.strictEqual(globalExecutorArray.length, 0); - let executorMockup = new ExecutorMockup(); - API.registerExecutor(executorMockup); - - assert.strictEqual(globalExecutorArray.length, 1); - - for (const executor of globalExecutorArray) { - assert.deepStrictEqual(executor, executorMockup); - } }); }); @@ -113,8 +87,5 @@ suite("Backend", function () { if (gToolchainEnvMap[backendName] !== undefined) { delete gToolchainEnvMap[backendName]; } - while (globalExecutorArray.length > 0) { - globalExecutorArray.pop(); - } }); });