Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead code clean up (smol PR) #4653

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lang/langHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Program,
_executor,
executor,
ProgramMemory,
programMemoryInit,
kclLint,
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function executeAst({
}
const execState = await (useFakeExecutor
? enginelessExecutor(ast, programMemoryOverride || programMemoryInit())
: _executor(
: executor(
ast,
programMemoryInit(),
idGenerator,
Expand Down
24 changes: 0 additions & 24 deletions src/lang/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
return program
} catch (e: any) {
// throw e
const parsed: RustKclError = JSON.parse(e.toString())

Check failure on line 134 in src/lang/wasm.ts

View workflow job for this annotation

GitHub Actions / yarn-unit-test

src/lang/wasm.test.ts > can execute parsed AST

SyntaxError: Unexpected token 'T', "TypeError:"... is not valid JSON ❯ Module.parse src/lang/wasm.ts:134:39 ❯ src/lang/wasm.test.ts:8:15
return new KCLError(
parsed.kind,
parsed.msg,
Expand Down Expand Up @@ -396,30 +396,6 @@
}

export const executor = async (
node: Node<Program>,
programMemory: ProgramMemory | Error = ProgramMemory.empty(),
idGenerator: IdGenerator = defaultIdGenerator(),
engineCommandManager: EngineCommandManager,
isMock: boolean = false
): Promise<ExecState> => {
if (err(programMemory)) return Promise.reject(programMemory)

// eslint-disable-next-line @typescript-eslint/no-floating-promises
engineCommandManager.startNewSession()
const _programMemory = await _executor(
node,
programMemory,
idGenerator,
engineCommandManager,
isMock
)
await engineCommandManager.waitForAllCommands()

engineCommandManager.endSession()
return _programMemory
}

export const _executor = async (
node: Node<Program>,
programMemory: ProgramMemory | Error = ProgramMemory.empty(),
idGenerator: IdGenerator = defaultIdGenerator(),
Expand Down
51 changes: 4 additions & 47 deletions src/lib/testHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import {
Program,
ProgramMemory,
_executor,
executor,
SourceRange,
ExecState,
defaultIdGenerator,
} from '../lang/wasm'
import {
EngineCommandManager,
EngineCommandManagerEvents,
} from 'lang/std/engineConnection'
import { EngineCommandManager } from 'lang/std/engineConnection'
import { EngineCommand } from 'lang/std/artifactGraph'
import { Models } from '@kittycad/lib'
import { v4 as uuidv4 } from 'uuid'
import { DefaultPlanes } from 'wasm-lib/kcl/bindings/DefaultPlanes'
import { err, reportRejection } from 'lib/trap'
import { toSync } from './utils'
import { err } from 'lib/trap'
import { IdGenerator } from 'wasm-lib/kcl/bindings/IdGenerator'
import { Node } from 'wasm-lib/kcl/bindings/Node'

Expand Down Expand Up @@ -98,7 +94,7 @@ export async function enginelessExecutor(
}) as any as EngineCommandManager
// eslint-disable-next-line @typescript-eslint/no-floating-promises
mockEngineCommandManager.startNewSession()
const execState = await _executor(
const execState = await executor(
ast,
pm,
idGenerator,
Expand All @@ -108,42 +104,3 @@ export async function enginelessExecutor(
await mockEngineCommandManager.waitForAllCommands()
return execState
}

export async function executor(
ast: Node<Program>,
pm: ProgramMemory = ProgramMemory.empty(),
idGenerator: IdGenerator = defaultIdGenerator()
): Promise<ExecState> {
const engineCommandManager = new EngineCommandManager()
engineCommandManager.start({
setIsStreamReady: () => {},
setMediaStream: () => {},
width: 0,
height: 0,
makeDefaultPlanes: () => {
return new Promise((resolve) => resolve(defaultPlanes))
},
modifyGrid: (hidden: boolean) => {
return new Promise((resolve) => resolve())
},
})

return new Promise((resolve) => {
engineCommandManager.addEventListener(
EngineCommandManagerEvents.SceneReady,
toSync(async () => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
engineCommandManager.startNewSession()
const execState = await _executor(
ast,
pm,
idGenerator,
engineCommandManager,
false
)
await engineCommandManager.waitForAllCommands()
resolve(execState)
}, reportRejection)
)
})
}
Loading