move TTC capture to unit test (#7268)

* move TTC capture to unit test

* progress with artifact

* fmt

* abstract cases

* add another case

* add another test

* update snapshots with proper file names

* force to JSON

* fmt

* make jest happy

* add another example and other tweaks

* fix

* tweak

* add logs

* more logs

* strip out kcl version

* remove logs

* add comment explainer

* more comments

* more comment

* remove package-lock line
This commit is contained in:
Kurt Hutten
2025-06-06 11:29:20 +10:00
committed by GitHub
parent c43ec280f2
commit 0bce7d3c1c
7 changed files with 1117 additions and 1 deletions

View File

@ -1,7 +1,7 @@
import type { Binary as BSONBinary } from 'bson'
import { v4 } from 'uuid'
import type { AnyMachineSnapshot } from 'xstate'
import type { CallExpressionKw, SourceRange } from '@src/lang/wasm'
import type { CallExpressionKw, ExecState, SourceRange } from '@src/lang/wasm'
import { isDesktop } from '@src/lib/isDesktop'
import type { AsyncFn } from '@src/lib/types'
@ -522,6 +522,20 @@ export function getModuleId(sourceRange: SourceRange) {
return sourceRange[2]
}
export function getModuleIdByFileName(
fileName: string,
fileNames: ExecState['filenames']
) {
const module = Object.entries(fileNames).find(
([, moduleInfo]) =>
moduleInfo?.type === 'Local' && moduleInfo.value === fileName
)
if (module) {
return Number(module[0]) // Return the module ID
}
return -1
}
export function getInVariableCase(name: string, prefixIfDigit = 'm') {
// As of 2025-04-08, standard case for KCL variables is camelCase
const startsWithANumber = !Number.isNaN(Number(name.charAt(0)))