Skip to content

Commit

Permalink
[Backend] Remove executors
Browse files Browse the repository at this point in the history
This commit removes executors as they are not used anywhere.

ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee <[email protected]>
  • Loading branch information
dayo09 committed Sep 12, 2023
1 parent bece45d commit 5758152
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 54 deletions.
25 changes: 1 addition & 24 deletions src/Backend/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,8 +30,6 @@ interface BackendMap {

// List of backend extensions registered
let globalBackendMap: BackendMap = {};
// List of Executor extensions registered
let globalExecutorArray: Executor[] = [];

const logTag = "API";

Expand All @@ -44,10 +41,6 @@ const registerBackend = (backend: Backend) => {
if (compiler) {
gToolchainEnvMap[backend.name()] = new ToolchainEnv(compiler);
}
const executor = backend.executor();
if (executor) {
globalExecutorArray.push(executor);
}

Logger.info(
logTag,
Expand All @@ -63,24 +56,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");
};

export const API = {
registerBackend,
registerExecutor,
};

export { globalBackendMap, globalExecutorArray };
export { globalBackendMap };
31 changes: 1 addition & 30 deletions src/Tests/Backend/Backend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
});
});

Expand All @@ -113,8 +87,5 @@ suite("Backend", function () {
if (gToolchainEnvMap[backendName] !== undefined) {
delete gToolchainEnvMap[backendName];
}
while (globalExecutorArray.length > 0) {
globalExecutorArray.pop();
}
});
});

0 comments on commit 5758152

Please sign in to comment.