diff --git a/packages/runtime/test/common-symbols.test.ts b/packages/runtime/test/common-symbols.test.ts index 344bd01d6..33930c2a4 100644 --- a/packages/runtime/test/common-symbols.test.ts +++ b/packages/runtime/test/common-symbols.test.ts @@ -2,6 +2,7 @@ import { execFile, spawnSync } from "node:child_process"; import { mkdir, readdir, readFile } from "node:fs/promises"; import { availableParallelism } from "node:os"; import { join } from "node:path"; +import { pathToFileURL } from "node:url"; import { promisify } from "node:util"; import { expect, test } from "vitest"; @@ -10,6 +11,19 @@ const testDir = import.meta.dirname; const srcDir = join(testDir, "../src"); const vendorDir = join(testDir, "../vendor"); const buildDir = join(testDir, "build", "common-symbols"); +const repoRoot = join(testDir, "../../.."); + +/** scr_intl.c includes ICU's C API headers from the fetched ICU release, as + * the runtime pack build compiles it (runtime-pack-common's icu-data.mjs). */ +async function icuIncludeFlags(): Promise { + const { ensureIcuSources } = (await import( + pathToFileURL(join(repoRoot, "packages/runtime-pack-common/scripts/icu-data.mjs")).href + )) as { ensureIcuSources: (cacheDir: string) => Promise }; + const root = await ensureIcuSources( + join(repoRoot, "node_modules", ".cache", "scriptc-icu-sources"), + ); + return ["-I", join(root, "source", "common"), "-I", join(root, "source", "i18n")]; +} /** COMMON globals in every runtime source compiled with `compiler`, in the * plain and worker configurations, as "file (defines): symbol" lines. */ @@ -22,6 +36,7 @@ async function commonSymbols(label: string, compiler: string[]): Promise [[], ["-DSCR_WORKERS"]].map((defines) => ({ name, defines })), ); + const icu = await icuIncludeFlags(); const common: string[] = []; let next = 0; const worker = async (): Promise => { @@ -39,6 +54,7 @@ async function commonSymbols(label: string, compiler: string[]): Promise